hash_tab_ts_ts

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashTab

type HashTab[T comparable.Comparable] struct {
	// contains filtered or unexported fields
}

HashTab is a generic binary tree

func NewHashTab

func NewHashTab[T comparable.Comparable](n int) *HashTab[T]

Complexity is O(1).

func (*HashTab[T]) Delete

func (tt *HashTab[T]) Delete(find *T) (found bool)

Delete an element from the hash_tab. The element needs to have been located with "Search" or as a result of a match using the Walk function. Complexity is O(1)

func (*HashTab[T]) Dump

func (tt *HashTab[T]) Dump(fo io.Writer)

Dump will print out the hash table to the file `fo`. Complexity is O(n).

func (*HashTab[T]) Insert

func (tt *HashTab[T]) Insert(item *T)

Insert will add a new item to the tree. If it is a duplicate of an exiting item the new item will replace the existing one. Complexity is O(log n)/k.

func (HashTab[T]) IsEmpty

func (tt HashTab[T]) IsEmpty() bool

IsEmpty will return true if the binary-tree is empty Complexity is O(1).

func (*HashTab[T]) ItemExists added in v0.0.8

func (tt *HashTab[T]) ItemExists(find *T) (rv bool)

if ok := ht.ItemExists(&DefinedItem{Name: in}); !ok {

func (*HashTab[T]) Len

func (tt *HashTab[T]) Len() int

Length returns the number of elements in the list. Complexity is O(1).

func (*HashTab[T]) Length

func (tt *HashTab[T]) Length() int

func (*HashTab[T]) NlDelete

func (tt *HashTab[T]) NlDelete(find *T) (found bool)

func (*HashTab[T]) NlSearch

func (tt *HashTab[T]) NlSearch(find *T) (rv *T)

Search will walk the tree looking for `find` and retrn the found item if it is in the tree. If it is not found then `nil` will be returned. Complexity is O(log n)/k.

func (*HashTab[T]) ReadLock

func (tt *HashTab[T]) ReadLock()

func (*HashTab[T]) ReadUnlock

func (tt *HashTab[T]) ReadUnlock()

func (*HashTab[T]) Search

func (tt *HashTab[T]) Search(find *T) (rv *T)

Search will walk the tree looking for `find` and retrn the found item if it is in the tree. If it is not found then `nil` will be returned. Complexity is O(log n)/k.

func (*HashTab[T]) Truncate

func (tt *HashTab[T]) Truncate()

Truncate removes all data from the tree. Complexity is O(1).

func (*HashTab[T]) Walk

func (tt *HashTab[T]) Walk(fx binary_tree.ApplyFunction[T], userData interface{})

func (*HashTab[T]) WalkFunc

func (tt *HashTab[T]) WalkFunc(Fx func(a *T))

func (*HashTab[T]) WriteLock

func (tt *HashTab[T]) WriteLock()

ht.WriteLock() ht.WriteUnlock() ht.ReadLock() ht.ReadUnlock()

func (*HashTab[T]) WriteUnlock

func (tt *HashTab[T]) WriteUnlock()

type Hashable

type Hashable interface {
	HashKey(x interface{}) int
}

Jump to

Keyboard shortcuts

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