hash_set

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LOAD_FACTOR = 5
)

LOAD_FACTOR

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