hashtable

package
v0.0.0-...-45b5b11 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hashtable

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

func New

func New(size int, hashFunc func(gram *ngram.Ngram) [32]byte) *Hashtable

New will create a new hashtable with a capacity approximately the size given as an argument. The true size is the smallest power of 2 that is greater than the requested size

func (*Hashtable) Collisions

func (h *Hashtable) Collisions() int

func (*Hashtable) Delete

func (h *Hashtable) Delete(key string) error

Delete deletes a key/value pair from the hashtable. Should return an error if the given key doesn't exist.

func (*Hashtable) Exists

func (h *Hashtable) Exists(key string) bool

Exists returns true if the key exists in the hashtable, false otherwise.

func (*Hashtable) Get

func (h *Hashtable) Get(key string) (int, error)

Get returns the value associated with the given key. Should return an error if value doesn't exist.

func (*Hashtable) GetSimilarSentences

func (h *Hashtable) GetSimilarSentences() [][]string

func (*Hashtable) Insert

func (h *Hashtable) Insert(key string, value int) error

Insert inserts a new key/value pair into the hashtable. Should return an error if the key already exists.

func (*Hashtable) Keys

func (h *Hashtable) Keys() []string

Keys returns a list of the keys in the hashtable

func (*Hashtable) Print

func (h *Hashtable) Print() string

Print will output the key and value for every existing entry in the table

func (*Hashtable) Update

func (h *Hashtable) Update(key string, value int) error

Update updates an existing key to be associated with a different value. Should return an error if the key doesn't already exist.

Jump to

Keyboard shortcuts

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