numBits
untyped bigint// m: total bits in the filter
Value
(2048 <untyped> bigint)
numBytes
untyped bigintValue
(256 <untyped> bigint)
numHashes
untyped bigint// k: hash functions per item (double-hashed from 2 bases)
Value
(5 <untyped> bigint)
maxHistory
untyped bigint// most recent additions kept for Render display only
Value
(20 <untyped> bigint)
bits
[256]uint8// the bit array itself
- OID
- 0aef2d…1d54:4
bits details
setBits
int// running count of bits currently set to 1
Value
0
added
int// total Add calls (may double-count re-adds)
Value
0
history
[]string// last few added items, for the Render view
Value
<zero>
fnv1a
func(s string, seed uint32) uint32fnv1a is a minimal FNV-1a 32-bit hash over a string, parameterized by an offset basis so two calls with different seeds behave as independent hash functions for the double-hashing scheme below.
- OID
- 0aef2d…1d54:8
fnv1a details
positions
func(item string) [5]uint32positions returns the k bit positions an item hashes to.
- OID
- 0aef2d…1d54:10
positions details
setBit
func(pos uint32) boolsetBit sets bit \`pos\` and reports whether it was previously unset.
- OID
- 0aef2d…1d54:11
setBit details
testBit
func(pos uint32) booltestBit reports whether bit \`pos\` is set.
- OID
- 0aef2d…1d54:12
testBit details
Add
func(item string)Add inserts \`item\` into the filter. Crossing function: any caller (user or realm) may add, matching this demo's open-membership model.
- OID
- 0aef2d…1d54:13
Add details
MightContain
func(item string) boolMightContain reports whether \`item\` was possibly added before. A false (definitely-not-a-member) answer is always correct; a true answer can occasionally be a false positive, never a false negative.
- OID
- 0aef2d…1d54:14
MightContain details
FalsePositiveRatePercent
func() float64FalsePositiveRatePercent estimates the current false-positive rate, in percent, as (bitsSet/m)^k — the standard Bloom filter approximation once bits are randomly distributed. Computed with plain integer/float math to avoid depending on math.Exp/Pow availability.
- OID
- 0aef2d…1d54:15
FalsePositiveRatePercent details
Stats
func() (int, int, int, int)Stats returns the raw counters backing the Render view and FalsePositiveRatePercent: (itemsAdded, bitsSet, totalBits, hashCount).
- OID
- 0aef2d…1d54:16
Stats details
Render
func(path string) stringRender draws the filter's current stats and recently-added items as Markdown for gnoweb.
- OID
- 0aef2d…1d54:17