Skip to content

Commit caa9c87

Browse files
author
DvirDukhan
committed
fixed PR comments
1 parent f30d765 commit caa9c87

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func main() {
9393
res.Next()
9494
r := res.Record()
9595
p, ok := r.GetByIndex(0).(Path)
96-
fmt.Printf("%v", p.Encode())
96+
fmt.Printf("%s", p)
9797
}
9898
```
9999

path.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,40 @@ import (
66
)
77

88
type Path struct {
9-
Nodes []interface{}
10-
Edges []interface{}
9+
Nodes []*Node
10+
Edges []*Edge
1111
}
1212

1313
func PathNew(nodes []interface{}, edges []interface{}) Path {
14-
return Path{
15-
Nodes: nodes,
16-
Edges: edges,
14+
Nodes := make([]*Node, len(nodes))
15+
for i := 0; i < len(nodes); i++ {
16+
Nodes[i] = nodes[i].(*Node)
17+
}
18+
Edges := make([]*Edge, len(edges))
19+
for i := 0; i < len(edges); i++ {
20+
Edges[i] = edges[i].(*Edge)
21+
}
22+
23+
return Path{
24+
Edges : Edges,
25+
Nodes : Nodes,
1726
}
1827
}
1928

20-
func (p Path) GetNodes() []interface{} {
29+
func (p Path) GetNodes() []*Node {
2130
return p.Nodes
2231
}
2332

24-
func (p Path) GetEdges() []interface{} {
33+
func (p Path) GetEdges() []*Edge {
2534
return p.Edges
2635
}
2736

2837
func (p Path) GetNode(index int) *Node {
29-
return p.Nodes[index].(*Node)
38+
return p.Nodes[index]
3039
}
3140

3241
func (p Path) GetEdge(index int) *Edge{
33-
return p.Edges[index].(*Edge);
42+
return p.Edges[index]
3443
}
3544

3645
func (p Path) FirstNode() *Node {
@@ -49,7 +58,7 @@ func (p Path) EdgeCount() int {
4958
return len(p.Edges)
5059
}
5160

52-
func (p Path) Encode() string {
61+
func (p Path) String() string {
5362
s := []string{"<"}
5463
edgeCount := p.EdgeCount()
5564
for i := 0; i < edgeCount; i++ {

0 commit comments

Comments
 (0)