dict

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrentHashDictionary deprecated

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

ConcurrentHashDictionary is the thread-safe hash dictionary implementation.

Deprecated: Use SyncDict instead.

func NewConcurrentHashDictionary deprecated

func NewConcurrentHashDictionary[K comparable, V any]() *ConcurrentHashDictionary[K, V]

NewConcurrentHashDictionary creates a new ConcurrentHashDictionary.

Deprecated: Use NewSyncDict instead.

func (*ConcurrentHashDictionary[K, V]) Clear

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

Clear removes all key-value pairs in this dictionary.

func (*ConcurrentHashDictionary[K, V]) Clone

func (m *ConcurrentHashDictionary[K, V]) Clone() collection.Dict[K, V]

Clone returns a copy of this dictionary.

func (*ConcurrentHashDictionary[K, V]) ContainsKey

func (m *ConcurrentHashDictionary[K, V]) ContainsKey(k K) bool

ContainsKey returns true if this dictionary contains a key-value pair with the specified key.

func (*ConcurrentHashDictionary[K, V]) Equals

func (m *ConcurrentHashDictionary[K, V]) Equals(o any) bool

Equals compares this dictionary with the object pass from parameter.

func (*ConcurrentHashDictionary[K, V]) ForEach

func (m *ConcurrentHashDictionary[K, V]) ForEach(handler func(K, V) error) error

ForEach performs the given handler for each key-value pairs in the dictionary until all pairs have been processed or the handler returns an error.

func (*ConcurrentHashDictionary[K, V]) Get

func (m *ConcurrentHashDictionary[K, V]) Get(k K) (V, bool)

Get returns the value which associated to the specified key.

func (*ConcurrentHashDictionary[K, V]) GetDefault

func (m *ConcurrentHashDictionary[K, V]) GetDefault(k K, defaultVal V) V

GetDefault returns the value associated with the specified key, and returns the default value if this dictionary contains no pair with the key.

func (*ConcurrentHashDictionary[K, V]) IsEmpty

func (m *ConcurrentHashDictionary[K, V]) IsEmpty() bool

IsEmpty returns true if this dictionary is empty.

func (*ConcurrentHashDictionary[K, V]) Iter added in v0.3.0

func (m *ConcurrentHashDictionary[K, V]) Iter() iter.Seq2[K, V]

Iter returns an iterator of all elements in this dictionary.

func (*ConcurrentHashDictionary[K, V]) Keys

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

Keys returns a slice that contains all the keys in this dictionary.

func (*ConcurrentHashDictionary[K, V]) Put

func (m *ConcurrentHashDictionary[K, V]) Put(k K, v V) V

Put associate the specified value with the specified key in this dictionary.

func (*ConcurrentHashDictionary[K, V]) Remove

func (m *ConcurrentHashDictionary[K, V]) Remove(k K) V

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

func (*ConcurrentHashDictionary[K, V]) Replace

func (m *ConcurrentHashDictionary[K, V]) Replace(k K, v V) (V, bool)

Replace replaces the value for the specified key only if it is currently in this dictionary.

func (*ConcurrentHashDictionary[K, V]) Size

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

Size returns the number of key-value pairs in this dictionary.

func (*ConcurrentHashDictionary[K, V]) Values

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

Values returns a slice that contains all the values in this dictionary.

type HashDict added in v0.3.0

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

HashDict is a Golang builtin map wrapper.

func NewHashDict added in v0.3.0

func NewHashDict[K comparable, V any]() *HashDict[K, V]

NewHashDict creates a new HashDict.

func (*HashDict[K, V]) Clear added in v0.3.0

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

Clear removes all key-value pairs in this dictionary.

func (*HashDict[K, V]) Clone added in v0.3.0

func (m *HashDict[K, V]) Clone() collection.Dict[K, V]

Clone returns a copy of this dictionary.

func (*HashDict[K, V]) ContainsKey added in v0.3.0

func (m *HashDict[K, V]) ContainsKey(k K) bool

ContainsKey returns true if this dictionary contains a key-value pair with the specified key.

