예제 #1
0
        public void Peek_Test()
        {
            IQueue <char> queue = new QueueViaLinkedList <char>(5);

            queue.Enqueue('A');
            queue.Enqueue('B');
            queue.Enqueue('C');
            queue.Enqueue('D');
            queue.Enqueue('E');
            queue.IsEmpty.Should().BeFalse();
            queue.IsFull.Should().BeTrue();
            queue.Count.Should().Be(5);
            queue.Peek().Should().Be('A');
            queue.Peek().Should().Be('A');
            queue.Peek().Should().Be('A');

            Action act = () => new QueueViaLinkedList <char>(5).Peek();

            act.Should().Throw <IndexOutOfRangeException>()
            .WithMessage("Queue is empty.");
        }
예제 #2
0
        static void Main(string[] args)
        {
            QueueViaLinkedList <int> queue = new QueueViaLinkedList <int>();

            int i = 9;

            queue.Enqueue(i);
            queue.Enqueue(i * 3);
            queue.Enqueue(i * 6);

            Console.WriteLine(queue.Peek());

            Console.WriteLine(queue.Dequeue());
        }