Skip to content

Commit

Permalink
Add Val method to node type
Browse files Browse the repository at this point in the history
  • Loading branch information
derekparker committed Sep 16, 2024
1 parent 6a4ad62 commit 4095f8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ func (n *node[T]) removeChild(r rune) {
}
}

// Val returns the value of the node.
func (n *node[T]) Val() T {
return n.meta
}

func findNode[T any](nd *node[T], runes []rune) *node[T] {
if nd == nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestTrieFind(t *testing.T) {
t.Fatal("Could not find node")
}

if n.meta != 1 {
if n.Val() != 1 {
t.Errorf("Expected 1, got: %d", n.meta)
}
}
Expand Down

0 comments on commit 4095f8e

Please sign in to comment.