func (*HashDict[K, V]) Equals added in v0.3.0

func (m *HashDict[K, V]) Equals(o any) bool

Equals compares this dictionary with the object pass from parameter.

func (*HashDict[K, V]) ForEach added in v0.3.0

func (m *HashDict[K, V]) ForEach(handler func(K, V) error) error

ForEach performs the given handler for each key-value pairs in the dictionary until all pairs have been processed or the handler returns an error.

func (*HashDict[K, V]) Get added in v0.3.0

func (m *HashDict[K, V]) Get(k K) (V, bool)

Get returns the value which associated to the specified key.

func (*HashDict[K, V]) GetDefault added in v0.3.0

func (m *HashDict[K, V]) GetDefault(k K, defaultVal V) V

GetDefault returns the value associated with the specified key, and returns the default value if this dictionary contains no pair with the key.

func (*HashDict[K, V]) IsEmpty added in v0.3.0

func (m *HashDict[K, V]) IsEmpty() bool

IsEmpty returns true if this dictionary is empty.

func (*HashDict[K, V]) Iter added in v0.3.0

func (m *HashDict[K, V]) Iter() iter.Seq2[K, V]

Iter returns an iterator of all elements in this dictionary.

func (*HashDict[K, V]) Keys added in v0.3.0

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

Keys returns a slice that contains all the keys in this dictionary.

func (*HashDict[K, V]) Put added in v0.3.0

func (m *HashDict[K, V]) Put(k K, v V) V

Put associate the specified value with the specified key in this dictionary.

func (*HashDict[K, V]) Remove added in v0.3.0

func (m *HashDict[K, V]) Remove(k K) V

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

func (*HashDict[K, V]) Replace added in v0.3.0

func (m *HashDict[K, V]) Replace(k K, v V) (V, bool)

Replace replaces the value for the specified key only if it is currently in this dictionary.

func (*HashDict[K, V]) Size added in v0.3.0

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

Size returns the number of key-value pairs in this dictionary.

func (*HashDict[K, V]) Values added in v0.3.0

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

Values returns a slice that contains all the values in this dictionary.

type HashDictionary deprecated

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

HashDictionary is a Golang builtin map wrapper.

Deprecated: Use HashDict instead

func NewHashDictionary deprecated

func NewHashDictionary[K comparable, V any]() *HashDictionary[K, V]

NewHashDictionary creates a new HashDictionary.

Deprecated: Use NewHashDict instead.

func (*HashDictionary[K, V]) Clear

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

Clear removes all key-value pairs in this dictionary.

func (*HashDictionary[K, V]) Clone

func (m *HashDictionary[K, V]) Clone() collection.Dict[K, V]

Clone returns a copy of this dictionary.

func (*HashDictionary[K, V]) ContainsKey

func (m *HashDictionary[K, V]) ContainsKey(k K) bool

ContainsKey returns true if this dictionary contains a key-value pair with the specified key.

func (*HashDictionary[K, V]) Equals

func (m *HashDictionary[K, V]) Equals(o any) bool

Equals compares this dictionary with the object pass from parameter.

func (*HashDictionary[K, V]) ForEach

func (m *HashDictionary[K, V]) ForEach(handler func(K, V) error) error

ForEach performs the given handler for each key-value pairs in the dictionary until all pairs have been processed or the handler returns an error.

func (*HashDictionary[K, V]) Get

func (m *HashDictionary[K, V]) Get(k K) (V, bool)

Get returns the value which associated to the specified key.

func (*HashDictionary[K, V]) GetDefault

func (m *HashDictionary[K, V]) GetDefault(k K, defaultVal V) V

GetDefault returns the value associated with the specified key, and returns the default value if this dictionary contains no pair with the key.

func (*HashDictionary[K, V]) IsEmpty

func (m *HashDictionary[K, V]) IsEmpty() bool

IsEmpty returns true if this dictionary is empty.

func (*HashDictionary[K, V]) Iter added in v0.3.0

func (m *HashDictionary[K, V]) Iter() iter.Seq2[K, V]

