Documentation
¶
Index ¶
- func KeyValueHasher[K comparable, V any](hasher hash.Hasher[K]) hash.Hasher[KeyValue[K, V]]
- func WithBucketAmount(amount uint64) options.Option[Options]
- func WithBucketFunction(calc func(capacity uint64) uint64) options.Option[Options]
- func WithBucketSize(size uint64) options.Option[Options]
- func WithCacheTarget[T any](target cpu.CacheKind) options.Option[Options]
- func WithItemLocks(pool *locks.Pool) options.Option[Options]
- func WithMaxBucketSize(size uint64) options.Option[Options]
- type Bucketted
- func (m *Bucketted[K, V]) Append(other collections.Rangeable[KeyValue[K, V]])
- func (m *Bucketted[K, V]) AppendParralel(other collections.ParralelRangeable[KeyValue[K, V]])
- func (m *Bucketted[K, V]) Get(key K) (KeyValue[K, V], bool)
- func (s *Bucketted[K, V]) GoString() string
- func (m *Bucketted[K, V]) Grow(new_capacity uint64)
- func (s *Bucketted[K, V]) KeyValues() iter.Seq2[K, V]
- func (s *Bucketted[K, V]) Keys() iter.Seq[K]
- func (s *Bucketted[K, V]) Range(yield func(item KeyValue[K, V]) bool)
- func (s *Bucketted[K, V]) RangeParralel(yield func(item KeyValue[K, V]) bool)
- func (s *Bucketted[K, V]) Read() iter.Seq[KeyValue[K, V]]
- func (m *Bucketted[K, V]) Set(key K, item V) bool
- func (s *Bucketted[K, V]) String() string
- func (s *Bucketted[K, V]) Values() iter.Seq[V]
- type Fixed
- type GrowableMap
- func (s *GrowableMap[K, V]) Find(item KeyValue[K, V]) (KeyValue[K, V], bool)
- func (s *GrowableMap[K, V]) GetOrAdd(key K, value V) (KeyValue[K, V], bool)
- func (s *GrowableMap[K, V]) GetOrAddKV(item KeyValue[K, V]) (KeyValue[K, V], bool)
- func (s *GrowableMap[K, V]) GoString() string
- func (s *GrowableMap[K, V]) NewKeyValue(key K, value V) KeyValue[K, V]
- func (s *GrowableMap[K, V]) Range(yield func(item KeyValue[K, V]) bool)
- func (s *GrowableMap[K, V]) Read() iter.Seq[KeyValue[K, V]]
- func (s *GrowableMap[K, V]) String() string
- func (s *GrowableMap[K, V]) UpdateOrAdd(key K, value V) bool
- func (s *GrowableMap[K, V]) UpdateOrAddKV(item KeyValue[K, V]) bool
- type KeyValue
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeyValueHasher ¶
KeyValueHasher creates a new hasher for KeyValue pairs using the provided hasher for the key type.
func WithBucketAmount ¶
WithBucketAmount sets the amount of buckets that the set will use
func WithBucketFunction ¶
WithBucketAmount sets the amount of buckets that the set will use
func WithBucketSize ¶
WithBucketSize sets the size of buckets that the set will use
func WithCacheTarget ¶
WithCacheTarget sets the cache target for the set
func WithItemLocks ¶
WithItemLocks sets the locks that the set will use
Types ¶
type Bucketted ¶
type Bucketted[K, V comparable] struct { // contains filtered or unexported fields }
BuckettedSet is a set of items, that uses a pre-defined amount of buckets, each item generates an hash, from which a bucket can be specified
func NewBuckettedMap ¶
func NewBuckettedMap[K, V comparable](capacity uint64, keyhasher hash.Hasher[K], opts ...options.Option[Options]) (*Bucketted[K, V], error)
NewBuckettedMap creates a new Bucketted with the specified capacity, hasher, and options. The Bucketted is a concurrent map that uses a bucketing strategy to reduce contention.
func (*Bucketted[K, V]) Append ¶
func (m *Bucketted[K, V]) Append(other collections.Rangeable[KeyValue[K, V]])
Append adds all items from the specified Rangeable to the Bucketted.
func (*Bucketted[K, V]) AppendParralel ¶
func (m *Bucketted[K, V]) AppendParralel(other collections.ParralelRangeable[KeyValue[K, V]])
AppendParralel adds all items from the specified ParralelRangeable to the Bucketted.
func (*Bucketted[K, V]) RangeParralel ¶
RangeParralel will iterate over all items in the set in parallel
type Fixed ¶
type Fixed[K, V comparable] struct { // contains filtered or unexported fields }
Fixed is a fixed size slice, that can be used to store a fixed amount of items
func NewFixed ¶
func NewFixed[K, V comparable](amount uint64) Fixed[K, V]
type GrowableMap ¶
type GrowableMap[K, V comparable] struct { Options // contains filtered or unexported fields }
GrowableMap is a set that grows as needed.
func NewGrowableMap ¶
func NewGrowableMap[K, V comparable](hasher hash.Hasher[K], opts ...options.Option[Options]) (*GrowableMap[K, V], error)
NewGrowableMap creates a new instance of GrowableMap with the provided hasher and options. The hasher is used to hash the elements in the set, and options can be used to configure the set.
func NewGrowableMapFrom ¶
func NewGrowableMapFrom[K, V comparable](hasher hash.Hasher[K], base Options) (*GrowableMap[K, V], error)
func (*GrowableMap[K, V]) Find ¶
func (s *GrowableMap[K, V]) Find(item KeyValue[K, V]) (KeyValue[K, V], bool)
func (*GrowableMap[K, V]) GetOrAdd ¶
func (s *GrowableMap[K, V]) GetOrAdd(key K, value V) (KeyValue[K, V], bool)
GetOrAdd returns the item if it exists in the set, otherwise it adds it and returns it.
func (*GrowableMap[K, V]) GetOrAddKV ¶
func (s *GrowableMap[K, V]) GetOrAddKV(item KeyValue[K, V]) (KeyValue[K, V], bool)
GetOrAdd returns the item if it exists in the set, otherwise it adds it and returns it.
func (*GrowableMap[K, V]) GoString ¶
func (s *GrowableMap[K, V]) GoString() string
func (*GrowableMap[K, V]) NewKeyValue ¶
func (s *GrowableMap[K, V]) NewKeyValue(key K, value V) KeyValue[K, V]
func (*GrowableMap[K, V]) Range ¶
func (s *GrowableMap[K, V]) Range(yield func(item KeyValue[K, V]) bool)
Range calls the yield function for each item in the set.
func (*GrowableMap[K, V]) Read ¶
func (s *GrowableMap[K, V]) Read() iter.Seq[KeyValue[K, V]]
Read returns an iterator that reads the items in the set.
func (*GrowableMap[K, V]) String ¶
func (s *GrowableMap[K, V]) String() string
func (*GrowableMap[K, V]) UpdateOrAdd ¶
func (s *GrowableMap[K, V]) UpdateOrAdd(key K, value V) bool
UpdateOrAdd updates the item if it exists in the set, otherwise it adds it. Returns true if it had to add it instead of update.
func (*GrowableMap[K, V]) UpdateOrAddKV ¶
func (s *GrowableMap[K, V]) UpdateOrAddKV(item KeyValue[K, V]) bool
UpdateOrAdd updates the item if it exists in the set, otherwise it adds it. Returns true if it had to add it instead of update.
type KeyValue ¶
type KeyValue[K comparable, V any] struct { Hash uint64 // The hash of the key marked for empty checks. See [hashmark.MarkedHash] Key K Value V }
func EmptyKeyValue ¶
func EmptyKeyValue[K comparable, V any]() KeyValue[K, V]
EmptyKeyValue creates a new KeyValue instance with empty key and value.
func NewKey ¶
func NewKey[K comparable, V any](hash uint64, key K) KeyValue[K, V]
NewKey creates a new KeyValue instance with the given key.
func NewKeyValue ¶
func NewKeyValue[K comparable, V any](hash uint64, key K, value V) KeyValue[K, V]
NewKeyValue creates a new KeyValue instance with the given key and value.
func (KeyValue[K, V]) GetKey ¶
func (kv KeyValue[K, V]) GetKey() K
Key returns the key of the KeyValue pair.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options is the base struct for all sets.
func CreateOptions ¶
CreateOptions creates a new instance of SetBase with the default bucket size.