本文整理汇总了C#中OrderedBag.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# OrderedBag.Remove方法的具体用法?C# OrderedBag.Remove怎么用?C# OrderedBag.Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderedBag
的用法示例。
在下文中一共展示了OrderedBag.Remove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
static public Questionnaire Run()
{
Questionnaire questionnaire = new Questionnaire();
OrderedBag<Grille> OPEN = new OrderedBag<Grille>();
OrderedBag<Grille> CLOSE = new OrderedBag<Grille>();
Grille S = new Grille();
OPEN.Add(S);
while (OPEN.Count != 0)
{
Grille n = OPEN.RemoveFirst();
CLOSE.Add(n);
questionnaire.solutionsExplorer.Add(n.getStringEtat());
if (n.getDistanceSolution() == 0)
{
questionnaire.solutionMot = n.getSolutionMot();
questionnaire.solutionVisuelle = n.getSolutionVisuelle();
for (int i = 0; i < questionnaire.solutionVisuelle.Count; i++)
{
Console.Write("\n---Étape" + i + "----\n" + questionnaire.solutionVisuelle[i] + "----------");
}
return questionnaire;
}
foreach (Grille nPrime in n.getListSuccessor())
{
questionnaire.etatExplorer.Add(nPrime.getStringEtat());
if (Contient(OPEN, nPrime) != -1)
{
int position = Contient(OPEN, nPrime);
if (nPrime.getTotalDistance() < OPEN[position].getTotalDistance())
{
OPEN.Remove(OPEN[position]);
OPEN.Add(nPrime);
}
}
else if (Contient(CLOSE, nPrime) != -1)
{
int position = Contient(CLOSE, nPrime);
if (nPrime.getTotalDistance() < CLOSE[position].getTotalDistance())
{
CLOSE.Remove(CLOSE[position]);
OPEN.Add(nPrime);
}
}
else // Ni dans Close , ni dans OPEN
{
OPEN.Add(nPrime);
}
}
}
questionnaire.solutionMot = "Aucun chemin possible";
return questionnaire;
}
示例2: AStar
/// <summary>
/// AStar - Performs the A* algorithm search to find a
/// solution of a given BoardNode.
/// </summary>
/// <param name="root">BoardNode to find a solution for</param>
/// <returns>BoardNode containing the solution. NULL if no solution found</returns>
public static BoardNode AStar(BoardNode root)
{
BoardNode current = root;
Comparison<BoardNode> compare = new Comparison<BoardNode>(compareFScore);
OrderedBag<BoardNode> openList = new OrderedBag<BoardNode>(compare);
OrderedBag<BoardNode> closedList = new OrderedBag<BoardNode>(compare);
int curGScore;
int heuristic;
curGScore = 0;
heuristic = current.board.numRemainingLights();
current.gScore = curGScore;
current.fScore = (curGScore + heuristic);
openList.Add(current);
while(openList.Count != 0)
{
current = openList.GetFirst();
if(current.clicked.Capacity >= 100000)
{
return null;
}
if(current.board.solved())
{
return current;
}
openList.Remove(current);
closedList.Add(current);
addChildren(current);
foreach (BoardNode child in current.children)
{
if (closedList.Contains(child))
{
;
}
else
{
curGScore = current.gScore + 1;
if (openList.Contains(child) == false || curGScore < child.gScore)
{
child.gScore = (curGScore);
heuristic = child.board.numRemainingLights();
child.fScore = (curGScore + heuristic);
if (openList.Contains(child) == false)
{
openList.Add(child);
}
}
}
}
}
return null;
}
示例3: Main
static void Main()
{
Console.Write("Bag of Integers: ");
var bagOfInts = new Bag<int>();
bagOfInts.Add(3);
bagOfInts.Add(5);
bagOfInts.Add(5);
bagOfInts.Add(5);
bagOfInts.Add(10);
bagOfInts.Add(20);
bagOfInts.Add(20);
bagOfInts.Remove(5);
bagOfInts.RemoveAllCopies(20);
bagOfInts.UnionWith(new Bag<int>() { 3, 3, 4, 4, 5, 5 });
Console.WriteLine(bagOfInts);
Console.Write("OrderedBag of Integers: ");
var orderedBagOfInts = new OrderedBag<int>();
orderedBagOfInts.Add(3);
orderedBagOfInts.Add(5);
orderedBagOfInts.Add(5);
orderedBagOfInts.Add(5);
orderedBagOfInts.Add(10);
orderedBagOfInts.Add(20);
orderedBagOfInts.Add(20);
orderedBagOfInts.Remove(5);
orderedBagOfInts.RemoveAllCopies(20);
orderedBagOfInts.UnionWith(new OrderedBag<int>() { 3, 3, 4, 4, 5, 5 });
Console.WriteLine(orderedBagOfInts);
Console.WriteLine("Sub-range [5...10]: " +
orderedBagOfInts.Range(5, true, 10, true));
Console.Write("Set of Integers: ");
var setOfInts = new Set<int>();
setOfInts.Add(3);
setOfInts.Add(5);
setOfInts.Add(5);
setOfInts.Add(5);
setOfInts.Add(10);
setOfInts.Add(20);
setOfInts.Add(20);
setOfInts.Remove(5);
setOfInts.UnionWith(new Set<int>() { 3, 4, 5 });
Console.WriteLine(setOfInts);
Console.Write("OrderedSet of Integers: ");
var orderedSetOfInts = new OrderedSet<int>();
orderedSetOfInts.Add(3);
orderedSetOfInts.Add(5);
orderedSetOfInts.Add(5);
orderedSetOfInts.Add(5);
orderedSetOfInts.Add(10);
orderedSetOfInts.Add(20);
orderedSetOfInts.Add(20);
orderedSetOfInts.Remove(5);
orderedSetOfInts.UnionWith(new OrderedSet<int>() { 3, 4, 5 });
Console.WriteLine(orderedSetOfInts);
Console.WriteLine("Sub-range [5...20): " +
orderedSetOfInts.Range(5, true, 20, false));
Console.Write("MultiDictionary<string,int>: ");
var studentGrades = new MultiDictionary<string, int>(true);
studentGrades.Add("Peter", 3);
studentGrades.Add("Peter", 4);
studentGrades.Add("Peter", 4);
studentGrades.Add("Stanka", 6);
studentGrades.Add("Stanka", 5);
studentGrades.Add("Stanka", 6);
studentGrades.Add("Tanya", 6);
studentGrades.Add("Tanya", 4);
Console.WriteLine(studentGrades);
Console.WriteLine("OrderedMultiDictionary<string,int>:");
var distancesFromSofia = new OrderedMultiDictionary<int, string>(true);
distancesFromSofia.Add(149, "Plovdiv");
distancesFromSofia.Add(505, "Varna");
distancesFromSofia.Add(394, "Bourgas");
distancesFromSofia.Add(310, "Rousse");
distancesFromSofia.Add(163, "Pleven");
distancesFromSofia.Add(163, "Troyan");
foreach (var distanceTowns in distancesFromSofia)
{
Console.WriteLine("\t" + distanceTowns);
}
Console.Write("Deque<string>: ");
var people = new Deque<string>();
people.AddToBack("Kiro");
people.AddToBack("Maria");
people.AddToFront("Steve");
people.AddManyToBack(new string[] { "Ivan", "Veronika" });
Console.WriteLine(people);
Console.Write("BigList<int>: ");
var ints = new BigList<int>();
// var ints = new List<int>();
for (int i = 0; i < 1000000; i++)
{
ints.Add(i);
}
//.........这里部分代码省略.........
示例4: Main
static void Main()
{
OrderedBag<int> newBag = new OrderedBag<int>();
OrderedBag<int> newBag2 = new OrderedBag<int>();
OrderedBag<int> newBag3 = new OrderedBag<int>();
OrderedBag<int> newOrderedBag = new OrderedBag<int>();
OrderedBag<int> newOrderedBag2 = new OrderedBag<int>();
OrderedBag<int> newOrderedBag3 = new OrderedBag<int>();
for (int i = 4; i >= 0; i--)
{
newBag2.Add(numbers[i]);
newOrderedBag2.Add(numbers[i]);
}
for (int i = 5; i < 10; i++)
{
newBag.Add(numbers[i]);
newBag2.Add(numbers[i]);
newOrderedBag.Add(numbers[i]);
newOrderedBag2.Add(numbers[i]);
}
newBag3 = newBag2.Union(newBag);
Console.WriteLine("Union of 6-10 & 1-10 :");
Console.WriteLine("Unordered:");
Console.WriteLine();
foreach (int a in newBag3.list)
Console.Write(a + " ");
Console.WriteLine();
Console.WriteLine("Ordered:");
Console.WriteLine();
foreach (int a in newOrderedBag3.list)
Console.Write(a + " ");
Console.WriteLine();
Console.WriteLine("Adding 9-14 to ordered and unordered list.");
newBag2.Add(12);
newBag2.Add(10);
newBag2.Add(11);
newBag2.Add(14);
newBag2.Add(13);
newBag2.Add(9);
newOrderedBag2.Add(12);
newOrderedBag2.Add(10);
newOrderedBag2.Add(11);
newOrderedBag2.Add(14);
newOrderedBag2.Add(13);
newOrderedBag2.Add(9);
Console.WriteLine();
Console.WriteLine("Unordered Contains 23? : " + newBag3.Contains(23));
Console.WriteLine("Ordered Contains 23? : " + newOrderedBag3.Contains(23));
Console.WriteLine();
newBag3 = newBag.Intersection(newBag2);
newOrderedBag3 = newOrderedBag.Intersection(newOrderedBag2);
Console.WriteLine("Intersection of 6-10 & 1-10 :");
Console.WriteLine();
Console.WriteLine("Unordsered:");
Console.WriteLine();
foreach (int a in newBag3.list)
Console.Write(a + " ");
Console.WriteLine();
Console.WriteLine("Ordered:");
Console.WriteLine();
foreach (int a in newOrderedBag3.list)
Console.Write(a + " ");
Console.WriteLine();
Console.WriteLine("Unordered Contains 6? : " + newBag3.Contains(6));
Console.WriteLine();
Console.WriteLine("Ordered Contains 6? : " + newOrderedBag3.Contains(6));
Console.WriteLine();
newBag3.Remove(6);
newOrderedBag3.Remove(6);
Console.WriteLine();
Console.WriteLine("After removing 6, does unordered bag contain 6? : " + newBag3.Contains(6));
Console.WriteLine();
Console.WriteLine("After removing 6, does ordered bag contain 6? : " + newBag3.Contains(6));
}