Documentation ¶
Index ¶
- func DefaultHashFunction[K comparable](key K, size int) uint64
- type ChainedHashTable
- func (cht *ChainedHashTable[K, V]) Cap() int
- func (cht *ChainedHashTable[K, V]) Del(key K) bool
- func (cht *ChainedHashTable[K, V]) Exists(key K) bool
- func (cht *ChainedHashTable[K, V]) Get(key K) (V, bool)
- func (cht *ChainedHashTable[K, V]) Set(key K, value V)
- func (cht *ChainedHashTable[K, V]) Size() int
- type Entry
- type HashFunction
- type HashTable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHashFunction ¶
func DefaultHashFunction[K comparable](key K, size int) uint64
DefaultHashFunction is the default hash function (using xxhash).
Types ¶
type ChainedHashTable ¶
type ChainedHashTable[K comparable, V any] struct { // contains filtered or unexported fields }
ChainedHashTable is a chained hash table.
func NewChainedHashTable ¶
func NewChainedHashTable[K comparable, V any](cap int, hashFunc ...HashFunction[K]) *ChainedHashTable[K, V]
NewChainedHashTable returns a new chained hash table.
func (*ChainedHashTable[K, V]) Cap ¶
func (cht *ChainedHashTable[K, V]) Cap() int
Cap returns the capacity of the hash table.
func (*ChainedHashTable[K, V]) Del ¶
func (cht *ChainedHashTable[K, V]) Del(key K) bool
Del deletes the key.
func (*ChainedHashTable[K, V]) Exists ¶
func (cht *ChainedHashTable[K, V]) Exists(key K) bool
Exists returns true if the key exists.
func (*ChainedHashTable[K, V]) Get ¶
func (cht *ChainedHashTable[K, V]) Get(key K) (V, bool)
Get gets the value of the key.
func (*ChainedHashTable[K, V]) Set ¶
func (cht *ChainedHashTable[K, V]) Set(key K, value V)
Set sets the value of the key.
func (*ChainedHashTable[K, V]) Size ¶
func (cht *ChainedHashTable[K, V]) Size() int
Size returns the number of elements in the hash table.
type Entry ¶
type Entry[K comparable, V any] struct { // contains filtered or unexported fields }
Entry is an entry in a hash table.
func NewEntry ¶
func NewEntry[K comparable, V any](key K, value V) *Entry[K, V]
NewEntry returns a new entry.
type HashFunction ¶
type HashFunction[K comparable] func(key K, size int) uint64
HashFunction is a hash function type.
type HashTable ¶
type HashTable[K comparable, V any] struct { // contains filtered or unexported fields }
HashTable is a hash table.
func NewHashTable ¶
func NewHashTable[K comparable, V any](cap int, hashFunc ...HashFunction[K]) *HashTable[K, V]
NewHashTable returns a new hash table with linear probing.
Click to show internal directories.
Click to hide internal directories.