-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.go
30 lines (26 loc) · 780 Bytes
/
map.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Package hashmaps implements several types of hash tables.
package hashmaps
import "errors"
const (
// DefaultMaxLoad is the default value for the load factor for:
// -Hopscotch
// -Robin Hood
// hashmaps, which can be changed with MaxLoad(). This value is a
// trade-off of runtime and memory consumption.
DefaultMaxLoad = 0.7
)
var (
// ErrOutOfRange signals an out of range request.
ErrOutOfRange = errors.New("out of range")
)
// IHashMap collects the basic hash maps operations as function points.
type IHashMap[K comparable, V any] struct {
Get func(key K) (V, bool)
Reserve func(n uintptr)
Load func() float32
Put func(key K, val V) bool
Remove func(key K) bool
Clear func()
Size func() int
Each func(fn func(key K, val V) bool)
}