Documentation
¶
Overview ¶
Package xsync provides a data structure that allows for concurrent access and modification.
Index ¶
- type MultiMap
- func (m *MultiMap[T]) AddIndex(key string, indexName string, indexValue string)
- func (m *MultiMap[T]) AddIndexByAnotherIndex(indexName string, indexValue string, anotherIndexName string, ...)
- func (m *MultiMap[T]) Delete(key string)
- func (m *MultiMap[T]) DeleteByIndex(indexName string, indexValue string)
- func (m *MultiMap[T]) Indexes(indexName string) []string
- func (m *MultiMap[T]) KeyByIndex(indexName string, indexValue string) (string, bool)
- func (m *MultiMap[T]) KeyValues() map[string]T
- func (m *MultiMap[T]) Keys() []string
- func (m *MultiMap[T]) Len() int
- func (m *MultiMap[T]) Load(key string) (T, bool)
- func (m *MultiMap[T]) LoadByIndex(indexName string, indexValue string) (T, bool)
- func (m *MultiMap[T]) Store(key string, value T, opts ...StoreOption)
- func (m *MultiMap[T]) Values() []T
- type StoreOption
- type WithIndexImpl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MultiMap ¶
type MultiMap[T any] struct { // contains filtered or unexported fields }
MultiMap is a map that allows multiple keys to point to the same value. It is thread-safe and can be used in concurrent environments. It is not serializable.
func NewMultiMap ¶
NewMultiMap creates a new instance of MultiMap.
func (*MultiMap[T]) AddIndex ¶
AddIndex adds an index to the map for the given key. It allows multiple indexes to be associated with the same key.
func (*MultiMap[T]) AddIndexByAnotherIndex ¶
func (m *MultiMap[T]) AddIndexByAnotherIndex( indexName string, indexValue string, anotherIndexName string, anotherIndexValue string, )
AddIndexByAnotherIndex adds an index to the map for the given index.
func (*MultiMap[T]) DeleteByIndex ¶
DeleteByIndex removes the value from the map with the given index key.
func (*MultiMap[T]) KeyByIndex ¶
KeyByIndex retrieves the key from the map with the given index key.
func (*MultiMap[T]) Load ¶
Load retrieves the value from the map with the given key. It returns the value and a boolean indicating whether the value was found.
func (*MultiMap[T]) LoadByIndex ¶
LoadByIndex retrieves the value from the map with the given index key. It returns the value and a boolean indicating whether the value was found.
func (*MultiMap[T]) Store ¶
func (m *MultiMap[T]) Store(key string, value T, opts ...StoreOption)
Store stores the value in the map with the given key. It overwrites the existing value if the key already exists.
type StoreOption ¶
type StoreOption interface {
// contains filtered or unexported methods
}
StoreOption is an interface for options that can be passed to the Store method.
type WithIndexImpl ¶
type WithIndexImpl struct {
// contains filtered or unexported fields
}
WithIndexImpl is an implementation of StoreOption for index options.
func WithIndex ¶
func WithIndex(indexName, indexValue string) *WithIndexImpl
WithIndex creates a index option for the Store method.