Iter returns an iterator of all elements in this dictionary.

func (*HashDictionary[K, V]) Keys

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

Keys returns a slice that contains all the keys in this dictionary.

func (*HashDictionary[K, V]) Put

func (m *HashDictionary[K, V]) Put(k K, v V) V

Put associate the specified value with the specified key in this dictionary.

func (*HashDictionary[K, V]) Remove

func (m *HashDictionary[K, V]) Remove(k K) V

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

func (*HashDictionary[K, V]) Replace

func (m *HashDictionary[K, V]) Replace(k K, v V) (V, bool)

Replace replaces the value for the specified key only if it is currently in this dictionary.

func (*HashDictionary[K, V]) Size

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

Size returns the number of key-value pairs in this dictionary.

func (*HashDictionary[K, V]) Values

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

Values returns a slice that contains all the values in this dictionary.

type SyncDict added in v0.3.0

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

SyncDict is a thread-safe map implementation based on sync.Map's algorithm.

func NewSyncDict added in v0.3.0

func NewSyncDict[K comparable, V any]() *SyncDict[K, V]

NewSyncDict creates a new SyncDict.

func (*SyncDict[K, V]) Clear added in v0.3.0

func (d *SyncDict[K, V]) Clear()

// Clear removes all key-value pairs in this dictionary.

func (*SyncDict[K, V]) Clone added in v0.3.0

func (d *SyncDict[K, V]) Clone() collection.Dict[K, V]

Clone returns a copy of this dictionary.

func (*SyncDict[K, V]) ContainsKey added in v0.3.0

func (d *SyncDict[K, V]) ContainsKey(key K) bool

ContainsKey returns true if this dictionary contains a key-value pair with the specified key.

func (*SyncDict[K, V]) Equals added in v0.3.0

func (d *SyncDict[K, V]) Equals(o any) bool

Equals compares this dictionary with the object pass from parameter.

func (*SyncDict[K, V]) ForEach added in v0.3.0

func (d *SyncDict[K, V]) ForEach(handler func(K, V) error) error

ForEach performs the given handler for each key-value pairs in the dictionary until all pairs have been processed or the handler returns an error.

func (*SyncDict[K, V]) Get added in v0.3.0

func (d *SyncDict[K, V]) Get(key K) (V, bool)

Get returns the value which associated to the specified key.

func (*SyncDict[K, V]) GetDefault added in v0.3.0

func (d *SyncDict[K, V]) GetDefault(key K, defaultVal V) V

GetDefault returns the value associated with the specified key, and returns the default value if this dictionary contains no pair with the key.

func (*SyncDict[K, V]) IsEmpty added in v0.3.0

func (d *SyncDict[K, V]) IsEmpty() bool

IsEmpty returns true if this dictionary is empty.

func (*SyncDict[K, V]) Iter added in v0.3.0

func (d *SyncDict[K, V]) Iter() iter.Seq2[K, V]

Iter returns an iterator of all elements in this dictionary.

func (*SyncDict[K, V]) Keys added in v0.3.0

func (d *SyncDict[K, V]) Keys() []K

Keys returns a slice that contains all the keys in this dictionary.

func (*SyncDict[K, V]) Put added in v0.3.0

func (d *SyncDict[K, V]) Put(key K, val V) V

Put associate the specified value with the specified key in this dictionary.

func (*SyncDict[K, V]) Remove added in v0.3.0

func (d *SyncDict[K, V]) Remove(key K) V

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

func (*SyncDict[K, V]) Replace added in v0.3.0

func (d *SyncDict[K, V]) Replace(key K, val V) (V, bool)

Replace replaces the value for the specified key only if it is currently in this dictionary.

func (*SyncDict[K, V]) Size added in v0.3.0

func (d *SyncDict[K, V]) Size() int

Size returns the number of key-value pairs in this dictionary.

func (*SyncDict[K, V]) Values added in v0.3.0

func (d *SyncDict[K, V]) Values() []V

Values returns a slice that contains all the values in this dictionary.

Jump to

Keyboard shortcuts

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