Example #1
0
 public void Enqueue(T data, double p)
 {
     this.len++;
     if (this.root == null)
     {
         this.root = new Nodo_simple <T>(data, prioridad: p);
     }
     else
     {
         Nodo_simple <T> new_node;
         if (this.root.Prioridad > p)
         {
             new_node  = new Nodo_simple <T>(data, this.root, p);
             this.root = new_node;
             return;
         }
         Nodo_simple <T> this_node = this.root;
         while (this_node.Next != null)
         {
             if (this_node.Next.Prioridad > p)
             {
                 new_node       = new Nodo_simple <T>(data, this_node.Next, p);
                 this_node.Next = new_node;
                 return;
             }
             this_node = this_node.Next;
         }
         this_node.Next = new Nodo_simple <T>(data, prioridad: p);
     }
 }
Example #2
0
        public Nodo_simple <T> Dequeue()
        {
            if (this.len > 0)
            {
                Nodo_simple <T> ret_node = this.root;
                this.root = this.root.Next;
                this.len--;

                return(ret_node);
            }
            return(null);
        }
Example #3
0
        public override string ToString()
        {
            if (len == 0)
            {
                return("Vacio");
            }
            string          self_str  = $"{this.root}";
            Nodo_simple <T> this_node = this.root.Next;

            while (this_node != null)
            {
                self_str += $" => {this_node}";
                this_node = this_node.Next;
            }
            return(self_str);
        }
Example #4
0
 public Pqueue()
 {
     this.len  = 0;
     this.root = null;
 }
Example #5
0
 public Nodo_simple(T data, Nodo_simple <T> next = null, double prioridad = 0)
 {
     this.next      = next;
     this.prioridad = prioridad;
     this.data      = data;
 }
Example #6
0
 public void Clear()
 {
     this.root = null;
     this.len  = 0;
 }