Documentation ¶
Index ¶
- type BytesCopyFunc
- type BytesEqualsFunc
- type BytesFinalizeFunc
- type BytesHashFunc
- type BytesIntHashMap
- func (m *BytesIntHashMap) Contains(k []byte) bool
- func (m *BytesIntHashMap) Delete(k []byte)
- func (m *BytesIntHashMap) Get(k []byte) (int, bool)
- func (m *BytesIntHashMap) Iter() map[BytesIntHashMapHash]BytesIntHashMapEntry
- func (m *BytesIntHashMap) Len() int
- func (m *BytesIntHashMap) Reallocate()
- func (m *BytesIntHashMap) Reset()
- func (m *BytesIntHashMap) Set(k []byte, v int)
- func (m *BytesIntHashMap) SetUnsafe(k []byte, v int, opts SetUnsafeBytesOptions)
- type BytesIntHashMapEntry
- type BytesIntHashMapHash
- type BytesIntHashMapOptions
- type SetUnsafeBytesOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BytesCopyFunc ¶
BytesCopyFunc is the copy key function to execute when copying the key.
type BytesEqualsFunc ¶
BytesEqualsFunc is the equals key function to execute when detecting equality of a key.
type BytesFinalizeFunc ¶
type BytesFinalizeFunc func([]byte)
BytesFinalizeFunc is the finalize key function to execute when finished with a key.
type BytesHashFunc ¶
type BytesHashFunc func([]byte) BytesIntHashMapHash
BytesHashFunc is the hash function to execute when hashing a key.
type BytesIntHashMap ¶
type BytesIntHashMap struct {
// contains filtered or unexported fields
}
BytesIntHashMap 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. BytesIntHashMap 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 NewBytesIntHashMap ¶
func NewBytesIntHashMap(opts BytesIntHashMapOptions) *BytesIntHashMap
NewBytesIntHashMap returns a new byte keyed map.
func (*BytesIntHashMap) Contains ¶
func (m *BytesIntHashMap) Contains(k []byte) bool
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 (*BytesIntHashMap) Delete ¶
func (m *BytesIntHashMap) Delete(k []byte)
Delete will remove a value set in the map for the specified key.
func (*BytesIntHashMap) Get ¶
func (m *BytesIntHashMap) Get(k []byte) (int, bool)
Get returns a value in the map for an identifier if found.
func (*BytesIntHashMap) Iter ¶
func (m *BytesIntHashMap) Iter() map[BytesIntHashMapHash]BytesIntHashMapEntry
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 (*BytesIntHashMap) Len ¶
func (m *BytesIntHashMap) Len() int
Len returns the number of map entries in the map.
func (*BytesIntHashMap) Reallocate ¶
func (m *BytesIntHashMap) 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 (*BytesIntHashMap) Reset ¶
func (m *BytesIntHashMap) Reset()
Reset will reset the map by simply deleting all keys to avoid allocating a new map.
func (*BytesIntHashMap) Set ¶
func (m *BytesIntHashMap) Set(k []byte, v int)
Set will set the value for an identifier.
func (*BytesIntHashMap) SetUnsafe ¶
func (m *BytesIntHashMap) SetUnsafe(k []byte, v int, opts SetUnsafeBytesOptions)
SetUnsafe will set the value for an identifier with unsafe options for how the map treats the key.
type BytesIntHashMapEntry ¶
type BytesIntHashMapEntry struct {
// contains filtered or unexported fields
}
BytesIntHashMapEntry is an entry in the map, this is public to support iterating over the map using a native Go for loop.
func (BytesIntHashMapEntry) Key ¶
func (e BytesIntHashMapEntry) Key() []byte
Key returns the map entry key.
func (BytesIntHashMapEntry) Value ¶
func (e BytesIntHashMapEntry) Value() int
Value returns the map entry value.
type BytesIntHashMapHash ¶
type BytesIntHashMapHash uint64
BytesIntHashMapHash is the hash for a given map entry, this is public to support iterating over the map using a native Go for loop.
type BytesIntHashMapOptions ¶
BytesIntHashMapOptions provides options used when created the map.
type SetUnsafeBytesOptions ¶
SetUnsafeBytesOptions is a set of options to use when setting a value with the SetUnsafe method.