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/orderedmap/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
moul / x / daily / orderedmap
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/orderedmap/v0
gno
0.9

Files (3)

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

**Map that remembers insertion order** — `New`, `Set`, `Get`, `Has`, `Delete`,
`Keys`, `Values`, `Iterate`, `At`, `Clone`, `Len`, `MaxKeys`.

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

o := orderedmap.New()
o.Set("delta", "4"); o.Set("alpha", "1")
o.Keys()             // ["delta" "alpha"] — insertion order, not sorted
o.Set("delta", "99") // updates in place, keeps position
```

**This matters more on chain than off it.** gno map iteration order is
unspecified, so a realm that ranges over a built-in map to build its `Render`
can emit a different page on every call — a **consensus bug**, not a cosmetic
one. This type gives back a deterministic order without requiring the keys to be
sortable.

Semantics worth knowing, each with a test:

- **Updating keeps position.** Insertion order means *first* insertion, not last
  write.
- **Re-inserting after a delete goes last** — it is a new insertion.
- `Keys` returns a copy, so a caller cannot reorder the map through it.

Backed by a built-in map for O(1) `Get` plus a slice holding the order. `Delete`
is **O(n)**: closing the gap in that slice is what preserves order, and that
trade is stated rather than hidden. `MaxKeys` (4096) bounds growth; a full map
refuses new keys but still accepts updates to existing ones.

**Live demo:** [`r/moul/x/daily/orderedmapdemo`](https://github.com/moul/gno-contracts/tree/main/r/moul/x/daily/orderedmapdemo/v0)
· render it at [`/r/moul/x/daily/orderedmapdemo/v0`](https://gno.land/r/moul/x/daily/orderedmapdemo/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.