linkedhashmap

package
v0.0.0-...-2a10efc Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnumerableWithKey

type EnumerableWithKey[K comparable, V any] interface {
	Filter(f func(k K, v V) bool) *Map[K, V]

	containers.EnumerableWithKey[K, V]
}

type Iterator

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

Iterator is an iterator for the linked hash map.

func (*Iterator[K, V]) Begin

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

Begin resets the iterator to its initial state (one-before-first) Call Next() to fetch the first element if any.

func (*Iterator[K, V]) End

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

End moves the iterator past the last element (one-past-the-end). Call Prev() to fetch the last element if any.

func (*Iterator[K, V]) First

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

First moves the iterator to the first element and returns true if there was a first element in the container. If the iterator was positioned before the first element, it will be moved to the first element. If the first element has not been loaded, loading will be performed.

func (*Iterator[K, V]) Key

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

Key returns the current key of the iterator.

func (*Iterator[K, V]) Last

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

Last moves the iterator to the last element and returns true if there was a last element in the container. If the iterator was positioned before the last element, it will be moved to the last element. If the last element has not been loaded, loading will be performed.

func (*Iterator[K, V]) Next

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

Next moves the iterator to the next element and returns true if there was a next element in the container.

func (*Iterator[K, V]) Prev

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

Prev moves the iterator to the previous element and returns true if there was a previous element in the container.

func (*Iterator[K, V]) Value

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

Value returns the current element of the iterator.

type Map

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

Map is a hash table that uses a linked list for collision resolution. LinkedHashMap keeps a doubly-linked list of all entries in the map.

func Map_

func Map_[K comparable, V1 any, V2 any](m *Map[K, V1], f func(k K, v V1) V2) *Map[K, V2]

Map returns a new container with the results of applying the given function to each element in this container.

func New

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

New returns a new hash table.

func (*Map[K, V]) All

func (m *Map[K, V]) All(f func(k K, v V) bool) bool

All passes each element of the container to the given function and returns true if the function returns true for all elements.

func (*Map[K, V]) Any

func (m *Map[K, V]) Any(f func(k K, v V) bool) bool

Any passes each element of the container to the given function and returns true if the function ever returns true for any element.

func (*Map[K, V]) Clear

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

Clear removes all key-value pairs from the map.

func (*Map[K, V]) Each

func (m *Map[K, V]) Each(f func(k K, v V))

Each calls the given function for each element.

func (*Map[K, V]) Empty

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

Empty returns true if the map is empty.

func (*Map[K, V]) Filter

func (m *Map[K, V]) Filter(f func(k K, v V) bool) *Map[K, V]

Filter returns a new container with all elements that the given predicate returns true for.

func (*Map[K, V]) Find

func (m *Map[K, V]) Find(f func(k K, v V) bool) (_ K, _ V)

Find returns the first value that the given predicate returns true for. If none matches, then ok is false.

func (*Map[K, V]) FromJSON

func (m *Map[K, V]) FromJSON(data []byte) error

FromJSON populates map from the input JSON representation.

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(key K) (value V, ok bool)

Get returns the value for the given key.

func (*Map[K, V]) Iterator

func (m *Map[K, V]) Iterator() *Iterator[K, V]

Iterator returns a new iterator for the map.

func (*Map[K, V]) Keys

func (m *Map[K, V]) Keys() []K

Keys returns all keys in the map.

func (*Map[K, V]) Put

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

Put adds a new key-value pair to the map.

func (*Map[K, V]) Remove

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

Remove removes the key-value pair with the given key.

func (*Map[K, V]) Size

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

Size returns the number of elements in the map.

func (*Map[K, V]) String

func (m *Map[K, V]) String() string

String returns a string representation of the map.

func (*Map[K, V]) ToJSON

func (m *Map[K, V]) ToJSON() ([]byte, error)

ToJSON outputs the JSON representation of map.

func (*Map[K, V]) Values

func (m *Map[K, V]) Values() []V

Values returns all values in the map.

Jump to

Keyboard shortcuts

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