Esempio n. 1
0
        public string Dequeue()
        {
            if (length > 0)
            {
                if (length > 1)
                {
                    string frontName = front.next.name;
                    Node cur = back.next;

                    while (cur.next != front.next)
                    {
                        cur = cur.next;
                    }

                    front = new Node();
                    cur.next = null;
                    front.next = cur;
                    cur = null;
                    length--;
                    return frontName;
                }
                else
                {
                    string frontName = front.next.name;
                    front.next = null;
                    back.next = null;
                    length--;
                    return frontName;
                }
            }
            else
            {
                return "";
            }
        }
Esempio n. 2
0
 public bool Enqueue(string n)
 {
     Node newNode = new Node();
     newNode.name = n;
     if (length > 0)
     {
         newNode.next = back.next;
         back.next = newNode;
     }
     else
     {
         back.next = newNode;
         front.next = newNode;
     }
     length++;
     return true;
 }
Esempio n. 3
0
 public ArtQueue()
 {
     front = new Node();
     back = new Node();
     length = 0;
 }