Example #1
0
        public void Pop()
        {
            ForQueue temp;

            while (head != null)
            {
                temp = head;
                head = head.next;
                temp = null;
            }
        }
Example #2
0
 public void AddinQueue(int a)//положить элемент в очередь
 {
     if (head == null)
     {
         head = new ForQueue(a);
         tail = head;
     }
     else
     {
         ForQueue temp = new ForQueue(a);
         tail.next = temp;
         tail      = temp;
     }
 }
Example #3
0
 public void FirstDel()
 {
     try
     {
         Console.WriteLine("Извлеченный первый элемент: " + head.data);
         if (head == tail)
         {
             tail = null;
         }
         head = head.next;
         Console.WriteLine("Сама очередь: " + display());
     }
     catch (Exception ex)
     {
         Console.WriteLine("Ошибка: " + ex.Message);
     }
 }
Example #4
0
        public int searchmin()
        {
            int      min  = head.data;
            ForQueue temp = head;

            while (true)
            {
                if (min > temp.data)
                {
                    min = temp.data;
                }
                if (temp == tail)
                {
                    break;
                }
                temp = temp.next;
            }
            return(min);
        }
Example #5
0
        public string display()
        {
            string str = "";

            if (head != null)
            {
                ForQueue temp = head;
                while (true)
                {
                    str = str + temp.data + " ";
                    if (temp == tail)
                    {
                        break;
                    }
                    temp = temp.next;
                }
            }
            return(str);
        }
Example #6
0
        public int count()
        {
            int      i    = 0;
            ForQueue temp = head;

            if (head != null)
            {
                while (true)
                {
                    i++;
                    if (temp == tail)
                    {
                        break;
                    }
                    temp = temp.next;
                }
            }
            return(i);
        }
Example #7
0
        public int searchmax()
        {
            int      max  = head.data;
            ForQueue temp = head;

            while (true)
            {
                if (max < temp.data)
                {
                    max = temp.data;
                }
                if (temp == tail)
                {
                    break;
                }
                temp = temp.next;
            }
            return(max);
        }
Example #8
0
 public MQueue()
 {
     head = null;
     tail = null;
 }
Example #9
0
 public ForQueue(int a)
 {
     data = a;
     next = null;
 }