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()); }
private LinkedList <Relationship> GatherRelationships(TraversalBranch first, TraversalBranch then) { // TODO Don't loop through them all up front LinkedList <Relationship> relationships = new LinkedList <Relationship>(); TraversalBranch branch = first; while (branch.Length() > 0) { relationships.AddFirst(branch.LastRelationship()); branch = branch.Parent(); } // We can might as well cache start node since we're right now there anyway if (_cachedStartNode == null && first == _start && branch.Length() >= 0) { _cachedStartNode = branch.EndNode(); } branch = then; while (branch.Length() > 0) { relationships.AddLast(branch.LastRelationship()); branch = branch.Parent(); } if (_cachedStartNode == null && then == _start && branch.Length() >= 0) { _cachedStartNode = branch.EndNode(); } return(relationships); }
public override bool Equals(object obj) { if (obj == this) { return(true); } if (!(obj is TraversalBranch)) { return(false); } TraversalBranch branch = this; TraversalBranch other = ( TraversalBranch )obj; if (branch.Length() != other.Length()) { return(false); } while (branch.Length() > 0) { if (!branch.LastRelationship().Equals(other.LastRelationship())) { return(false); } branch = branch.Parent(); other = other.Parent(); } return(true); }
public override IEnumerable <Relationship> Relationships() { LinkedList <Relationship> relationships = new LinkedList <Relationship>(); TraversalBranch branch = this; while (branch.Length() > 0) { relationships.AddFirst(branch.LastRelationship()); branch = branch.Parent(); } return(relationships); }
public override IEnumerator <PropertyContainer> Iterator() { LinkedList <PropertyContainer> entities = new LinkedList <PropertyContainer>(); TraversalBranch branch = this; while (branch.Length() > 0) { entities.AddFirst(branch.EndNode()); entities.AddFirst(branch.LastRelationship()); branch = branch.Parent(); } entities.AddFirst(branch.EndNode()); return(entities.GetEnumerator()); }
public override int GetHashCode() { TraversalBranch branch = this; int hashCode = 1; while (branch.Length() > 0) { Relationship relationship = branch.LastRelationship(); hashCode = 31 * hashCode + relationship.GetHashCode(); branch = branch.Parent(); } if (hashCode == 1) { hashCode = EndNode().GetHashCode(); } return(hashCode); }
internal BidirectionalTraversalBranchPath(TraversalBranch start, TraversalBranch end) { this._start = start; this._end = end; // Most used properties: endNode and lastRelationship, so cache them right away (semi-expensive though). IEnumerator <PropertyContainer> endPathEntities = end.GetEnumerator(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: this._endNode = ( Node )endPathEntities.next(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: this._lastRelationship = endPathEntities.hasNext() ? (Relationship)endPathEntities.next() : start.LastRelationship(); }
protected internal override double?CalculateValue(TraversalBranch next) { return(next.Length() == 0 ? 0d : outerInstance.costEvaluator.GetCost(next.LastRelationship(), Direction.OUTGOING)); }
protected internal override int?calculateValue(TraversalBranch next) { return(next.Length() == 0 ? 0 : evaluator.getCost(next.LastRelationship(), Direction.BOTH)); }