rhh

package
v1.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	Capacity:   256,
	LoadFactor: 90,
}

DefaultOptions represents a default set of options to pass to NewHashMap().

Functions

func Dist

func Dist(hash, i, capacity int64) int64

Dist returns the probe distance for a hash in a slot index. NOTE: Capacity must be a power of 2.

func HashKey

func HashKey(key []byte) int64

HashKey computes a hash of key. Hash is always non-zero.

Types

type HashMap

type HashMap struct {
	// contains filtered or unexported fields
}

HashMap represents a hash map that implements Robin Hood Hashing. https://cs.uwaterloo.ca/research/tr/1986/CS-86-14.pdf

func NewHashMap

func NewHashMap(opt Options) *HashMap

func (*HashMap) AverageProbeCount

func (m *HashMap) AverageProbeCount() float64

AverageProbeCount returns the average number of probes for each element.

func (*HashMap) Cap

func (m *HashMap) Cap() int64

Cap returns the number of key/values set in map.

func (*HashMap) Elem

func (m *HashMap) Elem(i int64) (key []byte, value interface{})

Elem returns the i-th key/value pair of the hash map.

func (*HashMap) Get

func (m *HashMap) Get(key []byte) interface{}

func (*HashMap) Keys

func (m *HashMap) Keys() [][]byte

Keys returns a list of sorted keys.

func (*HashMap) Len

func (m *HashMap) Len() int64

Len returns the number of key/values set in map.

func (*HashMap) Put

func (m *HashMap) Put(key []byte, val interface{})

func (*HashMap) Reset

func (m *HashMap) Reset()

Reset clears the values in the map without deallocating the space.

type Options

type Options struct {
	Capacity   int64
	LoadFactor int
}

Options represents initialization options that are passed to NewHashMap().

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL