Esempio n. 1
0
 private void PrintList(Node node)
 {
     if (node != null)
     {
         Console.Write("[" + node.Data + "]--->");
         PrintList(node.Next);
     }
 }
Esempio n. 2
0
 public void RemoveLast()
 {
     if (_tail != null)
     {
         _tail = _tail.Prev;
         _tail.Next = null;
     }
 }
Esempio n. 3
0
 /// 
 /// This function will print everything that is currently in the 
 /// Queue.
 /// 
 public void printQueue()
 {
     temp = front;
     while(temp != null){
         Console.WriteLine("{0}", temp.Value.ToString());
         temp = temp.Next;
     }
 }
Esempio n. 4
0
 /// 
 /// This function will append to the end of the Queue or 
 /// create The first Node instance.
 /// 
 ///  
 public void append(object obj)
 {
     if(count==0){
         front = end = new Node(obj, front);
     } else {
         end.Next = new Node(obj, end.Next);
         end = end.Next;
     }
     count++;
 }
Esempio n. 5
0
 public Node(string d, Node next = null) {
     this.data = new Label();
     this._next = next;
     this.data.Text = d;
     this.data.BackColor = System.Drawing.SystemColors.ActiveCaption;
     this.data.Font = new System.Drawing.Font("Microsoft Sans Serif", 10, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.data.Padding = new System.Windows.Forms.Padding(10);
     this.data.Size = new System.Drawing.Size(41, 85);
     this.data.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
 }
Esempio n. 6
0
 public object Dequeue()
 {
     if (count == 0)
     {
         throw new Exception("Queue is empty");
     }
     Node current = head;
     head = head.Next;
     count--;
     return current.Data;
 }
Esempio n. 7
0
 public Queue(Panel panel)
 {
     this._front = null;
     this._size = 0;
     this.khung = new FlowLayoutPanel();
     this.khung.AutoScroll = true;
     this.khung.BackColor = System.Drawing.SystemColors.AppWorkspace;
     this.khung.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
     this.khung.Dock = System.Windows.Forms.DockStyle.Fill;
     this.khung.Location = new System.Drawing.Point(0, 0);
     this.khung.Size = new System.Drawing.Size(573, 100);
     panel.Controls.Add(this.khung);
 }
Esempio n. 8
0
 public void Enqueue(object item)
 {
     if (head == null)
     {
         head = new Node(item);
         tail = head;
     }
     else
     {
         Node newNode = new Node(item, tail);
         tail = newNode;
     }
     count++;
 }
Esempio n. 9
0
 public Node dequeue()
 {
     if (this._front == null)
     {
         return null;
     }
     else
     {
         Node tam = this.front;
         this._front = this._front.next;
         this.khung.Controls.RemoveAt(0);
         this._size--;
         return tam;
     }
 }
Esempio n. 10
0
        public void AddFirst(int number)
        {
            Node newNode = new Node() { Data = number };

            if (_head == null)
            {
                _head = newNode;
                _tail = newNode;
            }
            else
            {
                _head.Prev = newNode;
                newNode.Next = _head;
                _head = newNode;
            }
        }
Esempio n. 11
0
        public void enqueue(Node n)
        {
            if (this._front == null)
            {

                this._front = n;

            }
            else {
                this._rear.next = n;
            }

            this._rear = n;
            this._size++;
            this.khung.Controls.Add(n.Data);
        }
Esempio n. 12
0
 public Node(object data)
 {
     this.data = data;
     this.next = null;
 }
Esempio n. 13
0
 public Node(object value, Node next)
 {
     Next = next;
     Value = value;
 }
Esempio n. 14
0
 /// 
 /// This function will serve from the front of the Queue.  Notice
 /// no deallocation for the Node Class, This is now handled by the 
 /// Garbage Collector.
 /// 
 public object serve()
 {
     temp = front;
     if (count == 0)
         throw new Exception("tried to serve from an empty Queue");
     front = front.Next;
     count--;
     return temp.Value;
 }
Esempio n. 15
0
 public void Clear()
 {
     this.head = null;
     this.tail = null;
     this.count = 0;
 }
Esempio n. 16
0
 public Queue()
 {
     this.head = null;
     this.tail = null;
     this.count = 0;
 }
Esempio n. 17
0
 public Node(object data, Node prevNode)
 {
     this.data = data;
     prevNode.next = this;
 }