Documentation ¶
Index ¶
- type CopyFn
- type EqualsFn
- type FinalizeFn
- type HashFn
- type KeyType
- type Map
- func (m *Map) Contains(k KeyType) bool
- func (m *Map) Delete(k KeyType)
- func (m *Map) Get(k KeyType) (ValueType, bool)
- func (m *Map) Iter() map[MapHash]MapEntry
- func (m *Map) Len() int
- func (m *Map) Reallocate()
- func (m *Map) Reset()
- func (m *Map) Set(k KeyType, v ValueType)
- func (m *Map) SetUnsafe(k KeyType, v ValueType, opts SetUnsafeOptions)
- type MapEntry
- type MapHash
- type SetUnsafeOptions
- type ValueType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FinalizeFn ¶
type FinalizeFn func(KeyType)
FinalizeFn is the finalize key function to execute when finished with a key.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map uses the genny package to provide a generic hash map that can be specialized by running the following command from this root of the repository: ``` make hashmap-gen pkg=outpkg key_type=Type value_type=Type out_dir=/tmp ``` Or if you would like to use bytes or ident.ID as keys you can use the partially specialized maps to generate your own maps as well: ``` make byteshashmap-gen pkg=outpkg value_type=Type out_dir=/tmp make idhashmap-gen pkg=outpkg value_type=Type out_dir=/tmp ``` This will output to stdout the generated source file to use for your map. It uses linear probing by incrementing the number of the hash created when hashing the identifier if there is a collision. Map is a value type and not an interface to allow for less painful upgrades when adding/removing methods, it is not likely to need mocking so an interface would not be super useful either.
func (*Map) Contains ¶
Contains returns true if value exists for key, false otherwise, it is shorthand for a call to Get that doesn't return the value.
func (*Map) Iter ¶
Iter provides the underlying map to allow for using a native Go for loop to iterate the map, however callers should only ever read and not write the map.
func (*Map) Reallocate ¶
func (m *Map) Reallocate()
Reallocate will avoid deleting all keys and reallocate a new map, this is useful if you believe you have a large map and will not need to grow back to a similar size.
func (*Map) Reset ¶
func (m *Map) Reset()
Reset will reset the map by simply deleting all keys to avoid allocating a new map.
type MapEntry ¶
type MapEntry struct {
// contains filtered or unexported fields
}
MapEntry is an entry in the map, this is public to support iterating over the map using a native Go for loop.
type MapHash ¶
type MapHash uint64
MapHash is the hash for a given map entry, this is public to support iterating over the map using a native Go for loop.
type SetUnsafeOptions ¶
SetUnsafeOptions is a set of options to use when setting a value with the SetUnsafe method.