PathrockNetwork Gno Explorer
HomeBlocksTransactionsRealmsPackagesValidatorsAnalytics

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/moul/x/daily/flatmap/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
moul / x / daily / flatmap
Files
3 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/moul/x/daily/flatmap/v0
gno
0.9

Files (3)

  • README.mdmarkdown
  • gnomod.tomltoml
  • flatmap.gnogno
README.mdPreviewRaw
# `gno.land/p/moul/x/daily/flatmap/v0`

**Sorted-vector map** — `New`, `Set`, `Get`, `Has`, `Delete`, `Keys`, `Values`,
`At`, `Iterate`, `Range`, `Clone`, `Sorted`, `MaxEntries`.

```go
import "gno.land/p/moul/x/daily/flatmap/v0"

f := flatmap.New()
f.Set("delta", "4"); f.Set("alpha", "1")
f.Keys()                  // ["alpha" "delta"] — sorted by construction
f.At(0)                   // "alpha", "1", true — indexed access
f.Range("a", "c", fn)     // lo inclusive, hi exclusive
```

The STL `flat_map` trade. Keys and values live in two parallel sorted slices
instead of a hash table or a tree of nodes:

| operation | cost |
|---|---|
| `Get` | O(log n) binary search over contiguous memory |
| iteration | O(n), already ordered, nothing to sort |
| `Set` in the middle | **O(n)** — the tail shifts |
| `Set` at the end | O(1) amortised — the fast path |

Cheap reads and cheap ordered iteration, paid for at write time. That trade is
stated rather than hidden.

On chain the ordering is the real draw: a built-in gno map iterates in an
unspecified order, so a `Render` built from one can differ between nodes. A flat
map is sorted by construction, so iteration is deterministic **without a sort on
every read**.

Sorted storage also buys two things a hash map cannot offer: `At(i)` positional
access, and `Range(lo, hi)` as two binary searches and a walk — including when
the bounds are not themselves keys.

`Sorted()` is exported so callers can assert the invariant; it holds through the
whole public API, including 200 worst-case head insertions.

**Live demo:** [`r/moul/x/daily/flatmapdemo`](https://github.com/moul/gno-contracts/tree/main/r/moul/x/daily/flatmapdemo/v0)
· render it at [`/r/moul/x/daily/flatmapdemo/v0`](https://gno.land/r/moul/x/daily/flatmapdemo/v0).

<!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) -->

---

Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

> 🧪 **Highly experimental — potentially vibe-coded.** Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: [DISCLAIMER](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md).

<!-- END GNOCONTRACTS FOOTER -->

Functions

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

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