当前位置: 首页>>代码示例>>C#>>正文


C# LinkedQueue.Dequeue方法代码示例

本文整理汇总了C#中LinkedQueue.Dequeue方法的典型用法代码示例。如果您正苦于以下问题:C# LinkedQueue.Dequeue方法的具体用法?C# LinkedQueue.Dequeue怎么用?C# LinkedQueue.Dequeue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinkedQueue的用法示例。


在下文中一共展示了LinkedQueue.Dequeue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

 static void Main()
 {
     var test = new LinkedQueue<int>();
     test.Enqueue(1);
     Console.WriteLine(string.Join(" ", test.ToArray()));
     test.Enqueue(2);
     Console.WriteLine(string.Join(" ", test.ToArray()));
     test.Enqueue(3);
     Console.WriteLine(string.Join(" ", test.ToArray()));
     test.Enqueue(4);
     Console.WriteLine(string.Join(" ", test.ToArray()));
     test.Enqueue(5);
     Console.WriteLine(string.Join(" ", test.ToArray()));
     test.Enqueue(6);
     Console.WriteLine(string.Join(" ", test.ToArray()));
     test.Enqueue(7);
     Console.WriteLine(string.Join(" ", test.ToArray()));
     Console.WriteLine("The queue count: {0}", test.Count);
     test.Dequeue();
     test.Dequeue();
     Console.WriteLine(string.Join(" ", test.ToArray()));
     Console.WriteLine("The queue count: {0}", test.Count);
     Console.WriteLine(test.Peek());
     Console.WriteLine(string.Join(" ", test.ToArray()));
     Console.WriteLine("The queue count: {0}", test.Count);
     test.Clear();
     Console.WriteLine(string.Join(" ", test.ToArray()));
     Console.WriteLine("The queue count: {0}", test.Count);
     //test.Dequeue();                           //if uncommented this line should throw exception
 }
开发者ID:kalinalazarova1,项目名称:TelerikAcademy,代码行数:30,代码来源:LinkedQueueTest.cs

示例2: Main

        static void Main()
        {
            LinkedQueue<int> collection = new LinkedQueue<int>();
            collection.Enqueue(1);
            collection.Enqueue(2);
            collection.Enqueue(3);
            collection.Enqueue(4);
            collection.Enqueue(5);
            collection.Enqueue(6);
            collection.Enqueue(7);
            collection.Enqueue(8);
            collection.Enqueue(9);

            Console.WriteLine("Total elements: " + collection.Count);
            Console.WriteLine(collection.Dequeue());
            Console.WriteLine(collection.Dequeue());
            Console.WriteLine(collection.Dequeue());
            Console.WriteLine(collection.Dequeue());
            Console.WriteLine("Total elements: " + collection.Count);

            collection.Enqueue(10);
            collection.Enqueue(11);

            Console.WriteLine(collection.Dequeue());
            Console.WriteLine("Total elements: " + collection.Count);

            var array = collection.ToArray();
            Console.WriteLine(string.Join(", ", array));
        }
开发者ID:AsenTahchiyski,项目名称:SoftUni,代码行数:29,代码来源:Program.cs

示例3: Main

 static void Main()
 {
     var lq = new LinkedQueue<int>();
     lq.Enqueue(5);
     lq.Enqueue(11);
     lq.Enqueue(22);
     lq.Enqueue(33);
     lq.Enqueue(44);
     lq.Dequeue();
     var p = lq.Peek();
     lq.Enqueue(55);
     lq.Enqueue(11);
     lq.Enqueue(22);
     lq.Enqueue(33);
     lq.Enqueue(44);
     lq.Dequeue();
     lq.Enqueue(55);
     lq.Enqueue(11);
     lq.Enqueue(22);
     lq.Enqueue(33);
     lq.Enqueue(44);
     lq.Dequeue();
     lq.Enqueue(55);
     lq.Enqueue(11);
     lq.Enqueue(22);
     lq.Enqueue(33);
     lq.Enqueue(44);
     lq.Dequeue();
 }
开发者ID:smihaylovit,项目名称:TelerikAkademy,代码行数:29,代码来源:Program.cs

