Пример #1
0
        public bool MoveNext()
        {
            switch (_action)
            {
            case Action.Right:
                _current = _right;

                while (_current.Left != null)
                {
                    _current = _current.Left;
                }

                _right  = _current.Right;
                _action = _right != null ? Action.Right : Action.Parent;

                return(true);

            case Action.Parent:
                while (_current.Parent != null)
                {
                    AvlNode <TKey, TValue> previous = _current;

                    _current = _current.Parent;

                    if (_current.Left == previous)
                    {
                        _right  = _current.Right;
                        _action = _right != null ? Action.Right : Action.Parent;

                        return(true);
                    }
                }

                _action = Action.End;

                return(false);

            default:
                return(false);
            }
        }
Пример #2
0
 public void Reset()
 {
     _right  = _root;
     _action = _root == null ? Action.End : Action.Right;
 }
Пример #3
0
 public AvlNodeEnumerator(AvlNode <TKey, TValue> root)
 {
     _right  = _root = root;
     _action = _root == null ? Action.End : Action.Right;
 }