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

Package
Open in gnoweb ↗

Overview

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

Files (3)

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

**Bidirectional map, unique both ways** — `New`, `Put`, `PutUnique`, `Get`,
`GetKey`, `Has`, `HasValue`, `Delete`, `DeleteValue`, `Keys`, `Values`,
`Iterate`, `Invert`, `Clone`, `Consistent`, `MaxPairs`.

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

m := bidimap.New()
m.Put("alice", "admin")
m.Get("alice")      // "admin", true
m.GetKey("admin")   // "alice", true — O(1), not a scan
```

Both sides are unique, which is the interesting constraint: inserting a pair
whose value already belongs to another key must do something deliberate rather
than silently corrupt the reverse index.

- **`Put` replaces**, and returns the pairs it displaced, so the caller sees what
  it evicted rather than discovering it later.
- **`PutUnique` refuses** instead, returning `false` and changing nothing.

What is not on offer is a half-updated map. `Consistent()` is exported so callers
and tests can assert the two indexes agree; it is true through the whole public
API.

One subtlety with `MaxPairs` (4096): a full map **still accepts** a `Put` that
rebinds an existing key or steals an existing value, because that reuses a slot
rather than growing the map. Only a pair new on *both* sides is refused.

`Keys`/`Values` come back **sorted**, never in map order: gno map iteration order
is unspecified, and a `Render` built from one can differ between nodes.

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