hash_set

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOAD_FACTOR = 5
)

in order to reduce the conflict of hash * hash array can be LOAD_FACTOR times larger than nodePool

Variables

This section is empty.

Functions

This section is empty.

Types

type HashSet

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

func NewHashSet

func NewHashSet(elemNum int, elemSize int, isFixKeyLen bool,
	hashFunc func([]byte) uint64) (*HashSet, error)

NewHashSet creates a newHashSet

PARAMS:

  • elemNum: max element num of hashSet
  • elemSize: maxSize of hashKey after it converted to []byte
  • isFixKeyLen: fixed element size or not
  • hashFunc: hash function

RETURNS:

  • (*HashSet, nil), if success
  • (nil, error), if fail

func (*HashSet) Add

func (set *HashSet) Add(key []byte) error

Add - add an element into the set

PARAMS:

  • key: []byte, element of the set

RETURNS:

  • nil, if succeed
  • error, if fail

func (*HashSet) Exist

func (set *HashSet) Exist(key []byte) bool

Exist checks if the element exist in Set

func (*HashSet) Full

func (set *HashSet) Full() bool

Full checks if the hashSet full or not

func (*HashSet) Len

func (set *HashSet) Len() int

Len returns element Num of hashSet

func (*HashSet) Remove

func (set *HashSet) Remove(key []byte) error

Remove removes an element from the hashSet

PARAMS:

  • key: []byte, element of the set

RETURNS:

  • nil, if succeed
  • error, if fail

Jump to

Keyboard shortcuts

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