Documentation ¶
Overview ¶
Package hashmap provides a generic hashmap and hashset implementation.
Index ¶
- type Bool
- type Byte
- type Bytes
- type Comparable
- type Complex128
- type Complex64
- type Float32
- type Float64
- type Int
- type Int16
- type Int32
- type Int64
- type Int8
- type Map
- type Rune
- type Set
- func (s *Set[K]) Add(key K)
- func (s *Set[K]) Contains(key K) bool
- func (s *Set[K]) Copy() *Set[K]
- func (s *Set[K]) Difference(t *Set[K]) *Set[K]
- func (s *Set[K]) Equals(t *Set[K]) bool
- func (s *Set[K]) ForEach(f func(K) error) error
- func (s *Set[K]) Hash() uint64
- func (s *Set[K]) Intersection(t *Set[K]) *Set[K]
- func (s *Set[K]) IsDisjoint(t *Set[K]) bool
- func (s *Set[K]) IsSubset(t *Set[K]) bool
- func (s *Set[K]) Remove(key K)
- func (s *Set[K]) Size() int
- func (s *Set[K]) Union(t *Set[K]) *Set[K]
- type Slice
- type String
- type Uint
- type Uint16
- type Uint32
- type Uint64
- type Uint8
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bytes ¶
type Bytes []byte
Bytes is a wrapper around []byte that implements the Comparable interface.
type Comparable ¶
Comparable is an interface that must be implemented by all types that are used as keys in a Map or Set.
type Complex128 ¶
type Complex128 complex128
Complex128 is a wrapper around complex128 that implements the Comparable interface.
func (Complex128) Equals ¶
func (c Complex128) Equals(other Complex128) bool
func (Complex128) Hash ¶
func (c Complex128) Hash() uint64
type Complex64 ¶
type Complex64 complex64
Complex64 is a wrapper around complex64 that implements the Comparable interface.
type Float32 ¶
type Float32 float32
Float32 is a wrapper around float32 that implements the Comparable interface. It uses the IEEE 754 binary32 format for hashing and equality. NaN is considered equal to itself.
type Float64 ¶
type Float64 float64
Float64 is a wrapper around float64 that implements the Comparable interface. It uses the IEEE 754 binary64 format for hashing and equality. NaN is considered equal to itself.
type Int16 ¶
type Int16 int16
Int16 is a wrapper around int16 that implements the Comparable interface.
type Int32 ¶
type Int32 int32
Int32 is a wrapper around int32 that implements the Comparable interface.
type Int64 ¶
type Int64 int64
Int64 is a wrapper around int64 that implements the Comparable interface.
type Map ¶
type Map[K Comparable[K], V any] struct { // contains filtered or unexported fields }
Map is a hash map that uses open addressing with linear probing. It is not thread-safe. The zero value is an empty map ready to use.
func (*Map[K, V]) Get ¶
Get returns the value associated with the given key. The second return value indicates if the key was found. The value is the zero value for the value type if the key was not found.
func (*Map[K, V]) Put ¶
func (m *Map[K, V]) Put(key K, value V)
Put adds the given key/value pair to the map. If the key already exists, the value is updated.
type Set ¶
type Set[K Comparable[K]] struct { // contains filtered or unexported fields }
Set is a hash set that uses open addressing with linear probing. It is not thread-safe. The zero value is an empty set ready to use. Set implements Comparable, so it can be used as a key in a Map or an element in a Set.
func (*Set[K]) Difference ¶
Difference returns a new set with the elements that are in the set but not in the given set.
func (*Set[K]) Intersection ¶
Intersection returns a new set with the elements that are in both sets.
func (*Set[K]) IsDisjoint ¶
IsDisjoint returns true if the intersection of the set and the given set is empty.
type Slice ¶
type Slice[T Comparable[T]] []T
Slice is a wrapper around []T that implements the Comparable interface.
type String ¶
type String string
String is a wrapper around string that implements the Comparable interface.
type Uint16 ¶
type Uint16 uint16
Uint16 is a wrapper around uint16 that implements the Comparable interface.
type Uint32 ¶
type Uint32 uint32
Uint32 is a wrapper around uint32 that implements the Comparable interface.