public override bool MoveNextCore() { while (_right == null || !_right.MoveNext()) { if (!_left.MoveNext()) { return(false); } _right = _expr.EvaluateNodeSet(_left); } if (_current == null) { _current = _right.Current.Clone(); } else if (!_current.MoveTo(_right.Current)) { _current = _right.Current.Clone(); } return(true); }
public override bool MoveNextCore() { if (_finished) { return(false); } if (_iterRight == null) // First time { if (!_iterLeft.MoveNext()) { return(false); } _iterRight = _expr.EvaluateNodeSet(_iterLeft); _iterList = new SortedList(XPathIteratorComparer.Instance); } while (true) { while (!_iterRight.MoveNext()) { if (_iterList.Count > 0) { int last = _iterList.Count - 1; _iterRight = (BaseIterator)_iterList.GetByIndex(last); _iterList.RemoveAt(last); break; } else if (_nextIterRight != null) { _iterRight = _nextIterRight; _nextIterRight = null; break; } else if (!_iterLeft.MoveNext()) { _finished = true; return(false); } else { _iterRight = _expr.EvaluateNodeSet(_iterLeft); } } bool loop = true; while (loop) { loop = false; if (_nextIterRight == null) { bool noMoreNext = false; while (_nextIterRight == null || !_nextIterRight.MoveNext()) { if (_iterLeft.MoveNext()) { _nextIterRight = _expr.EvaluateNodeSet(_iterLeft); } else { noMoreNext = true; break; } } if (noMoreNext) { _nextIterRight = null; // FIXME: More efficient code. Maybe making noMoreNext class scope would be better. } } if (_nextIterRight != null) { switch (_iterRight.Current.ComparePosition(_nextIterRight.Current)) { case XmlNodeOrder.After: _iterList [_iterRight] = _iterRight; _iterRight = _nextIterRight; _nextIterRight = null; loop = true; break; case XmlNodeOrder.Same: if (!_nextIterRight.MoveNext()) { _nextIterRight = null; } else { int last = _iterList.Count; _iterList [_nextIterRight] = _nextIterRight; if (last != _iterList.Count) { _nextIterRight = (BaseIterator)_iterList.GetByIndex(last); _iterList.RemoveAt(last); } } loop = true; break; } } } return(true); } }