public override IEnumerator <PropertyContainer> Iterator() { // TODO Don't loop through them all up front LinkedList <PropertyContainer> entities = new LinkedList <PropertyContainer>(); TraversalBranch branch = _start; while (branch.Length() > 0) { entities.AddFirst(branch.EndNode()); entities.AddFirst(branch.LastRelationship()); branch = branch.Parent(); } entities.AddFirst(branch.EndNode()); if (_cachedStartNode == null) { _cachedStartNode = branch.EndNode(); } if (_end.length() > 0) { entities.AddLast(_end.lastRelationship()); branch = _end.parent(); while (branch.Length() > 0) { entities.AddLast(branch.EndNode()); entities.AddLast(branch.LastRelationship()); branch = branch.Parent(); } entities.AddLast(branch.EndNode()); } return(entities.GetEnumerator()); }
protected internal override Relationship fetchNextOrNull() { try { return(branch != null?branch.lastRelationship() : null); } finally { branch = branch != null?branch.parent() : null; } }