private IEnumerable <Node> GatherNodes(TraversalBranch first, TraversalBranch then) { // TODO Don't loop through them all up front LinkedList <Node> nodes = new LinkedList <Node>(); TraversalBranch branch = first; while (branch.Length() > 0) { nodes.AddFirst(branch.EndNode()); branch = branch.Parent(); } if (_cachedStartNode == null && first == _start && branch.Length() >= 0) { _cachedStartNode = branch.EndNode(); } nodes.AddFirst(branch.EndNode()); branch = then.Parent(); if (branch != null) { while (branch.Length() > 0) { nodes.AddLast(branch.EndNode()); branch = branch.Parent(); } if (branch.Length() >= 0) { nodes.AddLast(branch.EndNode()); } } if (_cachedStartNode == null && then == _start && branch != null && branch.Length() >= 0) { _cachedStartNode = branch.EndNode(); } return(nodes); }
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); }
private TraversalBranch FindStartBranch() { TraversalBranch branch = this; while (branch.Length() > 0) { branch = branch.Parent(); } return(branch); }
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 IEnumerable <Node> Nodes() { LinkedList <Node> nodes = new LinkedList <Node>(); TraversalBranch branch = this; while (branch.Length() > 0) { nodes.AddFirst(branch.EndNode()); branch = branch.Parent(); } nodes.AddFirst(branch.EndNode()); return(nodes); }
public override bool Check(TraversalBranch source) { long idToCompare = Type.getId(source); while (source.Length() > 0) { source = source.Parent(); if (Type.idEquals(source, idToCompare)) { return(false); } } return(true); }
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); }