Пример #1
0
        //入队
        public void In(T item)
        {
            LinkQueueNode <T> p = new LinkQueueNode <T>(item);

            if (IsEmpty())
            {
                rear = p;
                num++;
                return;
            }

            rear.Next = p;
            rear      = p;
            num++;
        }
Пример #2
0
        //出队
        public void Out()
        {
            if (IsEmpty())
            {
                Console.WriteLine("The queue is empty , you can not remove element!");
                return;
            }

            LinkQueueNode <T> p = new LinkQueueNode <T>();

            p     = front.Next;
            front = p;
            num--;
            if (front == null)
            {
                rear = null;
            }
        }
 public LinkQueueNode()
 {
     this.data = default(T);
     this.next = null;
 }
 public LinkQueueNode(LinkQueueNode <T> p)
 {
     this.data = default(T);
     this.next = p;
 }
 public LinkQueueNode(T item)
 {
     this.data = item;
     this.next = null;
 }
 public LinkQueueNode(T item, LinkQueueNode <T> p)
 {
     this.data = item;
     this.next = p;
 }
Пример #7
0
 //清空链队列
 public void Clear()
 {
     front = rear = null;
     num   = 0;
 }
Пример #8
0
 public LinkQueue1()
 {
     front = rear = null;
     num   = 0;
 }