Skip to content

Commit

Permalink
chore(examples): update avlhelpers to use avl.ITree (#3377)
Browse files Browse the repository at this point in the history
## Description

Updates the `avlhelpers` package to use the new `avl.ITree` interface.
  • Loading branch information
leohhhn authored Dec 20, 2024
1 parent 329845f commit e57815a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/gno.land/p/demo/avlhelpers/avlhelpers.gno
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// It calls the provided callback function for each key-value pair encountered.
// If the callback returns true, the iteration is stopped.
// The prefix and keys are treated as byte strings, ignoring possible multi-byte Unicode runes.
func IterateByteStringKeysByPrefix(tree avl.Tree, prefix string, cb avl.IterCbFn) {
func IterateByteStringKeysByPrefix(tree avl.ITree, prefix string, cb avl.IterCbFn) {
end := ""
n := len(prefix)
// To make the end of the search, increment the final character ASCII by one.
Expand All @@ -28,7 +28,7 @@ func IterateByteStringKeysByPrefix(tree avl.Tree, prefix string, cb avl.IterCbFn
// Get a list of keys starting from the given prefix. Limit the
// number of results to maxResults.
// The prefix and keys are treated as byte strings, ignoring possible multi-byte Unicode runes.
func ListByteStringKeysByPrefix(tree avl.Tree, prefix string, maxResults int) []string {
func ListByteStringKeysByPrefix(tree avl.ITree, prefix string, maxResults int) []string {
result := []string{}
IterateByteStringKeysByPrefix(tree, prefix, func(key string, value interface{}) bool {
result = append(result, key)
Expand Down
4 changes: 2 additions & 2 deletions examples/gno.land/p/demo/avlhelpers/z_0_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func main() {
tree := avl.Tree{}
tree := avl.NewTree()

{
// Empty tree.
Expand Down Expand Up @@ -44,7 +44,7 @@ func main() {
println("match: " + matches[0])
}

tree = avl.Tree{}
tree = avl.NewTree()
tree.Set("a\xff", "")
tree.Set("a\xff\xff", "")
tree.Set("b", "")
Expand Down
2 changes: 1 addition & 1 deletion examples/gno.land/r/demo/users/users.gno
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func GetUserByAddressOrName(input users.AddressOrName) *users.User {
// Get a list of user names starting from the given prefix. Limit the
// number of results to maxResults. (This can be used for a name search tool.)
func ListUsersByPrefix(prefix string, maxResults int) []string {
return avlhelpers.ListByteStringKeysByPrefix(name2User, prefix, maxResults)
return avlhelpers.ListByteStringKeysByPrefix(&name2User, prefix, maxResults)
}

func Resolve(input users.AddressOrName) std.Address {
Expand Down

0 comments on commit e57815a

Please sign in to comment.