Пример #1
0
        public void testPopBack()
        {
            DEQueue <string> b = new DEQueue <string>();

            Assert.AreEqual(null, b.popBack());
            b.pushBack("abc");
            b.pushBack("cba");
            Assert.AreEqual("cba", b.popBack());
            Assert.IsTrue(b.Count == 1);
        }
Пример #2
0
        public void TestMethod4()//test_popfront_popback
        {
            DEQueue <string> qwsda = new DEQueue <string>();

            qwsda.pushBack("a");
            qwsda.pushBack("b");
            qwsda.pushBack("c");
            qwsda.pushBack("d");
            string a = qwsda.popFront() + qwsda.popBack() + qwsda.popFront() + qwsda.popBack();

            Assert.AreEqual(a, "adbc");
        }
Пример #3
0
        public void PopBackAloneTest()
        {
            DEQueue <string> deq = new DEQueue <string>();

            deq.popBack();
            Assert.IsTrue(deq.Size == 0);
            Assert.IsNull(deq.Head);
            Assert.IsNull(deq.Tail);
        }
Пример #4
0
        public void PopBackTest()
        {
            DEQueue <string> deq = new DEQueue <string>();

            deq.pushBack("a");
            deq.pushBack("b");
            deq.pushBack("c");
            Assert.IsTrue(deq.Size == 3);
            Assert.AreEqual("a", deq.Head.Data);
            Assert.AreEqual("c", deq.Tail.Data);

            deq.popBack();
            Assert.IsTrue(deq.Size == 2);
            Assert.AreEqual("a", deq.Head.Data);
            Assert.AreEqual("b", deq.Tail.Data);

            deq.popBack();
            Assert.IsTrue(deq.Size == 1);
            Assert.AreEqual("a", deq.Head.Data);
            Assert.AreEqual("a", deq.Tail.Data);
        }
Пример #5
0
        public void popBackTest_KostyaAndMark_KostyaReturn()
        {
            // arrange
            DEQueue <string> queue    = new DEQueue <string>();
            string           expected = "Kostya";

            // act
            queue.pushBack("Kostya");
            queue.pushBack("Mark");
            queue.pushFront("Kate");
            queue.popBack();

            // assert
            Assert.AreEqual(expected, queue.back);
        }
Пример #6
0
        public void popBackTest_LuffyAndZoroAndSanji_ReturnedLuffy()
        {
            // arrange
            DEQueue <string> queue    = new DEQueue <string>();
            string           expected = "Luffy";

            // act
            queue.pushFront("Luffy");
            queue.pushBack("Zoro");
            queue.pushFront("Sanji");
            queue.popBack();

            // assert
            Assert.AreEqual(expected, queue.back);
        }
Пример #7
0
        public void DeqTest2()
        {
            DEQueue <int> Deq = new DEQueue <int>();

            Deq.pushFront(1);
            Deq.pushFront(2);
            Deq.pushFront(3);
            Deq.popBack();
            int[] expected = { 3, 2 };
            int   i        = 0;

            foreach (int s in Deq)
            {
                Assert.AreEqual(expected[i], s);
                i++;
            }
        }
Пример #8
0
        private static void Main(string[] args)
        {
            DEQueue <string> queue = new DEQueue <string>();


            Console.WriteLine("---Добавление элементов---");
            queue.pushFront("Mark");
            queue.pushFront("Alisa");
            queue.pushBack("Kate");
            queue.pushBack("Ed");
            queue.pushBack("Kostya");
            queue.pushFront("Ilyas");
            foreach (var item in queue)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("---Удаление с начала---");

            Console.WriteLine(queue.popFront());

            Console.WriteLine("---Вывод данных---");

            foreach (var item in queue)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("---Удаление с конца---");
            Console.WriteLine(queue.popBack());

            Console.WriteLine("---Вывод данных---");

            foreach (var item in queue)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine("---Очистка данных---");
            queue.Clear();

            queue.pushFront("Mark");
            queue.pushFront("Alisa");
            queue.pushBack("Kate");
            queue.pushBack("Ed");
            queue.pushBack("Kostya");
            queue.pushFront("Ilyas");

            foreach (var item in queue)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("---ЛИСТ---");

            foreach (var x in queue.convertToArray())
            {
                Console.WriteLine(x);
            }


            string[] ss = (string[])queue.convertToArray().Clone();

            Console.WriteLine("---ЛИСТ КОПИЯ---");

            foreach (var x in ss.ToArray())
            {
                Console.WriteLine(x);
            }


            Console.WriteLine("---Проверка Типов---");

            if (ss.ToArray().GetType() == queue.convertToArray().GetType())
            {
                Console.WriteLine("True");
            }


            Console.Read();
        }
Пример #9
0
        private static void Main(string[] args)
        {
            DEQueue <string> queue = new DEQueue <string>();

            // добавление элементов

            Console.WriteLine("-------Добавление элементов--------");

            queue.pushBack("Bob");
            queue.pushBack("Bill");
            queue.pushBack("Tom");
            queue.pushFront("Kate");
            foreach (var item in queue)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine();

            Console.WriteLine("-------Удаление из начала--------");

            Console.WriteLine(queue.popFront());

            Console.WriteLine();

            foreach (var item in queue)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine();

            Console.WriteLine("-------Удаление из конца--------");

            Console.WriteLine(queue.popBack());

            Console.WriteLine();

            Console.WriteLine("-------Количество элементов в очереди--------");

            Console.WriteLine(queue.size);

            Console.WriteLine();

            foreach (var item in queue)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("-------Очищение очереди--------");

            queue.Clear();

            Console.WriteLine();

            Console.WriteLine("----Добавление элементов-----");

            queue.pushBack("Bob");
            queue.pushBack("Bill");
            queue.pushBack("Tom");
            queue.pushFront("Kate");

            foreach (var item in queue)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("-------Преобразование в список--------");

            foreach (var x in queue.convertToArray())
            {
                Console.WriteLine(x);
            }

            string[] ss = (string[])queue.convertToArray().Clone();

            Console.WriteLine("-------Копия списка--------");

            foreach (var x in ss.ToArray())
            {
                Console.WriteLine(x);
            }

            Console.WriteLine();

            Console.WriteLine("-------True потому что преобразовали очередь в список--------");
            if (ss.ToArray().GetType() == queue.convertToArray().GetType())
            {
                Console.WriteLine("True");
            }

            Console.Read();
        }