collections

package
v0.0.0-...-10117e9 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map interface {
	Get(key string) interface{}
	Put(key string, val interface{})
	Remove(key string)
	Size() int
	HasKey(key string) bool
	GetRand() interface{}
}

type ShardedMap

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

func NewShardedMap

func NewShardedMap(nShards int) *ShardedMap

NewShardedMap returns a map with {nShards} shards. {nShards} must be a power of 2

func (*ShardedMap) Get

func (sm *ShardedMap) Get(key string) interface{}

func (*ShardedMap) GetRand

func (sm *ShardedMap) GetRand() interface{}

func (*ShardedMap) HasKey

func (sm *ShardedMap) HasKey(key string) bool

func (*ShardedMap) Put

func (sm *ShardedMap) Put(key string, val interface{})

func (*ShardedMap) Remove

func (sm *ShardedMap) Remove(key string)

func (*ShardedMap) Size

func (sm *ShardedMap) Size() int

type SyncMap

type SyncMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSyncMap

func NewSyncMap() *SyncMap

func (*SyncMap) Get

func (sm *SyncMap) Get(key string) interface{}

func (*SyncMap) GetRand

func (sm *SyncMap) GetRand() interface{}

func (*SyncMap) HasKey

func (sm *SyncMap) HasKey(key string) bool

func (*SyncMap) Put

func (sm *SyncMap) Put(key string, val interface{})

func (*SyncMap) Remove

func (sm *SyncMap) Remove(key string)

func (*SyncMap) Size

func (sm *SyncMap) Size() int

type SyncStrSet

type SyncStrSet struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SyncStrSet is a collection of unique values

func NewSyncStrSet

func NewSyncStrSet() *SyncStrSet

NewSyncStrSet returns a new SyncStrSet

func (*SyncStrSet) Add

func (s *SyncStrSet) Add(vals ...string)

Add adds a value to the SyncStrSet

func (*SyncStrSet) Contains

func (s *SyncStrSet) Contains(vals ...string) bool

Contains returns true if the value is present in the SyncStrSet

func (*SyncStrSet) Get

func (s *SyncStrSet) Get() string

Get returns a random element of the set

func (*SyncStrSet) Intersect

func (s *SyncStrSet) Intersect(s2 *SyncStrSet) *SyncStrSet

Intersect returns the intersection of the two Sets

func (*SyncStrSet) Remove

func (s *SyncStrSet) Remove(x string)

Remove removes element x from the set

func (*SyncStrSet) Size

func (s *SyncStrSet) Size() int

Size returns the number of elements in the SyncStrSet

func (*SyncStrSet) Walk

func (s *SyncStrSet) Walk(walkFn func(item string))

Walk iterates over the set, executing walkFn in a goroutine.

Jump to

Keyboard shortcuts

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