hashtable

package module
v0.0.0-...-fafb133 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 1 Imported by: 0

README

hashtable

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashTable

type HashTable[K comparable, V any] struct {
	// contains filtered or unexported fields
}

HashTable stores key/value pairs where the number of hashtable buckets is n number of buckets.

A smaller number of buckets means less buckets will be created, but each key stored in the HashTable has a higher likelihood of having to share a bucket with other keys, thus slowing down lookups.

A larger number of buckets means more buckets will be created, so each key stored in the Table has a lower likelihood of having to share a bucket with other keys, thus speeding up lookups.

func New

func New[K comparable, V any](numberOfBuckets int, hash hash[K]) *HashTable[K, V]

New creates a table with n number of internal buckets which uses the specified hash function for an input type K.

func (*HashTable[K, V]) Delete

func (ht *HashTable[K, V]) Delete(key K)

func (*HashTable[K, V]) Insert

func (ht *HashTable[K, V]) Insert(key K, value V)

Insert a new key/value pair.

func (*HashTable[K, V]) Keys

func (ht *HashTable[K, V]) Keys() array.Array[K]

func (*HashTable[K, V]) Search

func (ht *HashTable[K, V]) Search(key K) (V, bool)

Jump to

Keyboard shortcuts

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