Documentation
¶
Index ¶
- type HashDict
- func (m *HashDict[K, V]) Clear()
- func (m *HashDict[K, V]) Clone() collection.Dict[K, V]
- func (m *HashDict[K, V]) ContainsKey(k K) bool
- func (m *HashDict[K, V]) Equals(o any) bool
- func (m *HashDict[K, V]) ForEach(handler func(K, V) error) error
- func (m *HashDict[K, V]) Get(k K) (V, bool)
- func (m *HashDict[K, V]) GetDefault(k K, defaultVal V) V
- func (m *HashDict[K, V]) IsEmpty() bool
- func (m *HashDict[K, V]) Iter() iter.Seq2[K, V]
- func (m *HashDict[K, V]) Keys() []K
- func (m *HashDict[K, V]) KeysIter() iter.Seq[K]
- func (m *HashDict[K, V]) MarshalJSON() ([]byte, error)
- func (m *HashDict[K, V]) Put(k K, v V) V
- func (m *HashDict[K, V]) Remove(k K) V
- func (m *HashDict[K, V]) Replace(k K, v V) (V, bool)
- func (m *HashDict[K, V]) Size() int
- func (m *HashDict[K, V]) String() string
- func (m *HashDict[K, V]) UnmarshalJSON(b []byte) error
- func (m *HashDict[K, V]) Values() []V
- func (m *HashDict[K, V]) ValuesIter() iter.Seq[V]
- type LockDict
- func (m *LockDict[K, V]) Clear()
- func (m *LockDict[K, V]) Clone() collection.Dict[K, V]
- func (m *LockDict[K, V]) ContainsKey(k K) bool
- func (m *LockDict[K, V]) Equals(o any) bool
- func (m *LockDict[K, V]) ForEach(handler func(K, V) error) error
- func (m *LockDict[K, V]) Get(k K) (V, bool)
- func (m *LockDict[K, V]) GetDefault(k K, defaultVal V) V
- func (m *LockDict[K, V]) IsEmpty() bool
- func (m *LockDict[K, V]) Iter() iter.Seq2[K, V]
- func (m *LockDict[K, V]) Keys() []K
- func (m *LockDict[K, V]) KeysIter() iter.Seq[K]
- func (m *LockDict[K, V]) MarshalJSON() ([]byte, error)
- func (m *LockDict[K, V]) Put(k K, v V) V
- func (m *LockDict[K, V]) Remove(k K) V
- func (m *LockDict[K, V]) Replace(k K, v V) (V, bool)
- func (m *LockDict[K, V]) Size() int
- func (m *LockDict[K, V]) String() string
- func (m *LockDict[K, V]) UnmarshalJSON(b []byte) error
- func (m *LockDict[K, V]) Values() []V
- func (m *LockDict[K, V]) ValuesIter() iter.Seq[V]
- type SyncDict
- func (d *SyncDict[K, V]) Clear()
- func (d *SyncDict[K, V]) Clone() collection.Dict[K, V]
- func (d *SyncDict[K, V]) ContainsKey(key K) bool
- func (d *SyncDict[K, V]) Equals(o any) bool
- func (d *SyncDict[K, V]) ForEach(handler func(K, V) error) error
- func (d *SyncDict[K, V]) Get(key K) (V, bool)
- func (d *SyncDict[K, V]) GetDefault(key K, defaultVal V) V
- func (d *SyncDict[K, V]) IsEmpty() bool
- func (d *SyncDict[K, V]) Iter() iter.Seq2[K, V]
- func (d *SyncDict[K, V]) Keys() []K
- func (d *SyncDict[K, V]) KeysIter() iter.Seq[K]
- func (d *SyncDict[K, V]) MarshalJSON() ([]byte, error)
- func (d *SyncDict[K, V]) Put(key K, val V) V
- func (d *SyncDict[K, V]) Remove(key K) V
- func (d *SyncDict[K, V]) Replace(key K, val V) (V, bool)
- func (d *SyncDict[K, V]) Size() int
- func (d *SyncDict[K, V]) String() string
- func (d *SyncDict[K, V]) UnmarshalJSON(b []byte) error
- func (d *SyncDict[K, V]) Values() []V
- func (d *SyncDict[K, V]) ValuesIter() iter.Seq[V]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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
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
Equals compares this dictionary with the object pass from parameter.
func (*HashDict[K, V]) ForEach ¶ added in v0.3.0
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
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]) Iter ¶ added in v0.3.0
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]) KeysIter ¶ added in v0.4.0
KeysIter returns an iterator of all keys in this dictionary.
func (*HashDict[K, V]) MarshalJSON ¶ added in v0.5.0
MarshalJSON marshals the HashDict as a JSON object (map).
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
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
Size returns the number of key-value pairs in this dictionary.
func (*HashDict[K, V]) String ¶ added in v0.5.0
String returns the string representation of this dictionary.
func (*HashDict[K, V]) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON unmarshals a JSON object into the HashDict.
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.
func (*HashDict[K, V]) ValuesIter ¶ added in v0.4.0
ValuesIter returns an iterator of all values in this dictionary.
type LockDict ¶ added in v0.5.0
type LockDict[K comparable, V any] struct { // contains filtered or unexported fields }
LockDict is a thread-safe dictionary using a read-write mutex.
func NewLockDict ¶ added in v0.5.0
func NewLockDict[K comparable, V any]() *LockDict[K, V]
NewLockDict creates a new LockDict.
func (*LockDict[K, V]) Clear ¶ added in v0.5.0
func (m *LockDict[K, V]) Clear()
Clear removes all key-value pairs in this dictionary.
func (*LockDict[K, V]) Clone ¶ added in v0.5.0
func (m *LockDict[K, V]) Clone() collection.Dict[K, V]
Clone returns a copy of this dictionary.
func (*LockDict[K, V]) ContainsKey ¶ added in v0.5.0
ContainsKey returns true if this dictionary contains a key-value pair with the specified key.
func (*LockDict[K, V]) Equals ¶ added in v0.5.0
Equals compares this dictionary with the object pass from parameter.
func (*LockDict[K, V]) ForEach ¶ added in v0.5.0
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 (*LockDict[K, V]) Get ¶ added in v0.5.0
Get returns the value which associated to the specified key.
func (*LockDict[K, V]) GetDefault ¶ added in v0.5.0
func (m *LockDict[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 (*LockDict[K, V]) Iter ¶ added in v0.5.0
Iter returns an iterator of all elements in this dictionary.
func (*LockDict[K, V]) Keys ¶ added in v0.5.0
func (m *LockDict[K, V]) Keys() []K
Keys returns a slice that contains all the keys in this dictionary.
func (*LockDict[K, V]) KeysIter ¶ added in v0.5.0
KeysIter returns an iterator of all keys in this dictionary.
func (*LockDict[K, V]) MarshalJSON ¶ added in v0.5.0
MarshalJSON marshals the HashDict as a JSON object (map).
func (*LockDict[K, V]) Put ¶ added in v0.5.0
func (m *LockDict[K, V]) Put(k K, v V) V
Put associate the specified value with the specified key in this dictionary.
func (*LockDict[K, V]) Remove ¶ added in v0.5.0
func (m *LockDict[K, V]) Remove(k K) V
Remove removes the key-value pair with the specified key.
func (*LockDict[K, V]) Replace ¶ added in v0.5.0
Replace replaces the value for the specified key only if it is currently in this dictionary.
func (*LockDict[K, V]) Size ¶ added in v0.5.0
Size returns the number of key-value pairs in this dictionary.
func (*LockDict[K, V]) String ¶ added in v0.5.0
String returns the string representation of this dictionary.
func (*LockDict[K, V]) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON unmarshals a JSON object into the HashDict.
func (*LockDict[K, V]) Values ¶ added in v0.5.0
func (m *LockDict[K, V]) Values() []V
Values returns a slice that contains all the values in this dictionary.
func (*LockDict[K, V]) ValuesIter ¶ added in v0.5.0
ValuesIter returns an iterator of all 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
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
Equals compares this dictionary with the object pass from parameter.
func (*SyncDict[K, V]) ForEach ¶ added in v0.3.0
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
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]) Iter ¶ added in v0.3.0
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]) KeysIter ¶ added in v0.4.0
KeysIter returns an iterator of all keys in this dictionary.
func (*SyncDict[K, V]) MarshalJSON ¶ added in v0.5.0
MarshalJSON marshals the SyncDict as a JSON object (map).
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
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
Size returns the number of key-value pairs in this dictionary.
func (*SyncDict[K, V]) String ¶ added in v0.5.0
String returns the string representation of this dictionary.
func (*SyncDict[K, V]) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON unmarshals a JSON object into the SyncDict.
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.
func (*SyncDict[K, V]) ValuesIter ¶ added in v0.4.0
ValuesIter returns an iterator of all values in this dictionary.