示例#1
0
        public void EnqueueFront(int val)
        {
            DQNode dNode = new DQNode(val);

            dNode.next = front;

            if (count > 0)
            {
                front.prev = dNode;
            }

            front = dNode;

            count++;

            if (count == 1)
            {
                rear = front;
            }
        }
示例#2
0
        public void EnqueueRear(int val)
        {
            DQNode dNode = new DQNode(val);

            dNode.prev = rear;

            if (count > 0)
            {
                rear.next = dNode;
            }

            rear = dNode;

            count++;

            if (count == 1)
            {
                front = dNode;
            }
        }
示例#3
0
        public int DequeueFront()
        {
            //Queue is empty
            if (count <= 0)
            {
            }

            int val = front.value;

            front = front.next;
            count--;

            if (count > 0)
            {
                front.prev = null;
            }
            else
            {
                rear = null;
            }

            return(val);
        }
示例#4
0
        public int DequeueRear()
        {
            if (count <= 0)
            {
                return(-1);
            }

            int val = rear.value;

            rear = rear.prev;

            count--;

            if (count > 0)
            {
                rear.next = null;
            }
            else
            {
                rear = null;
            }

            return(val);
        }