Пример #1
0
 public void SetUp()
 {
     priorityQueueDictionary = new PriorityQueueDictionary <int, string>();
     priorityQueueDictionary.Enqueue(12, "item one");
     priorityQueueDictionary.Enqueue(5, "item two");
     priorityQueueDictionary.Enqueue(7, "item three");
     priorityQueueDictionary.Enqueue(6, "item four");
 }
Пример #2
0
 public void ConstructFromEnumerable()
 {
     string[] array = new string[] { "item one", "item two", "item three", "item four" };
     priorityQueueDictionary = new PriorityQueueDictionary <int, string>(array);
     Assert.IsTrue(priorityQueueDictionary.Contains("item one"));
     Assert.IsTrue(priorityQueueDictionary.Contains("item two"));
     Assert.IsTrue(priorityQueueDictionary.Contains("item three"));
     Assert.IsTrue(priorityQueueDictionary.Contains("item four"));
 }
Пример #3
0
        public void ConstructFromPairEnumerator()
        {
            List <Pair <int, string> > list = new List <Pair <int, string> >();

            list.Add(new Pair <int, string>(12, "item one"));
            list.Add(new Pair <int, string>(5, "item two"));
            list.Add(new Pair <int, string>(7, "item three"));
            list.Add(new Pair <int, string>(6, "item four"));
            priorityQueueDictionary = new PriorityQueueDictionary <int, string>(list);
            Assert.AreEqual("item one", priorityQueueDictionary.Dequeue());
            Assert.AreEqual("item three", priorityQueueDictionary.Dequeue());
            Assert.AreEqual("item four", priorityQueueDictionary.Dequeue());
            Assert.AreEqual("item two", priorityQueueDictionary.Dequeue());
        }
Пример #4
0
        public void EnumerationTest()
        {
            priorityQueueDictionary = new PriorityQueueDictionary <int, string>();
            Bag <string> bag = new Bag <string>();

            for (int i = 0; i < 100; ++i)
            {
                string s = "item: " + i.ToString();
                bag.Add(s);
                int p = i * 2;
                priorityQueueDictionary.Enqueue(p, s);
            }
            foreach (string s in priorityQueueDictionary)
            {
                Assert.IsTrue(bag.Contains(s));
                bag.Remove(s);
            }
            Assert.AreEqual(0, bag.Count);
        }
Пример #5
0
        public void Enqueuing()
        {
            priorityQueueDictionary = new PriorityQueueDictionary <int, string>();
            priorityQueueDictionary.Enqueue(12, "item one");
            Assert.AreEqual(1, priorityQueueDictionary.Count);
            Assert.AreEqual("item one", priorityQueueDictionary.Front);

            priorityQueueDictionary.Enqueue(5, "item two");
            Assert.AreEqual("item one", priorityQueueDictionary.Front);
            Assert.AreEqual(2, priorityQueueDictionary.Count);

            priorityQueueDictionary.Enqueue(7, "item three");
            Assert.AreEqual("item one", priorityQueueDictionary.Front);
            Assert.AreEqual(3, priorityQueueDictionary.Count);

            priorityQueueDictionary.Enqueue(6, "item four");
            Assert.AreEqual("item one", priorityQueueDictionary.Front);
            Assert.AreEqual(4, priorityQueueDictionary.Count);
        }
Пример #6
0
 public void DefaultConstructor()
 {
     priorityQueueDictionary = new PriorityQueueDictionary <int, string>();
     Assert.AreEqual(0, priorityQueueDictionary.Count);
 }
Пример #7
0
 public PriorityQueueEnumerator(PriorityQueueDictionary <P, T> priorityQueueDictionary)
 {
     this.priorityQueueDictionary = priorityQueueDictionary;
     Reset();
 }