コード例 #1
0
        internal void Schedule(PriorityQueueNode <SchedulerEntry> schedulerEntry, ScheduleMode scheduleMode)
        {
            var nextCounter = SchedulerCounter++;

            if (scheduleMode == ScheduleMode.First)
            {
                nextCounter = -nextCounter;
            }

            schedulerEntry.Value.SchedulerCounter = nextCounter;

            scheduledEntries.Enqueue(schedulerEntry);
        }
コード例 #2
0
        public PriorityQueueNode <AssetBuildUnit> PushBuildUnit(AssetBuildUnit unit)
        {
            PriorityQueueNode <AssetBuildUnit> result;

            lock (queueLock)
            {
                result = queue.Enqueue(unit);
            }

            builder.NotifyBuildStepAvailable();

            return(result);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }