Help us shape the future of Go! Take the 2026 Go Developer Survey

concurrent

package module
v0.0.0-...-f508350 Latest Latest
Warning

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

Go to latest
Published: May 23, 2018 License: GPL-3.0 Imports: 6 Imported by: 0

README

go-concurrent

Concurrent Map and SkipList for Go

Documentation

Index

Constants

View Source
const (
	DEFAULT_INITIAL_CAPACITY  = 16
	DEFAULT_LOAD_FACTOR       = 0.75
	DEFAULT_CONCURRENCY_LEVEL = 16
	MAXIMUM_CAPACITY          = 1 << 30
	MAX_SEGMENTS              = 1 << 16
	RETRIES_BEFORE_LOCK       = 2
)
View Source
const (
	MAX_LEVEL = 12

	//for random
	M uint32 = 2147483647
	A uint64 = 16807
)

Variables

This section is empty.

Functions

func BKDRHash

func BKDRHash(str string) int32

func Gen_ID

func Gen_ID(str string) int32

func GetCrc16

func GetCrc16(pdata []byte) (fcs uint16)

计算给定长度数据的 16 位 CRC。

func MurmurHash3_32

func MurmurHash3_32(key []byte, seed uint32) uint32

func MurmurHash64A

func MurmurHash64A(key []byte, seed uint64) uint64

str64key 低碰撞率

func WJhash

func WJhash(h int32) int32

Types

type CStrKey

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

func NewCStrKey

func NewCStrKey(k string) *CStrKey

func (*CStrKey) Equals

func (self *CStrKey) Equals(o interface{}) bool

func (*CStrKey) GetValue

func (self *CStrKey) GetValue() string

func (*CStrKey) HashCode

func (self *CStrKey) HashCode() uint64

func (*CStrKey) Init

func (self *CStrKey) Init(k string)

func (*CStrKey) Less

func (self *CStrKey) Less(o interface{}) bool

type ConcurrentHashMap

type ConcurrentHashMap struct {
	Segments []*Segment
	// contains filtered or unexported fields
}

func NewConcurrentHashMap

func NewConcurrentHashMap(initialCapacity int32) *ConcurrentHashMap

func (*ConcurrentHashMap) Get

func (self *ConcurrentHashMap) Get(key KeyFace) (value interface{}, err error)

func (*ConcurrentHashMap) Init

func (self *ConcurrentHashMap) Init(initialCapacity int32, loadFactor float64, concurrencyLevel int32)

func (*ConcurrentHashMap) Len

func (self *ConcurrentHashMap) Len() int

func (*ConcurrentHashMap) NewConcurrentHashMapIterator

func (self *ConcurrentHashMap) NewConcurrentHashMapIterator() Iterator

func (*ConcurrentHashMap) Put

func (self *ConcurrentHashMap) Put(key KeyFace, value interface{}) (old_value interface{}, err error)

func (*ConcurrentHashMap) Remove

func (self *ConcurrentHashMap) Remove(key KeyFace) (value interface{}, err error)

func (*ConcurrentHashMap) Size

func (self *ConcurrentHashMap) Size() int

type ConcurrentHashMapIterator

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

func (*ConcurrentHashMapIterator) HasNext

func (self *ConcurrentHashMapIterator) HasNext() bool

func (*ConcurrentHashMapIterator) Next

func (self *ConcurrentHashMapIterator) Next() *Entry

type ConcurrentSkipList

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

func NewConcurrentSkipList

func NewConcurrentSkipList() *ConcurrentSkipList

func (*ConcurrentSkipList) Clear

func (self *ConcurrentSkipList) Clear()

func (*ConcurrentSkipList) Get

func (self *ConcurrentSkipList) Get(key KeyFace) (value interface{}, err error)

func (*ConcurrentSkipList) GetFirst

func (self *ConcurrentSkipList) GetFirst() (entry *Entry)

func (*ConcurrentSkipList) GetLast

func (self *ConcurrentSkipList) GetLast() (entry *Entry)

func (*ConcurrentSkipList) GetNext

func (self *ConcurrentSkipList) GetNext(key KeyFace) (value interface{}, err error)

func (*ConcurrentSkipList) GetPrev

func (self *ConcurrentSkipList) GetPrev(key KeyFace) (value interface{}, err error)

func (*ConcurrentSkipList) Init

func (self *ConcurrentSkipList) Init()

func (*ConcurrentSkipList) InitWithLevel

func (self *ConcurrentSkipList) InitWithLevel(lv int)

func (*ConcurrentSkipList) Len

func (self *ConcurrentSkipList) Len() int32

func (*ConcurrentSkipList) Level

func (self *ConcurrentSkipList) Level() int

func (*ConcurrentSkipList) NewConnSkipListIterator

func (self *ConcurrentSkipList) NewConnSkipListIterator() Iterator

func (*ConcurrentSkipList) Put

func (self *ConcurrentSkipList) Put(key KeyFace, value interface{}) (old_value interface{}, err error)

func (*ConcurrentSkipList) Remove

func (self *ConcurrentSkipList) Remove(key KeyFace) (value interface{}, err error)

func (*ConcurrentSkipList) Seek

func (self *ConcurrentSkipList) Seek(key KeyFace) Iterator

