Example #1
0
        //ref u
        /*   public bool Check()
           {
               Node p = head;
               bool u = true;
               if (p != null)
                   do
                   {
                       if (p.inf > p.next.inf)
                           u = false;

                   } while (p != null);

                   return u;
           }*/
        public bool Check()
        {
            Node p = head;
            bool u = true;
            for (int i = 0; i < count; i++)
            {

                if (p != null)
                // do
                {
                    if ((p.inf > p.next.inf) && (u == true))
                    {
                        u = false;
                        head = head.next;
                        count--;
                    }
                    else
                    {
                        head = head.next;
                        count--;
                    }
                    //  } while (p != null);
                }
            }
            return u;
        }
Example #2
0
 // положить в хвост очереди
 public void InQueue(int inf)
 {
     Node p = new Node(inf, null);
     if (QueueIsEmpty())
     {
         head = p; tail = p;
     }
     else
     {
         tail.next = p; tail = p;
     }
     count++;
 }
Example #3
0
 // взять из головы очереди
 public int OutQueue()
 {
     Node p = head;
     head = head.next;
     count--;
     return p.inf;
 }
Example #4
0
 public MyQueue()
 {
     head = null; tail = null; count = 0;
 }
Example #5
0
 // Конструктор
 public Node(int inf, Node next)
 {
     this.inf = inf;
     this.next = next;
 }