Documentation ¶
Index ¶
- type Map
- func (m *Map[K, V]) Copy() *Map[K, V]
- func (m *Map[K, V]) Delete(key K) (prev V, deleted bool)
- func (m *Map[K, V]) Get(key K) (value V, ok bool)
- func (m *Map[K, V]) GetPos(pos uint64) (key K, value V, ok bool)
- func (m *Map[K, V]) Keys() []K
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) Scan(iter func(key K, value V) bool)
- func (m *Map[K, V]) Set(key K, value V) (V, bool)
- func (m *Map[K, V]) Values() []V
- type Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map is a hashmap. Like map[string]interface{}
func New ¶
func New[K comparable, V any](cap int) *Map[K, V]
New returns a new Map. Like map[string]interface{}
func (*Map[K, V]) Delete ¶
Delete deletes a value for a key. Returns the deleted value, or false when no value was assigned.
func (*Map[K, V]) Get ¶
Get returns a value for a key. Returns false when no value has been assign for key.
func (*Map[K, V]) GetPos ¶ added in v1.1.0
GetPos gets a single keys/value nearby a position. The pos param can be any valid uint64. Useful for grabbing a random item from the map.
func (*Map[K, V]) Keys ¶ added in v1.5.0
func (m *Map[K, V]) Keys() []K
Keys returns all keys as a slice
func (*Map[K, V]) Scan ¶ added in v1.4.1
Scan iterates over all key/values. It's not safe to call or Set or Delete while scanning.
type Set ¶ added in v1.4.1
type Set[K comparable] struct { // contains filtered or unexported fields }
func (*Set[K]) Copy ¶ added in v1.6.0
Copy the set. This is a copy-on-write operation and is very fast because it only performs a shadow copy.
func (*Set[K]) GetPos ¶ added in v1.8.0
GetPos gets a single keys/value nearby a position. The pos param can be any valid uint64. Useful for grabbing a random item from the Set.