示例4: Main

        /*
         * Implement the ADT queue as dynamic linked list. 
         * Use generics (LinkedQueue<T>) to allow storing different data types in the queue.
        */

        static void Main(string[] args)
        {
            ILinkedQueue<int> sample = new LinkedQueue<int>();

            sample.Enqueue(1);
            sample.Enqueue(2);
            sample.Enqueue(3);

            int[] sampleAsArray = sample.ToArray();

            Console.WriteLine("Queue as array:");
            for (int index = 0; index < sampleAsArray.Length; index++)
            {
                Console.WriteLine(sampleAsArray[index]);
            }

            Console.WriteLine("Dequeue + Peek");
            Console.WriteLine(sample.Dequeue() + " Dequeue");
            Console.WriteLine(sample.Dequeue() + " Dequeue");
            Console.WriteLine(sample.Peek() + " Peek");
            Console.WriteLine(sample.Dequeue() + " Dequeue");

            sample.Enqueue(4);
            Console.WriteLine("Does Contains 4? " + sample.Contains(4));

            sample.Enqueue(5);
            sample.Enqueue(6);

            sample.Clear();
            Console.WriteLine("Count after clear: " + sample.Count);
            // Console.WriteLine(sample.Dequeue()); // exception expected


        }
开发者ID:vaster,项目名称:Telerik.vasko,代码行数:39,代码来源:Program.cs

示例5: Main

        static void Main()
        {
            try
            {
                LinkedQueue<string> queue = new LinkedQueue<string>();
                queue.Enqueue("Message One");
                queue.Enqueue("Message Two");
                queue.Enqueue("Message Three");
                queue.Enqueue("Message Four");

                Console.WriteLine(queue.Peek());
                Console.WriteLine(queue.Contains("Message Three"));

                var array = queue.ToArray();
                Console.WriteLine(string.Join(", ", array));

                while (queue.Count > 0)
                {
                    string message = queue.Dequeue();
                    Console.WriteLine(message);
                }

                queue.Dequeue();
            }
            catch (IndexOutOfRangeException iex)
            {
                Console.WriteLine(iex.TargetSite + " -> " + iex.Message);
            }
            catch (NullReferenceException nex)
            {
                Console.WriteLine(nex.TargetSite + " -> " + nex.Message);
            }
        }
开发者ID:niki-funky,项目名称:Telerik_Academy,代码行数:33,代码来源:Demo.cs

示例6: Main

 static void Main()
 {
     LinkedQueue<int> myQueue = new LinkedQueue<int>();
     myQueue.Enqueue(5);
     myQueue.Enqueue(6);
     Console.WriteLine(myQueue.Dequeue());
     Console.WriteLine(myQueue.Dequeue());
 }
开发者ID:zvet80,项目名称:TelerikAcademyHomework,代码行数:8,代码来源:Program.cs

示例7: TestCountAfterDequeue

 public void TestCountAfterDequeue()
 {
     var queue = new LinkedQueue<int>();
     queue.Enqueue(1);
     queue.Enqueue(2);
     queue.Enqueue(3);
     queue.Dequeue();
     queue.Dequeue();
     Assert.AreEqual(1, queue.Count);
 }
开发者ID:bobosam,项目名称:DataStructures,代码行数:10,代码来源:LinkedQueueTests.cs

示例8: Dequeue_Enqueue

 public void Dequeue_Enqueue()
 {
     LinkedQueue<int> testDequeue = new LinkedQueue<int>();
     Assert.AreEqual(0, testDequeue.Count);
     testDequeue.Enqueue(3);
     Assert.AreEqual(1, testDequeue.Count);
     testDequeue.Enqueue(3);
     Assert.AreEqual(2, testDequeue.Count);
     Assert.AreEqual(3, testDequeue.Dequeue());
     Assert.AreEqual(1, testDequeue.Count);
     Assert.AreEqual(3, testDequeue.Dequeue());
     Assert.AreEqual(0, testDequeue.Count);
 }
开发者ID:kosio197,项目名称:SoftUni_DataStructures,代码行数:13,代码来源:TestLinkedQueue.cs

示例9: TestCount_SeveralElementsWithDequeue_CountTwo

        public void TestCount_SeveralElementsWithDequeue_CountTwo()
        {
            var queue = new LinkedQueue<int>();
            queue.Enqueue(50);
            queue.Enqueue(60);
            queue.Enqueue(70);
            queue.Enqueue(int.MaxValue);

            queue.Dequeue();
            queue.Dequeue();

            Assert.AreEqual(2, queue.Count, "Queue count should be 2.");
        }
开发者ID:eslavov11,项目名称:SoftUni-Homework,代码行数:13,代码来源:LinkedQueueTests.cs

