From 287ea63e2d18c9c2bc9c0cf334379638c0405de4 Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Thu, 4 Sep 2014 16:30:05 -0400 Subject: [PATCH] rename to paths --- graph/api/api.go | 14 +++++--------- graph/api/api_test.go | 10 +++++----- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/graph/api/api.go b/graph/api/api.go index 848ff36..928ba61 100644 --- a/graph/api/api.go +++ b/graph/api/api.go @@ -26,16 +26,12 @@ type morphism struct { Apply graph.MorphismFunc } -type iteratorMorphism interface { - Apply(graph.Iterator) graph.Iterator -} - type Path struct { stack []morphism qs graph.QuadStore } -func V(qs graph.QuadStore, nodes ...string) *Path { +func StartPath(qs graph.QuadStore, nodes ...string) *Path { return &Path{ stack: []morphism{ isMorphism(qs, nodes...), @@ -53,14 +49,14 @@ func PathFromIterator(qs graph.QuadStore, it graph.Iterator) *Path { } } -func M(qs graph.QuadStore) *Path { +func NewPath(qs graph.QuadStore) *Path { return &Path{ qs: qs, } } func (p *Path) Reverse() *Path { - newPath := M(p.qs) + newPath := NewPath(p.qs) for i := len(p.stack) - 1; i >= 0; i-- { newPath.stack = append(newPath.stack, p.stack[i].Reversal()) } @@ -216,7 +212,7 @@ func buildViaPath(qs graph.QuadStore, via ...interface{}) *Path { if path, ok := v.(*Path); ok { return path } else if str, ok := v.(string); ok { - return V(qs, str) + return StartPath(qs, str) } else { panic("Invalid type passed to buildViaPath.") } @@ -229,5 +225,5 @@ func buildViaPath(qs graph.QuadStore, via ...interface{}) *Path { panic("Non-string type passed to long Via path") } } - return V(qs, strings...) + return StartPath(qs, strings...) } diff --git a/graph/api/api_test.go b/graph/api/api_test.go index 2b0a4d4..09dbe1f 100644 --- a/graph/api/api_test.go +++ b/graph/api/api_test.go @@ -72,23 +72,23 @@ func testSet(qs graph.QuadStore) []test { return []test{ { message: "use out", - path: V(qs, "A").Out("follows"), + path: StartPath(qs, "A").Out("follows"), expect: []string{"B"}, }, { message: "use in", - path: V(qs, "B").In("follows"), + path: StartPath(qs, "B").In("follows"), expect: []string{"A", "C", "D"}, }, { message: "use path Out", - path: V(qs, "B").Out(V(qs, "predicates").Out("are")), + path: StartPath(qs, "B").Out(StartPath(qs, "predicates").Out("are")), expect: []string{"F", "cool"}, }, { message: "in", - path: V(qs, "D").Out("follows").And( - V(qs, "C").Out("follows")), + path: StartPath(qs, "D").Out("follows").And( + StartPath(qs, "C").Out("follows")), expect: []string{"B"}, }, }