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); } } } }
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); } }
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); } } }
private PersistentList(WeightedAvlNode <T> root) : base(root) { }
public NodeLocator(int index, WeightedAvlNode <T> root) { _index = index; _current = root; }
public InsertionPointLocator(int position, WeightedAvlNode <T> root) { _position = position; _current = root; }