Ejemplo 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 "";
            }
        }
Ejemplo 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;
 }
Ejemplo n.º 3
0
 public ArtQueue()
 {
     front = new Node();
     back = new Node();
     length = 0;
 }