Skip to content

Commit

Permalink
reverse the return value of Ancestors()
Browse files Browse the repository at this point in the history
  • Loading branch information
Daisuke Maki committed Oct 16, 2024
1 parent 2348ac8 commit 3e0866c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ type Node[K cmp.Ordered, V any] interface {
Parent() Node[K, V]

// Ancestors returns a sequence of ancestors of this node.
// The first element is the root element, progressing all the way
// up to the parent of this node.
// The first element is the current element, progressing all the way
// back to the root element ("")
Ancestors() iter.Seq[Node[K, V]]
}

Expand Down Expand Up @@ -271,13 +271,13 @@ func (n *node[K, V]) Ancestors() iter.Seq[Node[K, V]] {

return func(yield func(Node[K, V]) bool) {
for len(ancestors) > 0 {
cur := ancestors[len(ancestors)-1]
cur := ancestors[0]
if cur != nil && !cur.isRoot {
if !yield(cur) {
break
}
}
ancestors = ancestors[:len(ancestors)-1]
ancestors = ancestors[1:]
}
}
}
Expand Down

0 comments on commit 3e0866c

Please sign in to comment.