示例10: Enqueue_Dequeue_Elements

 public void Enqueue_Dequeue_Elements()
 {
     var nums = new LinkedQueue<int>();
     Assert.AreEqual(0, nums.Count);
     nums.Enqueue(15);
     Assert.AreEqual(1, nums.Count);
     nums.Enqueue(12);
     Assert.AreEqual(2, nums.Count);
     Assert.AreEqual(15, nums.Dequeue());
     Assert.AreEqual(1, nums.Count);
     Assert.AreEqual(12, nums.Dequeue());
     Assert.AreEqual(0, nums.Count);
 }
开发者ID:asenAce,项目名称:Software_University_Bulgaria,代码行数:13,代码来源:LinkedQueueTest.cs

示例11: Main

    static void Main()
    {
        LinkedQueue<int> linkedQueue = new LinkedQueue<int>();

        linkedQueue.Enqueue(2);
        linkedQueue.Enqueue(3);
        linkedQueue.Enqueue(5);
        linkedQueue.Enqueue(61);
        linkedQueue.Enqueue(57);

        linkedQueue.Dequeue();
        linkedQueue.Dequeue();
        linkedQueue.Dequeue();
    }
开发者ID:zerefel,项目名称:Data-Structures-And-Algorithms,代码行数:14,代码来源:LinkedQueueMain.cs

示例12: Main

    public static void Main()
    {
        LinkedQueue<int> list = new LinkedQueue<int>();

        list.Enqueue(5);
        list.Enqueue(6);
        list.Enqueue(7);
        list.Enqueue(8);

        Console.WriteLine(list.Dequeue());
        Console.WriteLine(list.Dequeue());

        Console.WriteLine("List count: {0}", list.Count);
    }
开发者ID:vassil,项目名称:CSharp,代码行数:14,代码来源:LinkedQueueDemo.cs

示例13: TestDequeue_MultipleElements_ShouldReturnProperElements

        public void TestDequeue_MultipleElements_ShouldReturnProperElements()
        {
            var queue = new LinkedQueue<int>();
            queue.Enqueue(50);
            queue.Enqueue(60);
            queue.Enqueue(70);
            var elementOne = queue.Dequeue();
            var elementTwo = queue.Dequeue();
            var elementThree = queue.Dequeue();

            Assert.AreEqual(50, elementOne, "First element value should be 50.");
            Assert.AreEqual(60, elementTwo, "Second element value should be 60.");
            Assert.AreEqual(70, elementThree, "Third element value should be 70.");
        }
开发者ID:eslavov11,项目名称:SoftUni-Homework,代码行数:14,代码来源:LinkedQueueTests.cs

示例14: TestEnqueueDequeue_ShouldReturnCorrectResultsAndUpdateCounterProperly

 public void TestEnqueueDequeue_ShouldReturnCorrectResultsAndUpdateCounterProperly()
 {
     var stack = new LinkedQueue<string>();
     Assert.IsTrue(stack.Count == 0);
     stack.Enqueue("wow");
     Assert.IsTrue(stack.Count == 1);
     stack.Enqueue("yeah");
     Assert.IsTrue(stack.Count == 2);
     var element = stack.Dequeue();
     Assert.AreEqual("wow", element);
     Assert.IsTrue(stack.Count == 1);
     element = stack.Dequeue();
     Assert.AreEqual("yeah", element);
     Assert.IsTrue(stack.Count == 0);
 }
开发者ID:AsenTahchiyski,项目名称:SoftUni,代码行数:15,代码来源:UnitTest1.cs

示例15: Main

        public static void Main()
        {
            LinkedQueue<int> myTestLinkedQueue = new LinkedQueue<int>();
            myTestLinkedQueue.Enqueue(11);
            myTestLinkedQueue.Enqueue(22);
            myTestLinkedQueue.Enqueue(33);
            myTestLinkedQueue.Enqueue(44);
            myTestLinkedQueue.Enqueue(55);

            Console.WriteLine("Dequeue test: {0}", myTestLinkedQueue.Dequeue());
            Console.WriteLine("Dequeue test: {0}", myTestLinkedQueue.Dequeue());
            Console.WriteLine("Dequeue test: {0}", myTestLinkedQueue.Dequeue());
            Console.WriteLine("Dequeue test: {0}", myTestLinkedQueue.Dequeue());
            Console.WriteLine("Dequeue test: {0}", myTestLinkedQueue.Dequeue());
        }
开发者ID:quela,项目名称:myprojects,代码行数:15,代码来源:LinkedQueueTests.cs


注:本文中的LinkedQueue.Dequeue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。