maps

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketSortedMap

type BucketSortedMap struct {
	// contains filtered or unexported fields
}

BucketSortedMap is

func NewBucketSortedMap

func NewBucketSortedMap(nChunks uint32, nScoreChunks uint32) *BucketSortedMap

NewBucketSortedMap creates a new map.

func (*BucketSortedMap) ChunksCounts

func (sortedMap *BucketSortedMap) ChunksCounts() []uint32

ChunksCounts returns the number of elements by chunk

func (*BucketSortedMap) Clear

func (sortedMap *BucketSortedMap) Clear()

Clear clears the map

func (*BucketSortedMap) Count

func (sortedMap *BucketSortedMap) Count() uint32

Count returns the number of elements within the map

func (*BucketSortedMap) CountSorted

func (sortedMap *BucketSortedMap) CountSorted() uint32

CountSorted returns the number of sorted elements within the map

func (*BucketSortedMap) Get

func (sortedMap *BucketSortedMap) Get(key string) (BucketSortedMapItem, bool)

Get retrieves an element from map under given key.

func (*BucketSortedMap) GetSnapshotAscending

func (sortedMap *BucketSortedMap) GetSnapshotAscending() []BucketSortedMapItem

GetSnapshotAscending gets a snapshot of the items

func (*BucketSortedMap) GetSnapshotDescending

func (sortedMap *BucketSortedMap) GetSnapshotDescending() []BucketSortedMapItem

GetSnapshotDescending gets a snapshot of the items

func (*BucketSortedMap) Has

func (sortedMap *BucketSortedMap) Has(key string) bool

Has looks up an item under specified key

func (*BucketSortedMap) IterCbSortedAscending

func (sortedMap *BucketSortedMap) IterCbSortedAscending(callback SortedMapIterCb)

IterCbSortedAscending iterates over the sorted elements in the map

func (*BucketSortedMap) IterCbSortedDescending

func (sortedMap *BucketSortedMap) IterCbSortedDescending(callback SortedMapIterCb)

IterCbSortedDescending iterates over the sorted elements in the map

func (*BucketSortedMap) Keys

func (sortedMap *BucketSortedMap) Keys() []string

Keys returns all keys as []string

func (*BucketSortedMap) KeysSorted

func (sortedMap *BucketSortedMap) KeysSorted() []string

KeysSorted returns all keys of the sorted items as []string

func (*BucketSortedMap) NotifyScoreChange

func (sortedMap *BucketSortedMap) NotifyScoreChange(item BucketSortedMapItem, newScore uint32)

NotifyScoreChange moves or adds the item to the corresponding score chunk

func (*BucketSortedMap) Remove

func (sortedMap *BucketSortedMap) Remove(key string) (interface{}, bool)

Remove removes an element from the map

func (*BucketSortedMap) ScoreChunksCounts

func (sortedMap *BucketSortedMap) ScoreChunksCounts() []uint32

ScoreChunksCounts returns the number of elements by chunk

func (*BucketSortedMap) Set

func (sortedMap *BucketSortedMap) Set(item BucketSortedMapItem)

Set puts the item in the map This doesn't add the item to the score chunks (not necessary)

type BucketSortedMapItem

type BucketSortedMapItem interface {
	GetKey() string
	GetScoreChunk() *MapChunk
	SetScoreChunk(*MapChunk)
}

BucketSortedMapItem defines an item of the bucket sorted map

type ConcurrentMap

type ConcurrentMap struct {
	// contains filtered or unexported fields
}

ConcurrentMap is a thread safe map of type string:Anything. To avoid lock bottlenecks this map is divided to several map chunks.

func NewConcurrentMap

func NewConcurrentMap(nChunks uint32) *ConcurrentMap

NewConcurrentMap creates a new concurrent map.

func (*ConcurrentMap) Clear

func (m *ConcurrentMap) Clear()

Clear clears the map

func (*ConcurrentMap) Count

func (m *ConcurrentMap) Count() int

Count returns the number of elements within the map

func (*ConcurrentMap) Get

func (m *ConcurrentMap) Get(key string) (interface{}, bool)

Get retrieves an element from map under given key.

func (*ConcurrentMap) Has

func (m *ConcurrentMap) Has(key string) bool

Has looks up an item under specified key.

func (*ConcurrentMap) IterCb

func (m *ConcurrentMap) IterCb(fn IterCb)

IterCb iterates over the map (cheapest way to read all elements in a map)

func (*ConcurrentMap) Keys

func (m *ConcurrentMap) Keys() []string

Keys returns all keys as []string

func (*ConcurrentMap) Remove

func (m *ConcurrentMap) Remove(key string) (interface{}, bool)

Remove removes an element from the map.

func (*ConcurrentMap) Set

func (m *ConcurrentMap) Set(key string, value interface{})

Set sets the given value under the specified key.

func (*ConcurrentMap) SetIfAbsent

func (m *ConcurrentMap) SetIfAbsent(key string, value interface{}) bool

SetIfAbsent sets the given value under the specified key if no value was associated with it.

type IterCb

type IterCb func(key string, v interface{})

IterCb is an iterator callback

type MapChunk

type MapChunk struct {
	// contains filtered or unexported fields
}

MapChunk is

type SortedMapIterCb

type SortedMapIterCb func(key string, value BucketSortedMapItem)

SortedMapIterCb is an iterator callback

Jump to

Keyboard shortcuts

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