예제 #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;
 }