dict

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equals

func Equals[K any, V comparable](l Dict[K, V], r Dict[K, V]) bool

func HashDictCollector

func HashDictCollector[K comparable, V any]() iter.Collector[*HashDict[K, V], util.Pair[K, V], *HashDict[K, V]]

Types

type Dict

type Dict[K any, V any] interface {
	iter.Collection[util.Pair[K, V]]

	Contains(key K) bool
	At(key K) util.Ref[V]
	Put(key K, value V) util.Opt[V]
	Remove(key K) util.Opt[V]
	Clear()
}

Collection's extended interfaces, can provide more functional abstraction for maps.

type HashDict

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

func HashDictFrom

func HashDictFrom[K comparable, V any](collection iter.Collection[util.Pair[K, V]]) *HashDict[K, V]

func HashDictOf

func HashDictOf[K comparable, V any](elements ...util.Pair[K, V]) *HashDict[K, V]

func MakeHashDict

func MakeHashDict[K comparable, V any](capacity int) *HashDict[K, V]

func MakeHashDictWithHasher

func MakeHashDictWithHasher[K comparable, V any](hasher func(K) uint64, capacity int) *HashDict[K, V]

func (*HashDict[K, V]) At

func (a *HashDict[K, V]) At(key K) util.Ref[V]

func (*HashDict[K, V]) Clear

func (a *HashDict[K, V]) Clear()

func (*HashDict[K, V]) Clone

func (a *HashDict[K, V]) Clone() *HashDict[K, V]

func (*HashDict[K, V]) Contains

func (a *HashDict[K, V]) Contains(key K) bool

func (*HashDict[K, V]) Count

func (a *HashDict[K, V]) Count() int

func (*HashDict[K, V]) Iterator

func (a *HashDict[K, V]) Iterator() iter.Iterator[util.Pair[K, V]]

func (*HashDict[K, V]) Put

func (a *HashDict[K, V]) Put(key K, value V) util.Opt[V]

func (*HashDict[K, V]) Remove

func (a *HashDict[K, V]) Remove(key K) util.Opt[V]

Jump to

Keyboard shortcuts

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