internal void Schedule(PriorityQueueNode <SchedulerEntry> schedulerEntry, ScheduleMode scheduleMode) { var nextCounter = SchedulerCounter++; if (scheduleMode == ScheduleMode.First) { nextCounter = -nextCounter; } schedulerEntry.Value.SchedulerCounter = nextCounter; scheduledEntries.Enqueue(schedulerEntry); }
public PriorityQueueNode <AssetBuildUnit> PushBuildUnit(AssetBuildUnit unit) { PriorityQueueNode <AssetBuildUnit> result; lock (queueLock) { result = queue.Enqueue(unit); } builder.NotifyBuildStepAvailable(); return(result); }
public void TestInsertionRandom() { var priorityQueue = new PriorityNodeQueue<int>(); var random = new Random(); for (int i = 0; i < 1000; ++i) { priorityQueue.Enqueue(random.Next()); } Assert.That(priorityQueue.Count, Is.EqualTo(1000)); CheckPriorityQueue(priorityQueue); }
public void TestInsertionDescending() { var priorityQueue = new PriorityNodeQueue<int>(); for (int i = 0; i < 1000; ++i) { priorityQueue.Enqueue(999 - i); } Assert.That(priorityQueue.Count, Is.EqualTo(1000)); Assert.That(priorityQueue.Peek(), Is.EqualTo(0)); CheckPriorityQueue(priorityQueue); }
public void TestInsertionRandom() { var priorityQueue = new PriorityNodeQueue <int>(); var random = new Random(); for (int i = 0; i < 1000; ++i) { priorityQueue.Enqueue(random.Next()); } Assert.Equal(1000, priorityQueue.Count); CheckPriorityQueue(priorityQueue); }
public void TestInsertionDescending() { var priorityQueue = new PriorityNodeQueue <int>(); for (int i = 0; i < 1000; ++i) { priorityQueue.Enqueue(999 - i); } Assert.Equal(1000, priorityQueue.Count); Assert.Equal(0, priorityQueue.Peek()); CheckPriorityQueue(priorityQueue); }
public void TestInsertionAscending() { var priorityQueue = new PriorityNodeQueue <int>(); for (int i = 0; i < 1000; ++i) { priorityQueue.Enqueue(i); } Assert.That(priorityQueue.Count, Is.EqualTo(1000)); Assert.That(priorityQueue.Peek(), Is.EqualTo(0)); CheckPriorityQueue(priorityQueue); }
public void TestRemoval() { var priorityQueue = new PriorityNodeQueue<int>(); List<PriorityQueueNode<int>> nodes = new List<PriorityQueueNode<int>>(); for (int i = 0; i < 1000; ++i) { nodes.Add(priorityQueue.Enqueue(i)); } priorityQueue.Remove(nodes[3]); priorityQueue.Remove(nodes[0]); priorityQueue.Remove(nodes[500]); priorityQueue.Remove(nodes[251]); priorityQueue.Remove(nodes[999]); Assert.That(priorityQueue.Count, Is.EqualTo(1000 - 5)); CheckPriorityQueue(priorityQueue); }
public void TestRemoval() { var priorityQueue = new PriorityNodeQueue <int>(); List <PriorityQueueNode <int> > nodes = new List <PriorityQueueNode <int> >(); for (int i = 0; i < 1000; ++i) { nodes.Add(priorityQueue.Enqueue(i)); } priorityQueue.Remove(nodes[3]); priorityQueue.Remove(nodes[0]); priorityQueue.Remove(nodes[500]); priorityQueue.Remove(nodes[251]); priorityQueue.Remove(nodes[999]); Assert.Equal(1000 - 5, priorityQueue.Count); CheckPriorityQueue(priorityQueue); }