public void RandomWithDeleteHandles() { Random ran = new Random(6754); int length = 1000; int[] a = new int[length]; ArrayList<int> shuffle = new ArrayList<int>(length); IPriorityQueueHandle<int>[] h = new IPriorityQueueHandle<int>[length]; for (int i = 0; i < length; i++) { shuffle.Add(i); queue.Add(ref h[i], a[i] = ran.Next()); Assert.IsTrue(queue.Check()); } Assert.IsTrue(queue.Check()); shuffle.Shuffle(ran); for (int i = 0; i < length; i++) { int j = shuffle[i]; Assert.AreEqual(a[j], queue.Delete(h[j])); Assert.IsTrue(queue.Check()); } Assert.IsTrue(queue.IsEmpty); }
public void RandomIndexing() { Random ran = new Random(6754); int length = 1000; int[] a = new int[length]; int[] b = new int[length]; ArrayList<int> shuffle = new ArrayList<int>(length); IPriorityQueueHandle<int>[] h = new IPriorityQueueHandle<int>[length]; for (int i = 0; i < length; i++) { shuffle.Add(i); queue.Add(ref h[i], a[i] = ran.Next()); b[i] = ran.Next(); Assert.IsTrue(queue.Check()); } Assert.IsTrue(queue.Check()); shuffle.Shuffle(ran); for (int i = 0; i < length; i++) { int j = shuffle[i]; Assert.AreEqual(a[j], queue[h[j]]); queue[h[j]] = b[j]; Assert.AreEqual(b[j], queue[h[j]]); Assert.IsTrue(queue.Check()); } }
/// <summary> /// Create a new instance of this class. /// </summary> public PriorityQueueNode() : base() { Handle = null; }
public void Handles() { IPriorityQueueHandle<int>[] handles = new IPriorityQueueHandle<int>[10]; queue.Add(ref handles[0], 7); Assert.IsTrue(queue.Check()); queue.Add(ref handles[1], 72); Assert.IsTrue(queue.Check()); queue.Add(ref handles[2], 27); Assert.IsTrue(queue.Check()); queue.Add(ref handles[3], 17); Assert.IsTrue(queue.Check()); queue.Add(ref handles[4], 70); Assert.IsTrue(queue.Check()); queue.Add(ref handles[5], 1); Assert.IsTrue(queue.Check()); queue.Add(ref handles[6], 2); Assert.IsTrue(queue.Check()); queue.Add(ref handles[7], 7); Assert.IsTrue(queue.Check()); queue.Add(ref handles[8], 8); Assert.IsTrue(queue.Check()); queue.Add(ref handles[9], 9); Assert.IsTrue(queue.Check()); queue.Delete(handles[2]); Assert.IsTrue(queue.Check()); queue.Delete(handles[0]); Assert.IsTrue(queue.Check()); queue.Delete(handles[8]); Assert.IsTrue(queue.Check()); queue.Delete(handles[4]); Assert.IsTrue(queue.Check()); queue.Delete(handles[6]); Assert.IsTrue(queue.Check()); Assert.AreEqual(5, queue.Count); }
public void Dispose() { m_asset = null; PriorityQueueHandle = null; }