本文整理汇总了C#中IList.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# IList.Remove方法的具体用法?C# IList.Remove怎么用?C# IList.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.Remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Merge
private static IList<int> Merge(IList<int> left, IList<int> right)
{
var result = new List<int>();
while (left.Any() && right.Any())
{
if (left[0] < right[0])
{
result.Add(left[0]);
left.Remove(left[0]);
}
result.Add(right[0]);
right.Remove(right[0]);
}
while (left.Any())
{
result.Add(left[0]);
left.Remove(left[0]);
}
while (right.Any())
{
result.Add(right[0]);
right.Remove(right[0]);
}
return result;
}
示例2: GuerillaPreProcessMethod
protected static void GuerillaPreProcessMethod(BinaryReader binaryReader, IList<tag_field> fields)
{
var field = fields.Last(x => x.type != field_type._field_terminator);
fields.Remove(field);
field = fields.Last(x => x.type != field_type._field_terminator);
fields.Remove(field);
}
示例3: AskForBid
public BidType AskForBid(Contract currentContract, IList<BidType> allowedBids, IList<BidType> previousBids)
{
if (this.AlwaysPass)
{
return BidType.Pass;
}
allowedBids.Remove(BidType.Double);
allowedBids.Remove(BidType.ReDouble);
return allowedBids.RandomElement();
}
示例4: MergeClustersIfRequired
public IList<ClusterPrototype> MergeClustersIfRequired(IList<ClusterPrototype> clusters)
{
var clustersToIterateOver = new List<ClusterPrototype>(clusters);
foreach (var cluster in clustersToIterateOver) {
foreach (var otherCluster in new List<ClusterPrototype>(clusters)) {
if (cluster != otherCluster && this.IsMergeRequired(cluster, otherCluster)) {
clusters.Remove(cluster);
clusters.Remove(otherCluster);
clusters.Add(ClusterPrototype.Merge(cluster, otherCluster));
}
}
}
return clusters;
}
示例5: remove
public static bool remove(IList collection, object value)
{
bool b = collection.Contains(value);
if (b)
collection.Remove(value);
return b;
}
示例6: ProcessFactories
private void ProcessFactories(XmlNode node, IList factories)
{
foreach ( XmlNode child in node.ChildNodes )
{
Type type;
switch ( child.LocalName )
{
case "add":
type = Type.GetType(child.Attributes["type"].Value);
if ( !factories.Contains(type) )
factories.Add(type);
break;
case "remove":
type = Type.GetType(child.Attributes["type"].Value);
if ( factories.Contains(type) )
factories.Remove(type);
break;
case "clear":
factories.Clear();
break;
default:
// gives obsolete warning but needed for .NET 1.1 support
throw new ConfigurationException(string.Format("Unknown element '{0}' in section '{0}'", child.LocalName, node.LocalName));
}
}
}
示例7: SortGraph
IEnumerable<ModuleDefMD> SortGraph(IEnumerable<ModuleDefMD> roots, IList<DependencyGraphEdge> edges)
{
var visited = new HashSet<ModuleDefMD>();
var queue = new Queue<ModuleDefMD>(roots);
do {
while (queue.Count > 0) {
var node = queue.Dequeue();
visited.Add(node);
Debug.Assert(!edges.Where(edge => edge.To == node).Any());
yield return node;
foreach (DependencyGraphEdge edge in edges.Where(edge => edge.From == node).ToList()) {
edges.Remove(edge);
if (!edges.Any(e => e.To == edge.To))
queue.Enqueue(edge.To);
}
}
if (edges.Count > 0) {
foreach (var edge in edges) {
if (!visited.Contains(edge.From)) {
queue.Enqueue(edge.From);
break;
}
}
}
} while (edges.Count > 0);
}
示例8: RemoveMany
public static void RemoveMany(IList list, IEnumerable itemsToRemove)
{
foreach (var item in itemsToRemove)
{
list.Remove(item);
}
}
示例9: CheckActionList
private static void CheckActionList(IList<IBfsAction> actions, IBfsDataBlock block)
{
if (actions == null)
return;
for( int index = 0; index < actions.Count; index++)
{
IBfsAction action = actions[index];
if (action is BfsActionUnresolvedAssignment)
{
BfsActionUnresolvedAssignment unresolved = action as BfsActionUnresolvedAssignment;
BfsActionAssignment assignment = new BfsActionAssignment();
assignment.Expression = unresolved.Expression;
assignment.SourceRange = unresolved.SourceRange;
if (block.LocalFields.ContainsKey(unresolved.UnresolvedVariableName))
assignment.LocalVariable = block.LocalFields[unresolved.UnresolvedVariableName];
else
BfsCompiler.ReportError(assignment.SourceRange,
"Could not find local variable: '"+unresolved.UnresolvedVariableName+"'");
actions.Insert(index, assignment);
actions.Remove(action);
}
}
}
示例10: LargestStock
private static void LargestStock(IList<double> cuts, IList<Board> stockList)
{
var longest = stockList.OrderByDescending(x => x.Length).First();
var longestBoard = longest.Length;
var boardCost = longest.Price;
var scraps = new List<double>();
var stockUsed = new List<Board>();
while (cuts.Any())
{
var longestCut = cuts.OrderByDescending(x => x).First();
cuts.Remove(longestCut);
if (scraps.Any(x => x > longestCut))
{
scraps = scraps.CutFromScrap(longestCut);
}
else
{
stockUsed.Add(longest);
scraps.Add(longestBoard - longestCut - kerf);
}
}
Console.WriteLine("Total number of boards used: {0}", stockUsed.Count());
Console.WriteLine("Total Cost: {0}", stockUsed.Count() * boardCost);
OutputWaste(scraps, stockUsed.Count() * longestBoard);
}
示例11: FireballEnemyCollisionTest
// when a ball hits an enemy both are destroyed
public bool FireballEnemyCollisionTest(IList<IEnemy> enemies)
{
Rectangle fbRectangle = fireball.GetRectangle();
Rectangle enemyRectangle;
Rectangle intersectionRectangle;
Queue<IEnemy> doomedEnemies = new Queue<IEnemy>();
foreach (IEnemy enemy in enemies)
{
enemyRectangle = enemy.GetRectangle();
intersectionRectangle = Rectangle.Intersect(fbRectangle, enemyRectangle);
if (!intersectionRectangle.IsEmpty)
{
// hud score method needed
doomedEnemies.Enqueue(enemy);
}
}
while (doomedEnemies.Count() > 0)
{
IEnemy e = doomedEnemies.Dequeue();
enemies.Remove(e);
return true;
}
return false;
}
示例12: RTAAPrefixPresenter
public RTAAPrefixPresenter(IRealTimeAdherenceModel model)
{
_model = model;
_newAddedSet = new List<AdherenceEvent>(50);
_removedSet = new List<AdherenceEvent>(50);
WhenAdding = o =>
{
IsDirty = true;
var e = new AdherenceEvent
{
Text = o.Text,
Start = o.Start.RemoveSeconds(),
End = o.End.Second == 0 ? o.End : o.End.AddSeconds(60 - o.End.Second),
Remark = "added",
Reason = SelectedAbsence
};
_newAddedSet.Add(e);
return e;
};
WhenChanged = o =>
{
IsDirty = true;
};
WhenRemoving = o =>
{
IsDirty = true;
_newAddedSet.Remove(o);
_removedSet.Add(o);
};
}
示例13: CalculateTime
public static void CalculateTime(IList list, int k)
{
// Add
var startAdding = DateTime.Now;
string test = "Test string";
for (int i = 0; i < k; i++)
{
list.Add(test);
}
var finishAdding = DateTime.Now;
Console.WriteLine("Addition time (" + k + " elements) : " + list.GetType() + " " + (finishAdding - startAdding));
// Search
var startSearch = DateTime.Now;
for (int i = 0; i < k; i++)
{
bool a = list.Contains(test);
}
var finishSearch = DateTime.Now;
Console.WriteLine("Search time (" + k + " elements) : " + list.GetType() + " " + (finishSearch - startSearch));
// Remove
k = 1000;
var startRemoving = DateTime.Now;
for (int i = 0; i < k; i++)
{
list.Remove(test);
}
var finishRemoving = DateTime.Now;
Console.WriteLine("Removal time (" + k + " elements) : " + list.GetType() + " " + (finishRemoving - startRemoving) + "\n");
}
示例14: Merge
public static IList<int> Merge(IList<int> left, IList<int> right)
{
IList<int> result = new List<int>();
while (left.Any() && right.Any())
{
if (left[0] < right[0])
{
result.Add(left[0]);
left.Remove(left[0]);
}
else
{
result.Add(right[0]);
right.Remove(right[0]);
}
}
while (left.Any())
{
result.Add(left[0]);
left.RemoveAt(0);
}
while (right.Any())
{
result.Add(right[0]);
right.RemoveAt(0);
}
return result;
}
示例15: ParseColumns
public List<PropertySpecification> ParseColumns(ref IList<string> rows)
{
// pick off the heading line
string line0 = rows[0];
var headings = rows[0].Split(',');
rows.Remove(line0);
List<PropertySpecification> propertySpecs = new List<PropertySpecification>();
int rownum = 0;
foreach (var line in rows)
{
if (line.Trim().Length == 0)
continue;
var row = SplitLine(line);
for (var columnid = 0; columnid < headings.Length; columnid++)
{
try
{
string contents = row[columnid].Replace("\"", "");
var deduced = InferType(ColumnTypeCreate(contents));
PropertySpecification spec = propertySpecs.FirstOrDefault(s => s.Id == columnid);
if (spec == null)
{
propertySpecs.Add(new PropertySpecification
{
ColumnName = headings[columnid].Replace('"', ' ').Replace("/", string.Empty),
Id = columnid,
ColumnType = deduced,
Nullable = CheckForNullable(contents, deduced)
});
}
else
{
// elevate the type
if (spec.ColumnType < deduced && spec.ColumnType != CTEnum.String)
{
spec.ColumnType = deduced;
}
if (!spec.Nullable)
{
if (deduced != CTEnum.String && contents.Length == 0)
Debug.WriteLine("Should be true");
spec.Nullable = CheckForNullable(contents, deduced);
}
}
}
catch (Exception e)
{
throw new Exception(string.Format("{0} - Row {1} - Column {2} - Value {3}", e.Message, line, rownum, row[columnid]));
}
}
rownum++;
if (rownum == 57)
System.Diagnostics.Debug.WriteLine("56");
}
return propertySpecs;
}