public void IterationCleanup() { c5_arraylist.Clear(); while (c5_circularqueue.Count > 0) { _ = c5_circularqueue.Dequeue(); // There's no Clear() so we have to do this } c5_hashbag.Clear(); c5_hashedarraylist.Clear(); c5_hashedlinkedlist.Clear(); c5_hashset.Clear(); while (c5_intervalheap.Count > 0) { _ = c5_intervalheap.DeleteMax(); // There's no Clear() so we have to do this } c5_linkedlist.Clear(); c5_sortedarray.Clear(); c5_treebag.Clear(); c5_treeset.Clear(); collectathon_boundedarray.Clear(); collectathon_dynamicarray.Clear(); collectathon_singlylinkedlist.Clear(); msft_hashset.Clear(); msft_linkedlist.Clear(); msft_list.Clear(); msft_queue.Clear(); msft_segmentedlist.Clear(); msft_sortedset.Clear(); msft_stack.Clear(); }
/// <summary> /// Adds a new value to this average /// </summary> /// <param name="value"></param> public void AddValue(long value) { lock (this) { _values.Push(value); if (_values.Count > _sampleSize) { _values.Dequeue(); } } }
public void SW200602() { C5.CircularQueue <int> list = new C5.CircularQueue <int>(8); for (int count = 0; count <= 7; count++) { list.Enqueue(count); } int end = list.Count; for (int index = 0; index < end; index++) { Assert.AreEqual(index, list[0]); list.Dequeue(); } }
public void SW200602() { C5.CircularQueue<int> list = new C5.CircularQueue<int>(8); for(int count = 0; count <= 7; count++) { list.Enqueue(count); } int end = list.Count; for(int index = 0; index < end; index++) { Assert.AreEqual(index, list[0]); list.Dequeue(); } }
private bool TopologicalSearch(HKMSTDNode v, HKMSTDNode w) { var F = new C5.CircularQueue<int>(); var B = new C5.CircularQueue<int>(); F.Push(w.Index); B.Push(v.Index); var i = w.Position; var j = v.Position; v.Visited = true; w.Visited = true; while (true) { i++; while (i < j && !F.Any(u => adjMatrix[u, vertex[position[i]].Index])) i++; if (i == j) break; F.Push(vertex[position[i]].Index); vertex[position[i]].Visited = true; j--; while(i < j && !B.Any(z => adjMatrix[vertex[position[j]].Index, z])) j--; if (i == j) break; B.Push(vertex[position[j]].Index); vertex[position[j]].Visited = true; } //Once the search finishes, test for a cycle by checking whether there is an arc(u, z) //with u in F and z in B bool noCycle = !(from u in F from z in B where adjMatrix[u, z] select u).Any(); // Any stops when first occurance is found if (!noCycle) { foreach (var x in F) { vertex[x].Visited = false; } foreach (var x in B) { vertex[x].Visited = false; } return false; } else //cycle { var fix = new List<HKMSTDNode>();// putting things back the way they were // Reorder while (!F.IsEmpty) { if (vertex[position[i]].Visited == false && F.Any(u => adjMatrix[u, vertex[position[i]].Index])) { F.Push(vertex[position[i]].Index); vertex[position[i]].Visited = true; } if (vertex[position[i]].Visited) { var x = F.Dequeue(); position[i] = vertex[x].Index; vertex[x].Position = i; fix.Add(vertex[x]); } i++; } while (!B.IsEmpty) { j--; if (vertex[position[j]].Visited == false && B.Any(z => adjMatrix[vertex[position[j]].Index, z])) { B.Push(vertex[position[j]].Index); vertex[position[j]].Visited = true; } if (vertex[position[j]].Visited) { var y = B.Dequeue(); position[j] = vertex[y].Index; vertex[y].Position = j; fix.Add(vertex[y]); } } foreach (var vert in fix) { vert.Visited = false; } } return noCycle; }
private bool TopologicalSearch(HKMSTDNode v, HKMSTDNode w) { var F = new C5.CircularQueue <int>(); var B = new C5.CircularQueue <int>(); F.Push(w.Index); B.Push(v.Index); var i = w.Position; var j = v.Position; v.Visited = true; w.Visited = true; while (true) { i++; while (i < j && !F.Any(u => adjMatrix[u, vertex[position[i]].Index])) { i++; } if (i == j) { break; } F.Push(vertex[position[i]].Index); vertex[position[i]].Visited = true; j--; while (i < j && !B.Any(z => adjMatrix[vertex[position[j]].Index, z])) { j--; } if (i == j) { break; } B.Push(vertex[position[j]].Index); vertex[position[j]].Visited = true; } //Once the search finishes, test for a cycle by checking whether there is an arc(u, z) //with u in F and z in B bool noCycle = !(from u in F from z in B where adjMatrix[u, z] select u).Any(); // Any stops when first occurance is found if (!noCycle) { foreach (var x in F) { vertex[x].Visited = false; } foreach (var x in B) { vertex[x].Visited = false; } return(false); } else //cycle { var fix = new List <HKMSTDNode>();// putting things back the way they were // Reorder while (!F.IsEmpty) { if (vertex[position[i]].Visited == false && F.Any(u => adjMatrix[u, vertex[position[i]].Index])) { F.Push(vertex[position[i]].Index); vertex[position[i]].Visited = true; } if (vertex[position[i]].Visited) { var x = F.Dequeue(); position[i] = vertex[x].Index; vertex[x].Position = i; fix.Add(vertex[x]); } i++; } while (!B.IsEmpty) { j--; if (vertex[position[j]].Visited == false && B.Any(z => adjMatrix[vertex[position[j]].Index, z])) { B.Push(vertex[position[j]].Index); vertex[position[j]].Visited = true; } if (vertex[position[j]].Visited) { var y = B.Dequeue(); position[j] = vertex[y].Index; vertex[y].Position = j; fix.Add(vertex[y]); } } foreach (var vert in fix) { vert.Visited = false; } } return(noCycle); }