PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/g17khqpukees4237dtn3astzapmp462vjhsz6st4/trie

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
trie
Namespace
g17khqpukees4237dtn3astzapmp462vjhsz6st4
Files
5 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/g17khqpukees4237dtn3astzapmp462vjhsz6st4/trie
gno
0.9

Files (5)

  • README.mdmarkdown
  • gnomod.tomltoml
  • doc.gnogno
  • node.gnogno
  • tree.gnogno
README.mdPreviewRaw
# Trie Package

Package implements a simple prefix-tree (trie) for Gno realms, keyed by
`string` with values of any type.

`Tree` implements the [`avl.ITree`](https://gno.land/p/nt/avl/v0$source&file=tree.gno)
interface from `gno.land/p/nt/avl`, so it can be used as a drop-in alternative
to an AVL tree.

Repository can be found at [jeronimoalbi/gnome](https://github.com/jeronimoalbi/gnome),
as part of `jeronimoalbi`'s Gno smart contracts monorepo.

## Usage

[embedmd]:# (filetests/readme_filetest.gno go)
```go
package main

import "gno.land/p/jeronimoalbi/trie"

func main() {
	tree := trie.NewTree()
	tree.Set("apple", 1)
	tree.Set("app", 2)
	tree.Set("banana", 3)

	// Get value for app
	v := tree.Get("app")
	println(v)

	// Iterate keys in lexicographic order: app, apple, banana.
	tree.Iterate("", "", func(key string, value any) bool {
		println(key, value)
		return false
	})
}

// Output:
// 2
// app 2
// apple 1
// banana 3
```

Functions

not supported for pure packages by the node (vm/qfuncs)

Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.