本文整理汇总了C#中LinkedList.RemoveFirst方法的典型用法代码示例。如果您正苦于以下问题:C# LinkedList.RemoveFirst方法的具体用法?C# LinkedList.RemoveFirst怎么用?C# LinkedList.RemoveFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList
的用法示例。
在下文中一共展示了LinkedList.RemoveFirst方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getProductsFromBiobricks
public LinkedList<Product> getProductsFromBiobricks(LinkedList<BioBrick> list)
{
LinkedList<Product> products = new LinkedList<Product>();
Product prod;
RBSBrick rbs;
GeneBrick gene;
float RBSf = 0f;
string molName = "Unknown";
int i = 0;
foreach (BioBrick b in list)
{
rbs = b as RBSBrick;
if (rbs != null)
RBSf = rbs.getRBSFactor();
else
{
gene = b as GeneBrick;
if (gene != null)
{
molName = gene.getProteinName();
prod = new Product();
prod.setName(molName);
prod.setQuantityFactor(RBSf);
products.AddLast(prod);
}
else
Debug.Log("This case should never arrive. Bad Biobrick in operon.");
}
i++;
}
while (i > 0)
list.RemoveFirst();
return products;
}
示例2: Index
/// <summary>
/// Indexes the specified events.
/// </summary>
/// <param name="events">The events.</param>
/// <param name="predicateIndex">Index of the predicate.</param>
/// <returns></returns>
protected List<ComparableEvent> Index(LinkedList<Event> events, Dictionary<string, int> predicateIndex)
{
Dictionary<string, int> outcomeMap = new Dictionary<string, int>();
int numberOfEvents = events.Count;
int outcomeCount = 0;
List<ComparableEvent> eventsToCompare = new List<ComparableEvent>(numberOfEvents);
List<int> indexedContext = new List<int>();
for (int eventIndex = 0; eventIndex < numberOfEvents; eventIndex++)
{
Event ev = events.First.Value;
events.RemoveFirst();
string[] eventContext = ev.Context;
int outcomeId;
string outcome = ev.Outcome;
if (outcomeMap.ContainsKey(outcome))
{
outcomeId = outcomeMap[outcome];
}
else
{
outcomeId = outcomeCount++;
outcomeMap[outcome] = outcomeId;
}
UpdateIndexedContextList(indexedContext, predicateIndex, eventContext);
ProcessIndexedContextList(indexedContext, eventsToCompare, eventContext, outcomeId, outcome);
indexedContext.Clear();
}
OutcomeLabels = ToIndexedStringArray(outcomeMap);
PredicateLabels = ToIndexedStringArray(predicateIndex);
return eventsToCompare;
}
示例3: ExtractReportData
public override DataMatrix ExtractReportData(IProgressObserver progress)
{
var service = new TaxaService(User);
progress.ProgressStart(String.Format("Preparing Darwin Core records for {0} specimens...", _idSet.Count));
DataMatrix result = null;
var idSet = new LinkedList<int>(_idSet);
int chunkSize = 2000;
var helper = new DarwinCoreReportHelper();
var chunk = new List<int>();
var count = 0;
while (idSet.Count > 0) {
chunk.Add(idSet.First.Value);
idSet.RemoveFirst();
count++;
if (chunk.Count >= chunkSize || idSet.Count == 0) {
var percentComplete = ((double) count / (double) _idSet.Count) * 100;
progress.ProgressMessage(String.Format("Preparing Darwin Core records {0} of {1}", count, _idSet.Count), percentComplete);
var where = "tblMaterial.intMaterialID in (" + chunk.Join(",") + ")";
var dataChunk = helper.RunDwcQuery(service, where);
if (result == null) {
result = dataChunk;
} else {
result.AppendMatrix(dataChunk);
}
chunk = new List<int>();
}
}
progress.ProgressEnd(String.Format("{0} Darwin Core records retrieved.", count));
return result;
}
示例4: checkedFaces
/// <summary>
/// Returns the raw number of triangles actually checked for collision
/// (all triangles in all nodes that are reached)
/// </summary>
/// <param name="b"></param>
/// <param name="result"></param>
public void checkedFaces(BoundingSphere b, LinkedList<Face> result)
{
LinkedList<BspNode> toProcess = new LinkedList<BspNode>();
toProcess.AddLast(mRoot);
while (toProcess.Count > 0)
{
BspNode curNode = toProcess.First.Value;
toProcess.RemoveFirst();
if (curNode.separatingPlane.Normal.X == 0.0f &&
curNode.separatingPlane.Normal.Y == 0.0f &&
curNode.separatingPlane.Normal.Z == 0.0f &&
curNode.separatingPlane.D == 0.0f)
{
foreach (Face f in curNode.faces)
result.AddLast(f);
}
else
{
PlaneIntersectionType side = curNode.separatingPlane.Intersects(b);
if (side == PlaneIntersectionType.Back) toProcess.AddLast(curNode.neg);
else if (side == PlaneIntersectionType.Front) toProcess.AddLast(curNode.pos);
else
{
toProcess.AddLast(curNode.pos);
toProcess.AddLast(curNode.neg);
}
}
}
}
示例5: generateInternalName
private static string generateInternalName(LinkedList<ExpressionModule> modules)
{
Logger.Log("Device::generateInternalName(modules="+Logger.ToString(modules)+")", Logger.Level.INFO);
string name = "";
//TODO extract this
string separator = "+";
if(isValid(modules))
{
LinkedList<ExpressionModule> ems = new LinkedList<ExpressionModule>(modules);
while(1 != ems.Count)
{
string toAppend = ems.First.Value.getInternalName() + separator;
name += toAppend;
ems.RemoveFirst();
}
name += ems.First.Value.getInternalName();
return name;
}
else
{
Logger.Log("Device::generateInternalName got invalid expression modules sequence", Logger.Level.WARN);
return "";
}
}
示例6: BreadthFirst
public static int pathCounter = int.MinValue + 1; // Incremented after every check
#endregion Fields
#region Methods
// Yay C# has generators!
/// <summary>
/// A generator that produces positions by doing a breadth first iteration of tiles starting at a given position.
/// </summary>
/// <param name="engine">An engine object to get tiles from</param>
/// <param name="position">The starting position.</param>
/// <param name="distance">The maximum distance from the starting position. Or negative for no limit.</param>
/// <param name="size">The maximum number of tiles traversed. Or negative for no limit.</param>
public static IEnumerable<Position> BreadthFirst(Engine engine, Position position, int distance = -1, int size = -1)
{
// Reset ONE tile's pathIndex on the map to the minimum value to prevent integer rollover
int index = pathCounter < 0 ? -pathCounter : pathCounter;
engine.map.tiles[index % engine.map.width, (index / engine.map.width)%engine.map.height].pathIndex = int.MinValue;
int localPathCounter = pathCounter++;
LinkedList<Tile> perimeter = new LinkedList<Tile>();
perimeter.AddLast(engine.map.GetTileNearestTo(position));
perimeter.Last.Value.pathDistance = 0;
while (size != 0 && perimeter.Count > 0)
{
Tile top = perimeter.First.Value;
top.pathIndex = localPathCounter;
perimeter.RemoveFirst();
if (distance >= 0 && top.pathDistance > distance)
{
yield break;
}
yield return top.position;
foreach (var neighbor in top.neighbors)
{
if (neighbor.pathIndex < localPathCounter)
{
perimeter.AddLast(neighbor);
neighbor.pathIndex = localPathCounter;
neighbor.pathDistance = top.pathDistance + 1;
}
}
size -= 1;
}
// This is not the place for cleanup code
}
示例7: Bfs
/// <summary>
///
/// </summary>
/// <param name="s"></param>
/// <param name="t"></param>
/// <param name="parent"></param>
/// <returns></returns>
public bool Bfs(int s, int t, int[] parent)
{
PopulateListNodeVisited();
LinkedList<int> queue = new LinkedList<int>();
queue.AddLast(s);
Visited[s] = true;
parent[s] = -1;
// Standard BFS Loop
while (queue.Count() != 0)
{
int u = queue.First();
queue.RemoveFirst();
for (int v = 0; v < NumberOfNodes; v++)
{
if ((Visited[v] == false) && (PathTwoDimensionArray[u, v] > 0))
{
queue.AddLast(v);
parent[v] = u;
Visited[v] = true;
}
}
}
return (Visited[t] == true);
}
示例8: foreach
static int NumAños(Relación[] lista, int N, int víctima) {
LinkedList<Relación> cola = new LinkedList<Relación>();
int[] veces = Enumerable.Range(0, N).Select(x => 0).ToArray();
Relación aux;
foreach(Relación x in Conjunto(lista, víctima)) {
cola.AddLast(x);
}
veces[víctima - 1] = 1;
//Console.WriteLine("V: " + veces.Select(x => x.ToString())
// .Aggregate((x, xs) => x + " " + xs));
while(cola.Count() > 0) {
aux = cola.First();
cola.RemoveFirst();
veces[aux.necesita - 1] = veces[aux.asignatura - 1] + 1;
//Console.WriteLine("Asig: " + aux.asignatura + " Nece: " + aux.necesita);
//Console.WriteLine("V: " + veces.Select(x => x.ToString())
// .Aggregate((x, xs) => x + " " + xs));
foreach(Relación x in Conjunto(lista, aux.necesita)) {
cola.AddLast(x);
}
}
return veces.Max();
}
示例9: GenerateMaze
public override void GenerateMaze(int size, ref double animationDelay, ref int behaviorValue)
{
MazeData.CreateEmpty(size);
var tree = new KruskalTree(size);
var mazeWidth = size;
var mazeHeight = size;
AppData.AppState = AppData.AppStates.LongTask;
var walls = new LinkedList<MazePoint>();
for (var i = 1; i < mazeWidth - 1; i++)
{
var extra = i % 2 == 0 ? 1 : 0;
for (var j = 2 - extra; j < mazeHeight - 2 + extra; j += 2)
if (MazeData.MazeMatrix[i, j].State == CellState.Wall)
walls.AddLast(new MazePoint(i, j));
}
walls.Shuffle();
while (walls.First != null && AppData.AppState == AppData.AppStates.LongTask)
{
/*if (AnimateCheckBox.Checked)
BeginInvoke(fetchKruskalInfoDelegate);*/
var wall = walls.First.Value;
var x = 0;
var y = 0;
if (wall.X % 2 == 0 && wall.Y % 2 == 1)
x = 1;
else if (wall.X % 2 == 1 && wall.Y % 2 == 0)
y = 1;
var connected = tree.AreConnected(wall.X - x, wall.Y - y, wall.X + x, wall.Y + y);
if (!connected)
{
MazeData.MazeMatrix[wall.X - x, wall.Y - y].State = CellState.Walkway;
MazeData.MazeMatrix[wall.X, wall.Y].State = CellState.Walkway;
MazeData.MazeMatrix[wall.X + x, wall.Y + y].State = CellState.Walkway;
tree.Connect(wall.X - x, wall.Y - y, wall.X + x, wall.Y + y);
if (animationDelay > 0)
Utils.Sleep(animationDelay);
}
walls.RemoveFirst();
}
MakeEntranceExit();
AppData.AppState = AppData.AppStates.Idle;
/*MakeEntranceExit(AnimateCheckBox.Checked);
if (!AnimateCheckBox.Checked)
DrawMatrix(true);
Invoke(() => EnableButtons());
_debugStopwatch.Toc(true);
_debugStopwatch.Reset(true);*/
}
示例10: resolve
/// <summary>
/// 求解
/// </summary>
/// <returns></returns>
public Path resolve()
{
Path path = new Path();
Node start = new Node(p.Start);
LinkedList<Node> Open = new LinkedList<Node>();
HashSet <Node>Open2=new HashSet<Node> (); // 元素与Open一样。效率不同。
HashSet<Node> Close = new HashSet<Node>();
Open.AddFirst(start); // 起始点。
Open2.Add(start);
bool flag = false;
Node curr=null;
while(Open .Count >0)
{
curr = Open.First(); // 取出第一个。
Open.RemoveFirst();
Open2.Remove (curr);
Close.Add(curr); // 放入闭集合,后面会做重复性检查。
if (curr.cell.End)
{
flag = true;
break;
}
curr.Expand(Open, Open2, Close); //展开此节点:其所有的不在Open和Close的子节点,加入到队列尾部。
}
if (flag)
{
while(curr.Parent !=null)//记录下所有的结果。
{
path.cells.Add(curr.cell);
curr = curr.Parent;
}
path.cells.Add(curr.cell);//这是第一个点。
}
return path;
}
示例11: Ask
private void Ask(LinkedList<Expression> goals, KnowledgeBase context, Substitution theta, ProverCache cache, VariableRenamer renamer,
bool askOne, HashSet<Substitution> results, HashSet<Fact> alreadyAsking)
{
if (goals.Count == 0)
results.Add(theta);
else
{
Expression literal = goals.First.Value;
goals.RemoveFirst();
Expression qPrime = Substituter.Substitute(literal, theta);
var fact = qPrime as Fact;
if (fact != null && fact.RelationName == GameContainer.Parser.TokDistinct)
AskDistinct(fact, goals, context, theta, cache, renamer, askOne, results, alreadyAsking);
else
{
var negation = qPrime as Negation;
if (negation != null)
AskNot(negation, goals, context, theta, cache, renamer, askOne, results, alreadyAsking);
else
{
var disjunction = qPrime as Disjunction;
if (disjunction != null)
AskOr(disjunction, goals, context, theta, cache, renamer, askOne, results, alreadyAsking);
else
{
var sentence = (Fact) qPrime;
AskSentence(sentence, goals, context, theta, cache, renamer, askOne, results, alreadyAsking);
}
}
}
goals.AddFirst(literal);
}
}
示例12: GetSubstrings
public static IEnumerable<string> GetSubstrings(this string @this, int Size)
{
LinkedList<StringBuilder> builders = new LinkedList<StringBuilder>();
bool Full = false;
int c = 0;
foreach (char a in @this)
{
c++;
if (!Full)
{
if (c == Size)
Full = true;
}
else
{
builders.RemoveFirst();
}
builders.AddLast(new StringBuilder());
builders.Apply(b => b.Append(a));
foreach (StringBuilder sb in builders)
{
yield return sb.ToString();
}
}
}
示例13: Main
static void Main()
{
var list = new LinkedList<int>();
list.AddLast(1);
Console.WriteLine(list);
list.AddLast(2);
Console.WriteLine(list);
list.AddLast(3);
Console.WriteLine(list);
list.AddFirst(-1);
Console.WriteLine(list);
list.AddFirst(-2);
Console.WriteLine(list);
list.AddFirst(-3);
Console.WriteLine(list);
Console.WriteLine("Remove First: {0}", list.RemoveFirst().Value);
Console.WriteLine("Remove Last: {0}", list.RemoveLast().Value);
Console.WriteLine(list);
Console.WriteLine("Min: {0}; Max: {1}", list.Min(), list.Max());
Console.WriteLine("Contains 2: {0}", list.Contains(2));
Console.WriteLine("Count: {0}", list.Count);
}
示例14: PileShuffle
/// <summary>
/// Breaks deck into as many as 7 piles and places the cards one by one into piles
/// </summary>
/// <param name="deck"></param>
/// <returns></returns>
public CardCollectionOperationResult PileShuffle(Deck deck)
{
int pileCount = Math.Min(DEFAULT_PILE_COUNT, deck.Count);
int cardCount = deck.Count;
LinkedList<Deck> piles = new LinkedList<Deck>(new Deck[pileCount]);
for (int i = 0; i < cardCount; ++i)
{
Card card = deck.ElementAt(0);
Deck currentPile = piles.ElementAt(0);
deck.RemoveAt(0);
currentPile.Insert(0, card);
piles.AddLast(currentPile);
piles.RemoveFirst();
}
if (deck.Count == 0)
deck = new Deck();
foreach (Deck pile in piles)
deck.AddRange(pile);
return new CardCollectionOperationResult(deck);
}
示例15: Main
static void Main(string[] args)
{
WordPrediction.Initialize();
LinkedList<string> words = new LinkedList<string>();
//if you like
words.AddLast("for");
words.AddLast("he");
words.AddLast("was");
foreach(var word in words)
{
Console.Write(word + " ");
}
while (true)
{
//var line = Console.ReadLine();
var predictions = WordPrediction.Predict(words.Aggregate((a, b) => a + " " + b));
predictions.OrderByDescending(a => a.Item2);
words.RemoveFirst();
var prediction = predictions.FirstOrDefault();
if (prediction == null) break;
var word = predictions.FirstOrDefault().Item1;
words.AddLast(word);
Console.Write(" " + word);
Thread.Sleep(250);
}
}