Documentation ¶
Index ¶
- type Iterator
- func (it *Iterator[K, V]) Get() misc.Pair[K, V]
- func (it *Iterator[K, V]) Key() K
- func (it *Iterator[K, V]) Move()
- func (it *Iterator[K, V]) Node() *Node[K, V]
- func (it *Iterator[K, V]) Remove()
- func (it *Iterator[K, V]) SetValue(value V)
- func (it *Iterator[K, V]) Valid() bool
- func (it *Iterator[K, V]) Value() V
- func (it *Iterator[K, V]) ValueRef() *V
- type Node
- type Order
- type Wrapper
- func (w *Wrapper[K, V]) Clear()
- func (w *Wrapper[K, V]) Clone() maps.Map[K, V]
- func (w *Wrapper[K, V]) Contains(key K) bool
- func (w *Wrapper[K, V]) Get(key K) V
- func (w *Wrapper[K, V]) GetRef(key K) *V
- func (w *Wrapper[K, V]) Iterator() iter.Iterator[misc.Pair[K, V]]
- func (w *Wrapper[K, V]) MapIterator() maps.Iterator[K, V]
- func (w *Wrapper[K, V]) RefsStream2(yield func(K, *V) bool)
- func (w *Wrapper[K, V]) Remove(key K)
- func (w *Wrapper[K, V]) Set(key K, value V)
- func (w *Wrapper[K, V]) Size() int
- func (w *Wrapper[K, V]) Stream2(yield func(K, V) bool)
- func (w *Wrapper[K, V]) TryGet(key K) (V, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator[K, V any] struct { // contains filtered or unexported fields }
Iterator is a struct for iterating over the map.
func (*Iterator[K, V]) Move ¶
func (it *Iterator[K, V]) Move()
Move moves the iterator to the next element.
func (*Iterator[K, V]) Remove ¶
func (it *Iterator[K, V]) Remove()
Remove removes the current entry from the map. The iterator will be moved to the next element.
func (*Iterator[K, V]) SetValue ¶
func (it *Iterator[K, V]) SetValue(value V)
SetValue sets the value of the current entry.
type Node ¶
type Node[K, V any] struct { Value V // The Value of the entry stored in the node. // contains filtered or unexported fields }
Node is a entry in the map. It is used to keep track of the order of the elements. It should not be created directly.
func (*Node[K, V]) Clone ¶
Clone returns a copy of the node. The clone has the same key and value as the node. The clone does not have any links to other nodes.
func (*Node[K, V]) Key ¶
func (node *Node[K, V]) Key() K
Key returns the key of the entry stored in the node.
type Wrapper ¶
type Wrapper[K, V any] struct { // contains filtered or unexported fields }
Wrapper is a map that keeps track of the order of the nodes.
func NewHashmap ¶
func NewHashmap[K comparable, V any](capacity int, order Order) *Wrapper[K, V]
NewHashmap returns a new Wrapper around a empty hashmap.
func (*Wrapper[K, V]) Clear ¶
func (w *Wrapper[K, V]) Clear()
Clear removes all entries from the map.
func (*Wrapper[K, V]) Get ¶
func (w *Wrapper[K, V]) Get(key K) V
Get returns the value associated with the given key. Panics if the key is not in the map. If the order is LRU, the entry is moved to the front.
func (*Wrapper[K, V]) GetRef ¶
func (w *Wrapper[K, V]) GetRef(key K) *V
GetRef returns a reference to the value associated with the given key. Panics if the key is not in the map. If the order is LRU, the entry is moved to the front.
func (*Wrapper[K, V]) MapIterator ¶
MapIterator returns a iterator over the entries in the map.
func (*Wrapper[K, V]) RefsStream2 ¶ added in v1.7.0
RefsStream2 streams keys and references to values of the Map
func (*Wrapper[K, V]) Remove ¶
func (w *Wrapper[K, V]) Remove(key K)
Remove removes the entry with the given key. If the key is not in the map, nothing happens.
func (*Wrapper[K, V]) Set ¶
func (w *Wrapper[K, V]) Set(key K, value V)
Set sets the value associated with the given key. Entry is moved to the front of the map. If the map is full, the last entry is removed.