implement reverse v1
This commit is contained in:
parent
5451d07ff5
commit
2bceb9c25f
2 changed files with 19 additions and 2 deletions
|
|
@ -61,9 +61,21 @@ func M(qs graph.QuadStore) *Path {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Path) Reverse() *Path {
|
||||||
|
newPath := M(p.qs)
|
||||||
|
for i := len(p.stack) - 1; i >= 0; i-- {
|
||||||
|
newPath.stack = append(newPath.stack, p.stack[i].Reversal())
|
||||||
|
}
|
||||||
|
return newPath
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Path) IsConcrete() bool { return p.it != nil }
|
func (p *Path) IsConcrete() bool { return p.it != nil }
|
||||||
|
|
||||||
func (p *Path) Tag(tags ...string) *Path { p.stack = append(p.stack, TagMorphism(tags...)); return p }
|
func (p *Path) Tag(tags ...string) *Path {
|
||||||
|
p.stack = append(p.stack, TagMorphism(tags...))
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Path) Out(via ...interface{}) *Path {
|
func (p *Path) Out(via ...interface{}) *Path {
|
||||||
p.stack = append(p.stack, OutMorphism(p.qs, via...))
|
p.stack = append(p.stack, OutMorphism(p.qs, via...))
|
||||||
return p
|
return p
|
||||||
|
|
|
||||||
|
|
@ -69,10 +69,15 @@ type test struct {
|
||||||
func testSet(qs graph.QuadStore) []test {
|
func testSet(qs graph.QuadStore) []test {
|
||||||
return []test{
|
return []test{
|
||||||
{
|
{
|
||||||
message: "out",
|
message: "use out",
|
||||||
path: V(qs, "A").Out("follows"),
|
path: V(qs, "A").Out("follows"),
|
||||||
expect: []string{"B"},
|
expect: []string{"B"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
message: "use in",
|
||||||
|
path: V(qs, "B").In("follows"),
|
||||||
|
expect: []string{"A", "C", "D"},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue