moveBack method

bool moveBack()

Implementation

bool moveBack() {
  if (_length != _tree._length) {
    throw ConcurrentModificationError();
  }
  while (true) {
    if (_currentNode == null) {
      if (_tree._rootNode == null) return false;
      var _c = IteratorNode(_tree._rootNode!, null);
      while (_c.treeNode.right != null) {
        _c = IteratorNode(_c.treeNode.right!, _c);
      }
      _currentNode = _c;
      _currentNode?.currentIterated = true;
      return true;
    }

    if (_currentNode!.currentIterated) {
      if (_currentNode!.treeNode.left != null) {
        if (_currentNode!.rightIterated) {
          _currentNode = _currentNode!.parent;
          if (_currentNode == null) return false;
        } else {
          var _c = IteratorNode(_currentNode!.treeNode.left!, _currentNode);
          _currentNode!.rightIterated = true;
          while (_c.treeNode.right != null) {
            _c = IteratorNode(_c.treeNode.right!, _c);
          }
          _currentNode = _c;
          _currentNode?.currentIterated = true;
          return true;
        }
      } else {
        _currentNode = _currentNode!.parent;
        if (_currentNode == null) return false;
      }
    } else {
      _currentNode!.currentIterated = true;
      return true;
    }
  }
}