Documentation ¶
Index ¶
Constants ¶
View Source
const (
MaxArrayLen uint = math.MaxInt
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ExtendedMap ¶
type ExtendedMap[K any, V any] interface { Map[K, V] //HasKey is a convenient alias for `_,x:=M.Load(K)` HasKey(K) bool Size() uint //Take an arbitrary key value pair from the Map. Take() (K, V) //Set is equivalent to Store(K,V) on a existing key, it won't do anything on a key that's not in the Map. In the prior case, it should be designed to be faster than Store. Set(K, V) *V }
ExtendedMap is the additional operation that my implementation support. Note that these operations aren't explicit implemented, meaning that they're merely taking advantage of the implementation. For example, values are internally stored as pointers in all implementations, so why not just provide a method to access the pointers directly?
type HashList ¶
type HashList[V any] struct { Array []V Chunk byte //HashAny range of the first segment is [0,2^chunk) }
HashList is a array with length 2^n
type Map ¶
type Map[K any, V any] interface { Delete(K) Load(K) (V, bool) LoadAndDelete(K) (V, bool) LoadOrStore(K, V) (V, bool) Range(func(K, V) bool) Store(K, V) }
Map is designed for compatibility with sync.Map. All the below functions have the exact same usage/behavior as documented in sync.Map.
type PtrMap ¶ added in v0.4.0
type PtrMap[K any, V any] interface { Map[K, V] //TakePtr is the pointer variant of Take. TakePtr(K, *V) //LoadPtr is the pointer variant of Map.Load. LoadPtr(K) *V //LoadPtrAndDelete is the pointer variant of Map.LoadAndDelete. LoadPtrAndDelete(K) (*V, bool) //LoadPtrOrStore is the pointer variant of Map.LoadOrStore. LoadPtrOrStore(K, V) (*V, bool) //RangePtr is the pointer variant of Map.Range. RangePtr(func(K, *V) bool) }
Click to show internal directories.
Click to hide internal directories.