Esempio n. 1
0
        public T this[int index]
        {
            get
            {
                if (index < 0 || index >= Count)
                {
                    throw new IndexOutOfRangeException();
                }

                WeightedAvlNode <T> current = root;
                while (true)
                {
                    int leftWeight = current.Left.Weight;
                    if (index < leftWeight)
                    {
                        current = current.Left;
                    }
                    else if (index > leftWeight)
                    {
                        index  -= leftWeight + 1;
                        current = current.Right;
                    }
                    else
                    {
                        return(current.Payload);
                    }
                }
            }
        }
Esempio n. 2
0
            public Descent Descend()
            {
                int leftWeight = _current.Left.Weight;

                if (_index < leftWeight)
                {
                    _current = _current.Left;
                    return(Descent.Left);
                }
                else if (_index > leftWeight)
                {
                    _index  -= leftWeight + 1;
                    _current = _current.Right;
                    return(Descent.Right);
                }
                else
                {
                    return(Descent.Found);
                }
            }
Esempio n. 3
0
 public Descent Descend()
 {
     if (_current.IsNil)
     {
         return(Descent.Found);
     }
     else
     {
         if (_position <= _current.Left.Weight)
         {
             _current = _current.Left;
             return(Descent.Left);
         }
         else
         {
             _position -= _current.Left.Weight + 1;
             _current   = _current.Right;
             return(Descent.Right);
         }
     }
 }
Esempio n. 4
0
 private PersistentList(WeightedAvlNode <T> root) : base(root)
 {
 }
Esempio n. 5
0
 public NodeLocator(int index, WeightedAvlNode <T> root)
 {
     _index   = index;
     _current = root;
 }
Esempio n. 6
0
 public InsertionPointLocator(int position, WeightedAvlNode <T> root)
 {
     _position = position;
     _current  = root;
 }