示例#1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="Enumerator"/> struct.
            /// </summary>
            /// <param name="collection">Input collection.</param>
            public Enumerator(CustomQueue <T> collection)
            {
                if (collection == null)
                {
                    throw new ArgumentNullException(nameof(collection), "cannot be null");
                }

                this.version      = collection.Version;
                this.currentIndex = -1;
                this.queue        = collection;
            }
示例#2
0
        static void ShowDemoQueue()
        {
            CustomQueue <int> queue = new CustomQueue <int>(0);

            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);
            Console.WriteLine("Queue element count: {0}", queue.Count);
            Console.WriteLine("It looks like: {0}", queue.ToString());
            Console.WriteLine("Lets dequeue the element: {0}", queue.Dequeue());
            Console.WriteLine("And the previous one: {0}", queue.Dequeue());
            Console.WriteLine("It looks like: {0}", queue.ToString());
        }