本文整理汇总了C#中IList.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# IList.RemoveAt方法的具体用法?C# IList.RemoveAt怎么用?C# IList.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.RemoveAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Filter
public override void Filter(IList<ContentItem> items)
{
while (items.Count > maxCount + startIndex)
items.RemoveAt(items.Count - 1);
while (items.Count > maxCount)
items.RemoveAt(0);
}
示例2: ModifyListForTest
private void ModifyListForTest(IList<string> list)
{
list[0] = "OneModified";
list.Insert(0, "Zero");
list.RemoveAt(0);
list.Insert(0, "ZeroAgain");
list.Insert(4, "Four");
list.RemoveAt(4);
list.Insert(4, "FourAgain");
}
示例3: BindQuestion
protected void BindQuestion()
{
queslist = CY.CSTS.Core.Business.Question.GetSqlWhere("[IsHomePage]=1");
unsolvequestion = new List<CY.CSTS.Core.Business.Question>();
for (int i = 0; i <= queslist.Count - 1; i++)
{
if (!isanswer(queslist.ElementAt(i).Id))
{
unsolvequestion.Add(queslist.ElementAt(i));
}
}
for (int i = queslist.Count - 1; i >= 0; i--)
{
if (!isanswer(queslist.ElementAt(i).Id))
{
queslist.RemoveAt(i);
}
}
if (queslist.Count >= 4)
{
for (int i = queslist.Count - 1; i >= 4; i--)
{
queslist.RemoveAt(i);
}
}
for (int i = 0, j = queslist.Count; i < j; i++)
{
//queslist[i].Title = CY.Utility.Common.StringUtility.CutString(queslist[i].Title, 80, "...");
}
//Questionlist.DataSource = queslist;
//Questionlist.DataBind();
if (unsolvequestion.Count >= 4)
{
for (int i = unsolvequestion.Count - 1; i >= 4; i--)
{
unsolvequestion.RemoveAt(i);
}
}
for (int i = 0, j = unsolvequestion.Count; i < j; i++)
{
//unsolvequestion[i].Title = CY.Utility.Common.StringUtility.CutString(unsolvequestion[i].Title, 80, "...");
}
}
示例4: Schedule
/// <summary>
/// Fill bigger time into scheduleList first, until there is no time smaller than [morning/afternoon]TimeLeft
/// </summary>
/// <param name="requests"></param>
/// <returns></returns>
public override IEnumerable<DaySchedule> Schedule(IList<ScheduleItem> requests)
{
if (requests.Count == 0) return null;
List<DaySchedule> scheduleList = new List<DaySchedule>();
while (requests.Count > 0)
{
DaySchedule daySchedule = new DaySchedule();
// Schedule morning meeting
int moringTimeLeft=ConfigurationSetting.MorningDuration;
for (int i = requests.Count-1; i >=0; i--)
{
if (requests[i].ScheduleTime == moringTimeLeft)
{
daySchedule.MorningPlan.Add(requests[i]);
requests.RemoveAt(i);
break;
}
else if (requests[i].ScheduleTime < moringTimeLeft)
{
daySchedule.MorningPlan.Add(requests[i]);
moringTimeLeft -= requests[i].ScheduleTime;
requests.RemoveAt(i);
}
}
// Schedule afternoon meeting
int afternoonTimeLeft = ConfigurationSetting.AfternoonDuration;
for (int i = requests.Count - 1; i >= 0; i--)
{
if (requests[i].ScheduleTime == afternoonTimeLeft)
{
daySchedule.AfternoonPlan.Add(requests[i]);
requests.RemoveAt(i);
break;
}
else if (requests[i].ScheduleTime < afternoonTimeLeft)
{
daySchedule.AfternoonPlan.Add(requests[i]);
afternoonTimeLeft -= requests[i].ScheduleTime;
requests.RemoveAt(i);
}
}
scheduleList.Add(daySchedule);
}
return scheduleList;
}
示例5: Perform
/// <summary>
/// Deletes the employee
/// </summary>
public override void Perform(IList<Employee> employees, IEnumerable<Employee> query, StringBuilder log)
{
var employee = employees[Index];
employees.RemoveAt(Index);
log.AppendFormat("Delete Employee {0}", employee.Name);
log.AppendLine();
}
示例6: RotateRight
public static void RotateRight(IList sequence, int count)
{
//This method makes a swap of the list elements to the right
object tmp = sequence[count - 1];
sequence.RemoveAt(count - 1);
sequence.Insert(0, tmp);
}
示例7: Draw
public override void Draw(
IList<Point> points,
double thickness,
int miterLimit,
ILogicalToScreenMapper logicalToScreenMapper)
{
// First define the geometric shape
var streamGeometry = new StreamGeometry();
using (var gc = streamGeometry.Open())
{
gc.BeginFigure(points[0], _fillAndClose, _fillAndClose);
points.RemoveAt(0);
gc.PolyLineTo(points, true, true);
}
using (var dc = RenderOpen())
dc.DrawGeometry(
_fillAndClose ? Brushes.White : null,
new Pen(
Brushes.White,
thickness == 1 ? 0.25 : thickness)
{
MiterLimit = miterLimit
},
streamGeometry);
}
示例8: FixExpressions
public IList<string> FixExpressions(IList<string> expressions)
{
expressions = RemoveEmptyExpressions(expressions);
var listHasChanged = true;
while (listHasChanged)
{
listHasChanged = false;
for (var i = 0; i < expressions.Count; i++)
{
var exp = expressions[i];
if (!this.expressionValidator.IsNumberAndOperator(exp)) continue;
var splitted = RemoveEmptyExpressions(SplitByOperator(exp));
expressions.RemoveAt(i);
foreach (var newExp in splitted)
{
expressions.Add(newExp.Trim());
i++;
}
listHasChanged = true;
}
}
return expressions;
}
示例9: Process
override protected void Process(IFCAnyHandle ifcPolyLoop)
{
base.Process(ifcPolyLoop);
List<IFCAnyHandle> ifcPolygon =
IFCAnyHandleUtil.GetAggregateInstanceAttribute<List<IFCAnyHandle>>(ifcPolyLoop, "Polygon");
if (ifcPolygon == null)
return; // TODO: WARN
Polygon = IFCPoint.ProcessScaledLengthIFCCartesianPoints(ifcPolygon);
int numVertices = Polygon.Count;
if (numVertices > 1)
{
if (Polygon[0].IsAlmostEqualTo(Polygon[numVertices - 1]))
{
// LOG: Warning: #: First and last points are almost identical, removing extra point.
Polygon.RemoveAt(numVertices - 1);
numVertices--;
}
}
if (numVertices < 3)
throw new InvalidOperationException("#" + ifcPolyLoop.StepId + ": Polygon attribute has only " + numVertices + " vertices, 3 expected.");
}
示例10: CheckFirstAndLastPoint
private void CheckFirstAndLastPoint(IList<Point> points)
{
if (this.DistanceIsTooSmall(points.Last(), points.First()))
{
points.RemoveAt(points.Count - 1);
}
}
示例11: SetExtension
///////////////////////////////////////////////////////////////////////
/// <summary>Replaces or adds an extension of the given type
/// to the list.
///
/// This method looks for the first element on the list of the
/// given type and replaces it with the new value. If there are
/// no element of this type yet, a new element is added at the
/// end of the list.
/// </summary>
/// <param name="extensionElements">list of IExtensionElement</param>
/// <param name="type">type of the element to be added, removed
/// or replaced</param>
/// <param name="newValue">new value for this element, null to
/// remove it</param>
///////////////////////////////////////////////////////////////////////
public static void SetExtension(IList<IExtensionElementFactory> extensionElements,
Type type,
IExtensionElementFactory newValue)
{
int count = extensionElements.Count;
for (int i = 0; i < count; i++)
{
object element = extensionElements[i];
if (type.IsInstanceOfType(element))
{
if (newValue == null)
{
extensionElements.RemoveAt(i);
}
else
{
extensionElements[i] = newValue;
}
return;
}
}
if (newValue != null)
{
extensionElements.Add(newValue);
}
}
示例12: Search
private void Search(Dictionary<int, int> count, IList<int> temp, IList<IList<int>> results)
{
if (!count.Any() && temp.Any())
{
results.Add(new List<int>(temp));
return;
}
var keys = count.Keys.ToList();
foreach (var key in keys)
{
temp.Add(key);
--count[key];
if (count[key] == 0) count.Remove(key);
Search(count, temp, results);
temp.RemoveAt(temp.Count - 1);
if (count.ContainsKey(key))
{
++count[key];
}
else
{
count[key] = 1;
}
}
}
示例13: AssignFragmentPeak
public void AssignFragmentPeak(IList<IAtomContainer> fragments, IEnumerable<Peak> peakList, double mzabs, double mzppm)
{
hits = new List<PeakMolPair>();
hitsAll = new List<PeakMolPair>();
foreach (var peak in peakList)
{
var haveFoundAMatch = false;
foreach (var fragment in fragments)
{
//matched peak
int hydrogensAdded;
double matchedMass;
double hydrogenPenalty;
if (MatchByMass(fragment, peak.Mass, mzabs, mzppm, out matchedMass, out hydrogenPenalty, out hydrogensAdded))
{
var match = new PeakMolPair(fragment, peak, matchedMass, GetMolecularFormulaAsString(fragment), hydrogenPenalty, double.Parse((string)fragment.getProperty("BondEnergy"), CultureInfo.InvariantCulture), GetNeutralChange(fragment, hydrogensAdded));
hitsAll.Add(match);
// If we don't yet have a match, add it
if (!haveFoundAMatch)
{
hits.Add(match);
haveFoundAMatch = true;
}
// If we do have a match, replace it if this new match has a lower hydrogen penalty
else if (hydrogenPenalty < hits.Last().HydrogenPenalty)
{
hits.RemoveAt(hits.Count - 1);
hits.Add(match);
}
}
}
}
}
示例14: CheckFirstAndLastPoint
private void CheckFirstAndLastPoint(IList<DepthPointEx> points)
{
if (PointsAreClose(points.Last(), points.First()))
{
points.RemoveAt(points.Count - 1);
}
}
示例15: BatchSave
public int BatchSave(IList<MsgRecord> msgRecords)
{
#region prevent duplicate data
IList<string> msgids=new List<string>();
for(int i=0;i<msgRecords.Count;i++)
{
msgids.Add(msgRecords[i].MsgID);
}
var query = from aa in msgRecordRepository.Table
join bb in msgids on aa.MsgID equals bb
select aa.MsgID;
IList<string> tempids = query.ToList();
#endregion
for (int i = msgRecords.Count-1; i >= 0; i--)
{
if(tempids.Contains(msgRecords[i].MsgID))
{
msgRecords.RemoveAt(i);
}
}
return msgRecordRepository.BatchInsert(msgRecords);
}