Documentation
¶
Overview ¶
Package swiss is the open-addressed table behind the module's hash maps: groups of eight slots, each with one control byte holding seven bits of the hash, probed a group at a time with word-at-a-time comparisons. It needs no stored hash and reaches a 7/8 load, so it costs one byte per slot.
Index ¶
- type Entry
- type Table
- func (t *Table[S]) All(who string, yield func(*S) bool)
- func (t *Table[S]) Clear()
- func (t *Table[S]) Clip() error
- func (t *Table[S]) Find(h uint64, eq func(*S) bool) *S
- func (t *Table[S]) Free() error
- func (t *Table[S]) Insert(h uint64) (*S, error)
- func (t *Table[S]) Len() int
- func (t *Table[S]) Remove(h uint64, eq func(*S) bool) (S, bool)
- func (t *Table[S]) Touch(h uint64) uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶ added in v0.5.0
type Entry[K comparable, V any] struct { Key K Value V }
Entry is a slot holding a comparable key and its value.
type Table ¶
type Table[S any] struct { // contains filtered or unexported fields }
Table is an open-addressed table of slots. It is not safe for concurrent use. Pointers into it are valid until the next call that may grow or shrink it.
func New ¶
New returns an empty Table with room for capacity entries. hash must return the hash the slot was inserted under.
func (*Table[S]) All ¶
All calls yield with every slot until it returns false. A change to the set of entries during the loop panics, reporting who as the modified container.
func (*Table[S]) Clear ¶ added in v0.5.0
func (t *Table[S]) Clear()
Clear removes every entry, keeping the table's memory.