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/bloom

Package
Open in gnoweb ↗

Overview

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

Files (3)

  • README.mdmarkdown
  • gnomod.tomltoml
  • bloom.gnogno
README.mdPreviewRaw
# Bloom Package

Package implements a Bloom filter, a space-efficient probabilistic data structure
used to test whether an element is a member of a set.

A Bloom filter never returns a false negative. If `Contains` returns `false`, the
element was definitely never added. It may return a false positive, `Contains` can
return `true` for an element that was never added. This trade-off lets the filter
use far less memory than storing the elements themselves, which makes it useful for
membership checks such as caches, deduplication, or "have I seen this before?" tests.

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/g17khqpukees4237dtn3astzapmp462vjhsz6st4/bloom"

func main() {
	// Create a filter expecting up to 1000 items with a 1% false-positive rate.
	b := bloom.New(1000, 0.01)

	b.AddString("apple").AddString("banana")

	println("Has apple:", b.ContainsString("apple"))
	println("Has banana:", b.ContainsString("banana"))
	println("Has cherry:", b.ContainsString("cherry"))
}

// Output:
// Has apple: true
// Has banana: true
// Has cherry: false
```

Functions

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

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