hashmap

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator added in v1.3.3

type Iterator[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Iterator is an iterator over a HashMap.

func (*Iterator[K, V]) Get added in v1.3.3

func (it *Iterator[K, V]) Get() misc.Pair[K, V]

Get returns the current entry as a key-value pair.

func (*Iterator[K, V]) Key added in v1.3.3

func (it *Iterator[K, V]) Key() K

Key returns the key of the current entry.

func (*Iterator[K, V]) Move added in v1.3.3

func (it *Iterator[K, V]) Move()

Move moves the iterator to the next entry.

func (*Iterator[K, V]) Remove added in v1.3.3

func (it *Iterator[K, V]) Remove()

Remove removes the current entry from the map. The iterator will point to the next entry afterward.

func (*Iterator[K, V]) SetValue added in v1.3.3

func (it *Iterator[K, V]) SetValue(value V)

SetValue sets the value of the current entry.

func (*Iterator[K, V]) Valid added in v1.3.3

func (it *Iterator[K, V]) Valid() bool

Valid returns true if it points to a valid entry.

func (*Iterator[K, V]) Value added in v1.3.3

func (it *Iterator[K, V]) Value() V

Value returns the value of the current entry.

func (*Iterator[K, V]) ValueRef added in v1.3.3

func (it *Iterator[K, V]) ValueRef() *V

ValueRef returns a reference to the value of the current entry.

type Map

type Map[K comparable, V any] map[K]V

Map is a hash map with builtin map as a base.

func FromMap added in v1.3.2

func FromMap[K comparable, V any](m map[K]V) Map[K, V]

FromMap creates a new Map from the specified map.

func New

func New[K comparable, V any]() Map[K, V]

New creates an empty Map.

func NewFromIterable added in v1.6.1

func NewFromIterable[K comparable, V any](iterable iter.Iterable[misc.Pair[K, V]]) Map[K, V]

NewFromIterable creates a Map from the specified iter.Iterable.

func NewWithCapacity added in v1.3.0

func NewWithCapacity[K comparable, V any](capacity int) Map[K, V]

NewWithCapacity creates an empty Map with the specified capacity.

func (Map[K, V]) Clear

func (m Map[K, V]) Clear()

Clear removes all entries from the map.

func (Map[K, V]) Clone

func (m Map[K, V]) Clone() maps.Map[K, V]

Clone returns a shallow copy of the map.

func (Map[K, V]) Contains

func (m Map[K, V]) Contains(key K) bool

Contains returns true if the map contains the specified key.

func (Map[K, V]) Get

func (m Map[K, V]) Get(key K) V

Get returns the value associated with the specified key. Panics if the key is not present.

func (Map[K, V]) GetRef added in v0.8.1

func (m Map[K, V]) GetRef(key K) *V

GetRef returns a reference to the value associated with the specified key. Panics if the key is not present.

func (Map[K, V]) Iterator

func (m Map[K, V]) Iterator() iter.Iterator[misc.Pair[K, V]]

Iterator returns an iter.Iterator over the map.

func (Map[K, V]) Map added in v1.3.0

func (m Map[K, V]) Map() map[K]V

Map returns the builtin map used as a base.

func (Map[K, V]) MapIterator added in v1.5.0

func (m Map[K, V]) MapIterator() maps.Iterator[K, V]

MapIterator returns an iterator over the map.

func (Map[K, V]) RefsStream2 added in v1.7.0

func (m Map[K, V]) RefsStream2(yield func(K, *V) bool)

RefsStream2 streams over the keys and references to the values in the Map.

func (Map[K, V]) Remove

func (m Map[K, V]) Remove(key K)

Remove removes the entry with the specified key. Does nothing if the key is not present.

func (Map[K, V]) Set

func (m Map[K, V]) Set(key K, value V)

Set sets the value associated with the specified key.

func (Map[K, V]) Size

func (m Map[K, V]) Size() int

Size returns the number of entries in the map.

func (Map[K, V]) Stream2 added in v1.7.0

func (m Map[K, V]) Stream2(yield func(K, V) bool)

Stream2 streams over the entries in the Map.

func (Map[K, V]) TryGet added in v1.3.2

func (m Map[K, V]) TryGet(key K) (V, bool)

TryGet returns the value associated with the specified key, or zero value and false if the key is not present.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL