Esempio n. 1
0
        // Methods
        public void AddNode(treeNode el, int pr)
        {
            queueNode item = new queueNode(el, pr);

            if (base.Count == 0)
            {
                base.Add(item);
            }
            else
            {
                for (int i = 0; i < base.Count; i++)
                {
                    if (base[i].priority > pr)
                    {
                        item.next = base[i];
                        if (i > 0)
                        {
                            base[i - 1].next = item;
                        }
                        base.Insert(i, item);
                        return;
                    }
                    if (base[i].next == null)
                    {
                        base[i].next = item;
                        base.Add(item);
                        return;
                    }
                }
            }
        }
Esempio n. 2
0
 private void traverseTree(treeNode tn, string cod)
 {
     if (tn.symbol != '\0')
     {
         tableNode item = new tableNode(tn.symbol, cod);
         base.Add(item);
     }
     if (tn.left != null)
     {
         this.traverseTree(tn.left, cod.Insert(cod.Length, "0"));
     }
     if (tn.right != null)
     {
         this.traverseTree(tn.right, cod.Insert(cod.Length, "1"));
     }
 }
Esempio n. 3
0
 // Methods
 public queueNode(treeNode el, int pr)
 {
     this.val      = el;
     this.priority = pr;
     this.next     = null;
 }
Esempio n. 4
0
 // Methods
 public treeNode(treeNode le, treeNode ri, char sy)
 {
     this.left   = le;
     this.right  = ri;
     this.symbol = sy;
 }