func (*ConcurrentSkipList) UnsafePut

func (self *ConcurrentSkipList) UnsafePut(key KeyFace, value interface{}) (old_value interface{}, err error)

func (*ConcurrentSkipList) UnsafeRemove

func (self *ConcurrentSkipList) UnsafeRemove(key KeyFace) (value interface{}, err error)

type ConnSkipListIterator

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

func (*ConnSkipListIterator) HasNext

func (self *ConnSkipListIterator) HasNext() bool

func (*ConnSkipListIterator) Next

func (self *ConnSkipListIterator) Next() (entry *Entry)

type Entry

type Entry struct {
	Key   KeyFace
	Value interface{}
}

type Float32Key

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

float32key

func NewFloat32Key

func NewFloat32Key(k float32) *Float32Key

func (*Float32Key) Equals

func (self *Float32Key) Equals(o interface{}) bool

func (*Float32Key) GetValue

func (self *Float32Key) GetValue() float32

func (*Float32Key) HashCode

func (self *Float32Key) HashCode() uint64

func (*Float32Key) Init

func (self *Float32Key) Init(k float32)

func (*Float32Key) Less

func (self *Float32Key) Less(o interface{}) bool

type Int32Key

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

int32key

func NewInt32Key

func NewInt32Key(k int32) *Int32Key

func (*Int32Key) Equals

func (self *Int32Key) Equals(o interface{}) bool

func (*Int32Key) GetValue

func (self *Int32Key) GetValue() int32

func (*Int32Key) HashCode

func (self *Int32Key) HashCode() uint64

func (*Int32Key) Init

func (self *Int32Key) Init(k int32)

func (*Int32Key) Less

func (self *Int32Key) Less(o interface{}) bool

type Int64Key

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

int64key

func NewInt64Key

func NewInt64Key(k int64) *Int64Key

func (*Int64Key) Equals

func (self *Int64Key) Equals(o interface{}) bool

func (*Int64Key) GetValue

func (self *Int64Key) GetValue() int64

func (*Int64Key) HashCode

func (self *Int64Key) HashCode() uint64

func (*Int64Key) Init

func (self *Int64Key) Init(k int64)

func (*Int64Key) Less

func (self *Int64Key) Less(o interface{}) bool

type Iterator

type Iterator interface {
	HasNext() bool
	Next() *Entry
}

type KeyFace

type KeyFace interface {
	HashCode() uint64
	Equals(o interface{}) bool
	Less(o interface{}) bool
}

type Mutex

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

spinlock

func (*Mutex) Lock

func (m *Mutex) Lock()

func (*Mutex) MeanLock

func (m *Mutex) MeanLock()

func (*Mutex) TryLock

func (m *Mutex) TryLock() bool

func (*Mutex) Unlock

func (m *Mutex) Unlock()

type Random

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

func NewRandom

func NewRandom(s uint32) *Random

func (*Random) Init

func (self *Random) Init(s uint32)

func (*Random) Next

func (self *Random) Next() uint32

type Segment

type Segment struct {
	Elements []*ConcurrentSkipList
	// contains filtered or unexported fields
}

func NewSegment

func NewSegment(initialCapacity int32, lf float64) *Segment

func (*Segment) GetCount

func (self *Segment) GetCount() int

func (*Segment) SegGet

func (self *Segment) SegGet(key KeyFace, hashv int32) (value interface{}, err error)

func (*Segment) SegPut

func (self *Segment) SegPut(key KeyFace, hashv int32, value interface{}) (old_value interface{}, err error)

func (*Segment) SegRemove

func (self *Segment) SegRemove(key KeyFace, hashv int32) (old_value interface{}, err error)

type Str16Key

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

func NewStr16Key

func NewStr16Key(k string) *Str16Key

func (*Str16Key) Equals

func (self *Str16Key) Equals(o interface{}) bool

func (*Str16Key) GetValue

func (self *Str16Key) GetValue() string

func (*Str16Key) HashCode

func (self *Str16Key) HashCode() uint64

func (*Str16Key) Init

func (self *Str16Key) Init(k string)

func (*Str16Key) Less

func (self *Str16Key) Less(o interface{}) bool

type Str64Key

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

func NewStr64Key

func NewStr64Key(key string) *Str64Key

func (*Str64Key) Equals

func (self *Str64Key) Equals(o interface{}) bool

func (*Str64Key) GetValue

func (self *Str64Key) GetValue() string

func (*Str64Key) HashCode

func (self *Str64Key) HashCode() uint64

func (*Str64Key) Init

func (self *Str64Key) Init(key string)

func (*Str64Key) Less

func (self *Str64Key) Less(o interface{}) bool

type StrKey

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

func NewStrKey

func NewStrKey(k string) *StrKey

func (*StrKey) Equals

func (self *StrKey) Equals(o interface{}) bool

func (*StrKey) GetValue

func (self *StrKey) GetValue() string

func (*StrKey) HashCode

func (self *StrKey) HashCode() uint64

func (*StrKey) Init

func (self *StrKey) Init(k string)

func (*StrKey) Less

func (self *StrKey) Less(o interface{}) bool

Jump to

Keyboard shortcuts

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