Exemple #1
0
        public void Add(T element)
        {
            ILBinTreeNode <T> cur = null; // m_root;

            while (cur != null)
            {
            }
            m_count++;
        }
Exemple #2
0
        private void heapify(ILBinTreeNode <T> top)
        {
            System.Diagnostics.Debug.Assert(top != null && top.Data != null);
            int res;
            ILBinTreeNode <T> child;

            if (top.LeftSon != null)
            {
                System.Diagnostics.Debug.Assert(top.LeftSon.Data != null);
                T ls = top.LeftSon.Data;
                if (top.RightSon != null)
                {
                    System.Diagnostics.Debug.Assert(top.RightSon.Data != null);
                    T rs = top.RightSon.Data;
                    if (ls.CompareTo(rs) > 0)
                    {
                        child = top.LeftSon;
                    }
                    else
                    {
                        child = top.RightSon;
                    }
                }
                else
                {
                    child = top.LeftSon;
                }
            }
            else
            {
                if (top.RightSon != null)
                {
                    System.Diagnostics.Debug.Assert(top.RightSon.Data != null);
                    child = top.RightSon;
                }
                else
                {
                    return;
                }
            }
            // may exchange this data with largest node's value
            if (child.m_data.CompareTo(top.m_data) > 0)
            {
                T tmp = child.m_data;
                child.m_data = top.m_data;
                top.m_data   = tmp;
                heapify(child);
            }
        }
Exemple #3
0
 private bool Contains(ILBinTreeNode <T> _root, T data)
 {
     if (object.Equals(_root.Data, data))
     {
         return(true);
     }
     if (_root.LeftSon != null && Contains(_root.LeftSon, data))
     {
         return(true);
     }
     if (_root.RightSon != null && Contains(_root.RightSon, data))
     {
         return(true);
     }
     return(false);
 }