Documentation
¶
Index ¶
- Constants
- func ByteSliceGetOrDefault(src []byte, defaultP *[]byte) *[]byte
- func CalculateShard(key string, numShards int) uint64
- func ConvertOrCopyGenericSlice[T any](src any) (dest []T)
- func CopyAnySliceToByteSlice(data []any) (conv [][]byte)
- func CopyByteSliceToAnySlice(data [][]byte) (conv []any)
- func CopySlice[T any](src []T) (dest []T)
- func DigitsOf32Bits(n int32) int
- func DigitsOf64Bits(n int64) (nDigits int)
- func MapCopy[K comparable, V any](m map[K]V) map[K]V
- func MapCopyFromTo[K comparable, V any](src map[K]V, dest map[K]V)
- func Max[V Number](a, b V) V
- func MaxCompFunc[T cmp.Ordered](a, b T) bool
- func Min[V Number](a, b V) V
- func MinCompFunc[T cmp.Ordered](a, b T) bool
- func NewByteSlicePtr(src []byte) *[]byte
- func NewPointer[T any](src T) *T
- func QuickFloatParse(s []byte, nDec int) (result float64)
- func QuickInt32Parse(s []byte) (result int32)
- func QuickPositiveInt32Parse(s []byte) (result int32)
- func QuickPositiveInt32ToBuf(n int32, nDigits int, buf []byte)
- func QuickPositiveInt32ToString(n int32, nDigits int) (result string)
- func RemoveByValueSlice[V comparable](slice *SliceWithCounter[V], value V)
- func RemoveByValueSliceHideable[V comparable](slice *SliceWithHideable[V], value V)
- func SortPair[A Integer, B any](Pos []A, Val []B, ascending bool)
- func SortTriple[A Integer, B any, C any](Pos []A, Val []B, ExtraVal []C, ascending bool)
- func UnsafeBytesToString(b []byte) string
- func UnsafeStringToBytes(s string) []byte
- type BitSet
- type BitSet64
- type BitSetImpl
- type CircularArray
- func (ca *CircularArray[T]) Initialize(length int)
- func (ca *CircularArray[T]) Read(pos int) T
- func (ca *CircularArray[T]) ReadFirst() T
- func (ca *CircularArray[T]) ReadLast() T
- func (ca *CircularArray[T]) RemoveNFirst(nToRemove int)
- func (ca *CircularArray[T]) RemoveNLast(nToRemove int)
- func (ca *CircularArray[T]) Write(elem T)
- type CommonMap
- type ConfigLoader
- func (config *ConfigLoader) GetAndHasConfig(key string) (value string, has bool)
- func (config *ConfigLoader) GetBoolConfig(key string, def bool) bool
- func (config *ConfigLoader) GetConfig(key string) (value string)
- func (config *ConfigLoader) GetFloatConfig(key string, def float64) float64
- func (config *ConfigLoader) GetInt32Config(key string, def int32) int32
- func (config *ConfigLoader) GetInt64Config(key string, def int64) int64
- func (config *ConfigLoader) GetIntConfig(key string, def int) int
- func (config *ConfigLoader) GetOrDefault(key string, def string) (value string)
- func (config *ConfigLoader) GetStringSliceCommaConfig(key string, def string) []string
- func (config *ConfigLoader) GetStringSliceConfig(key string, def string) []string
- func (config *ConfigLoader) HasConfig(key string) (has bool)
- func (config *ConfigLoader) InitEmptyConfig()
- func (config *ConfigLoader) LoadConfigs(folder string)
- func (config *ConfigLoader) ReplaceConfig(key string, value string)
- type ConstantSource
- type GoMap
- func (m GoMap[K, V]) AddAll(other map[K]V)
- func (m GoMap[K, V]) ApplyToAll(f func(key K, value V))
- func (m GoMap[K, V]) ApplyToAllKey(f func(key K))
- func (m GoMap[K, V]) ApplyToAllKeySeq(f func(key K))
- func (m GoMap[K, V]) ApplyToAllSeq(f func(key K, value V))
- func (m GoMap[K, V]) ApplyToAllValue(f func(value V))
- func (m GoMap[K, V]) ApplyToAllValueSeq(f func(value V))
- func (m GoMap[K, V]) Clear()
- func (m GoMap[K, V]) CollectToFloat(f func(value V) (float64, int)) (result float64, count int)
- func (m GoMap[K, V]) CollectToFloatSeq(f func(value V) (float64, int)) (result float64, count int)
- func (m GoMap[K, V]) CopyFrom(other MyMap[K, V])
- func (m GoMap[K, V]) Delete(key K)
- func (m GoMap[K, V]) Get(key K) (V, bool)
- func (m GoMap[K, V]) GetConcurrencyFactor() int
- func (m GoMap[K, V]) GetDirect(key K) V
- func (m GoMap[K, V]) HasKey(key K) bool
- func (m GoMap[K, V]) IsNotEmpty() bool
- func (m GoMap[K, V]) Len() int
- func (m GoMap[K, V]) Set(key K, value V)
- func (m GoMap[K, V]) ShallowCopy() MyMap[K, V]
- type GrowableBitSet
- func (bs *GrowableBitSet) AnyBitIsSet() bool
- func (bs *GrowableBitSet) GetBit(pos int) bool
- func (bs *GrowableBitSet) GetNBitsSet(nBits int) (count int)
- func (bs *GrowableBitSet) Reset()
- func (bs *GrowableBitSet) Set(pos int)
- func (bs *GrowableBitSet) ToString() string
- func (bs *GrowableBitSet) Unset(pos int)
- type Heap
- type Int8InInt64Slice
- func (s Int8InInt64Slice) CountNonZero() (count int)
- func (s *Int8InInt64Slice) Dec(i int, val int8)
- func (s Int8InInt64Slice) Get(i int) int8
- func (s Int8InInt64Slice) HasValue() bool
- func (s *Int8InInt64Slice) Inc(i int, val int8)
- func (s *Int8InInt64Slice) Reset()
- func (s *Int8InInt64Slice) Set(i int, val int8)
- type Integer
- type InterfaceTest
- type IntnInInt64Slice
- func (s IntnInInt64Slice) CountNonZero() (count int)
- func (s *IntnInInt64Slice) Dec(i int, val int8)
- func (s IntnInInt64Slice) Get(i int) int8
- func (s IntnInInt64Slice) HasValue() bool
- func (s *IntnInInt64Slice) Inc(i int, val int8)
- func (s *IntnInInt64Slice) Reset()
- func (s *IntnInInt64Slice) Set(i int, val int8)
- type MapWithReadSlice
- func (m MapWithReadSlice[K, V]) AddAll(other map[K]V)
- func (m MapWithReadSlice[K, V]) ApplyToAll(f func(key K, value V))
- func (m MapWithReadSlice[K, V]) ApplyToAllKey(f func(key K))
- func (m MapWithReadSlice[K, V]) ApplyToAllKeySeq(f func(key K))
- func (m MapWithReadSlice[K, V]) ApplyToAllSeq(f func(key K, value V))
- func (m MapWithReadSlice[K, V]) ApplyToAllValue(f func(value V))
- func (m MapWithReadSlice[K, V]) ApplyToAllValueSeq(f func(value V))
- func (m MapWithReadSlice[K, V]) Clear()
- func (m MapWithReadSlice[K, V]) CollectToFloat(f func(value V) (float64, int)) (result float64, count int)
- func (m MapWithReadSlice[K, V]) CollectToFloatSeq(f func(value V) (float64, int)) (result float64, count int)
- func (m MapWithReadSlice[K, V]) CopyFrom(other MyMap[K, V])
- func (m MapWithReadSlice[K, V]) Delete(key K)
- func (m MapWithReadSlice[K, V]) Get(key K) (V, bool)
- func (m MapWithReadSlice[K, V]) GetConcurrencyFactor() int
- func (m MapWithReadSlice[K, V]) GetDirect(key K) V
- func (m MapWithReadSlice[K, V]) HasKey(key K) bool
- func (m MapWithReadSlice[K, V]) IsNotEmpty() bool
- func (m MapWithReadSlice[K, V]) Len() int
- func (m MapWithReadSlice[K, V]) Set(key K, value V)
- func (m MapWithReadSlice[K, V]) ShallowCopy() MyMap[K, V]
- type MyMap
- func NewGoMap[K comparable, V any]() MyMap[K, V]
- func NewGoMapWithSize[K comparable, V any](size int) MyMap[K, V]
- func NewMapWithReadSlice[K comparable, V any]() MyMap[K, V]
- func NewMapWithReadSliceWithSize[K comparable, V any](size int) MyMap[K, V]
- func NewMapWithReadSliceWithSizeAndFactor[K comparable, V any](size int, factor int) MyMap[K, V]
- func NewShardedMap[V any](nShards int) MyMap[string, V]
- func NewShardedMapBitset[V any](nShards int) MyMap[string, V]
- func NewShardedMapBitsetWithSize[V any](nShards, totalSize int) MyMap[string, V]
- func NewShardedMapWithSize[V any](nShards, totalSize int) MyMap[string, V]
- type NilCheck
- type Number
- type Pair
- type PairSliceAsc
- type PairSliceDesc
- type Quad
- type ShardedMap
- func (m ShardedMap[V]) AddAll(other map[string]V)
- func (m ShardedMap[V]) ApplyToAll(f func(key string, value V))
- func (m ShardedMap[V]) ApplyToAllKey(f func(key string))
- func (m ShardedMap[V]) ApplyToAllKeySeq(f func(key string))
- func (m ShardedMap[V]) ApplyToAllSeq(f func(key string, value V))
- func (m ShardedMap[V]) ApplyToAllValue(f func(value V))
- func (m ShardedMap[V]) ApplyToAllValueSeq(f func(value V))
- func (m ShardedMap[V]) Clear()
- func (m ShardedMap[V]) CollectToFloat(f func(value V) (float64, int)) (result float64, count int)
- func (m ShardedMap[V]) CollectToFloatSeq(f func(value V) (float64, int)) (result float64, count int)
- func (m ShardedMap[V]) CopyFrom(other MyMap[string, V])
- func (m ShardedMap[V]) Delete(key string)
- func (m ShardedMap[V]) Get(key string) (V, bool)
- func (m ShardedMap[V]) GetConcurrencyFactor() int
- func (m ShardedMap[V]) GetDirect(key string) V
- func (m ShardedMap[V]) GetNShards() int
- func (m ShardedMap[V]) HasKey(key string) bool
- func (m ShardedMap[V]) IsNotEmpty() bool
- func (m ShardedMap[V]) Len() int
- func (m ShardedMap[V]) Set(key string, value V)
- func (m ShardedMap[V]) SetInvalidLen()
- func (m ShardedMap[V]) ShallowCopy() MyMap[string, V]
- type ShardedMapWithBitset
- func (m ShardedMapWithBitset[V]) ApplyToAllBitSet(f func(key string, value V))
- func (m ShardedMapWithBitset[V]) ApplyToAllKeyBitSet(f func(key string))
- func (m ShardedMapWithBitset[V]) ApplyToAllValueBitSet(f func(value V))
- func (m ShardedMapWithBitset[V]) ClearBits()
- func (m ShardedMapWithBitset[V]) Set(key string, value V)
- type SliceMap
- func (sm SliceMap[K, V]) Cap() int
- func (sm SliceMap[K, V]) Copy() SliceMapInterface[K, V]
- func (sm *SliceMap[K, V]) Delete(key K)
- func (sm *SliceMap[K, V]) DeleteByPos(pos int)
- func (sm *SliceMap[K, V]) Get(key K) (value V, found bool)
- func (sm *SliceMap[K, V]) GetByPos(pos int) (key K, value V)
- func (sm *SliceMap[K, V]) GetDirect(key K) (value V)
- func (sm SliceMap[K, V]) GetKeys() []K
- func (sm *SliceMap[K, V]) GetReturnPos(key K) (value V, pos int)
- func (sm SliceMap[K, V]) GetValues() []V
- func (sm *SliceMap[K, V]) HasKey(key K) (found bool)
- func (sm SliceMap[K, V]) IsNotEmpty() bool
- func (sm SliceMap[K, V]) Len() int
- func (sm *SliceMap[K, V]) Set(key K, value V)
- func (sm *SliceMap[K, V]) SetNew(key K, value V)
- func (sm *SliceMap[K, V]) SetOnPos(key K, value V, pos int)
- type SliceMapInterface
- type SliceNumberMap
- func (sm SliceNumberMap[K, V]) Cap() int
- func (sm SliceNumberMap[K, V]) Copy() SliceMapInterface[K, V]
- func (sm *SliceNumberMap[K, V]) Decrement(key K, delta V)
- func (sm *SliceNumberMap[K, V]) Delete(key K)
- func (sm *SliceNumberMap[K, V]) DeleteByPos(pos int)
- func (sm *SliceNumberMap[K, V]) Get(key K) (value V, found bool)
- func (sm *SliceNumberMap[K, V]) GetByPos(pos int) (key K, value V)
- func (sm *SliceNumberMap[K, V]) GetDirect(key K) (value V)
- func (sm SliceNumberMap[K, V]) GetKeys() []K
- func (sm *SliceNumberMap[K, V]) GetReturnPos(key K) (value V, pos int)
- func (sm SliceNumberMap[K, V]) GetValues() []V
- func (sm *SliceNumberMap[K, V]) HasKey(key K) (found bool)
- func (sm *SliceNumberMap[K, V]) Increment(key K, delta V)
- func (sm SliceNumberMap[K, V]) IsNotEmpty() bool
- func (sm SliceNumberMap[K, V]) Len() int
- func (sm *SliceNumberMap[K, V]) Set(key K, value V)
- func (sm *SliceNumberMap[K, V]) SetNew(key K, value V)
- func (sm *SliceNumberMap[K, V]) SetOnPos(key K, value V, pos int)
- type SliceSet
- func (ss *SliceSet[V]) Add(value V) bool
- func (ss *SliceSet[V]) AddNoCheck(value V)
- func (ss *SliceSet[V]) Cap() int
- func (ss *SliceSet[V]) Copy() SliceSetInterface[V]
- func (ss *SliceSet[V]) Delete(value V) bool
- func (ss *SliceSet[V]) DeleteByPos(pos int)
- func (ss *SliceSet[V]) GetValues() []V
- func (ss *SliceSet[V]) Has(value V) bool
- func (ss *SliceSet[V]) Len() int
- type SliceSetInterface
- type SliceWithCounter
- func (slice *SliceWithCounter[T]) AddAll(values []T)
- func (slice *SliceWithCounter[T]) AddToEnd(value T)
- func (slice *SliceWithCounter[T]) Append(value T)
- func (slice *SliceWithCounter[T]) AppendAll(values []T)
- func (slice SliceWithCounter[T]) Cap() int
- func (slice *SliceWithCounter[T]) Clear()
- func (slice *SliceWithCounter[T]) Copy() SliceWithCounter[T]
- func (slice *SliceWithCounter[T]) CopyGoSlice() (newSlice []T)
- func (slice *SliceWithCounter[T]) DeepClear()
- func (slice *SliceWithCounter[T]) Get(index int) T
- func (slice SliceWithCounter[T]) IsEmpty() bool
- func (slice SliceWithCounter[T]) IsFull() bool
- func (slice SliceWithCounter[T]) Len() int
- func (slice *SliceWithCounter[T]) Remove(index int)
- func (slice *SliceWithCounter[T]) RemoveAndGet(index int) (removed T)
- func (slice *SliceWithCounter[T]) RemoveAndGetLast() T
- func (slice *SliceWithCounter[T]) RemoveLast()
- func (slice *SliceWithCounter[T]) Set(index int, value T)
- func (slice SliceWithCounter[T]) ToSlice() []T
- type SliceWithHideable
- func (slice *SliceWithHideable[T]) AddAll(values []T)
- func (slice *SliceWithHideable[T]) AddToEnd(value T)
- func (slice *SliceWithHideable[T]) Append(value T)
- func (slice *SliceWithHideable[T]) AppendAll(values []T)
- func (slice *SliceWithHideable[T]) AppendAndHide(value T)
- func (slice *SliceWithHideable[T]) Cap() int
- func (slice *SliceWithHideable[T]) Clear()
- func (slice *SliceWithHideable[T]) Copy() SliceWithHideable[T]
- func (slice *SliceWithHideable[T]) CopyOnlyVisible() SliceWithHideable[T]
- func (slice *SliceWithHideable[T]) DeepClear()
- func (slice *SliceWithHideable[T]) FullLen() int
- func (slice *SliceWithHideable[T]) Get(index int) T
- func (slice *SliceWithHideable[T]) GetAndHideHead() T
- func (slice *SliceWithHideable[T]) GetAndHideTail() T
- func (slice *SliceWithHideable[T]) Head() T
- func (slice *SliceWithHideable[T]) HideHead()
- func (slice *SliceWithHideable[T]) HideHeadN(n int)
- func (slice *SliceWithHideable[T]) HideTail()
- func (slice *SliceWithHideable[T]) HideTailN(n int)
- func (slice *SliceWithHideable[T]) IsEmpty() bool
- func (slice *SliceWithHideable[T]) Len() int
- func (slice *SliceWithHideable[T]) LenHiddenHead() int
- func (slice *SliceWithHideable[T]) Remove(index int)
- func (slice *SliceWithHideable[T]) RemoveAndGet(index int) (removed T)
- func (slice *SliceWithHideable[T]) RemoveAndGetLast() T
- func (slice *SliceWithHideable[T]) RemoveLast()
- func (slice *SliceWithHideable[T]) Set(index int, value T)
- func (slice *SliceWithHideable[T]) ShiftElementsLeft()
- func (slice *SliceWithHideable[T]) Tail() T
- func (slice *SliceWithHideable[T]) ToFullSlice() []T
- func (slice *SliceWithHideable[T]) ToHiddenHeadSlice() []T
- func (slice *SliceWithHideable[T]) ToOriginalSlice() []T
- func (slice *SliceWithHideable[T]) ToSlice() []T
- func (slice *SliceWithHideable[T]) UnhideAll()
- func (slice *SliceWithHideable[T]) UnhideHead()
- func (slice *SliceWithHideable[T]) UnhideHeadN(n int)
- func (slice *SliceWithHideable[T]) UnhideTail()
- func (slice *SliceWithHideable[T]) UnhideTailN(n int)
- type Source
- type Triple
- type TripleSliceAsc
- type TripleSliceDesc
- type ValueTest
Constants ¶
const ( BIT_MASK_8 = 0xFF BIT_MASK_16 = 0xFFFF BIT_MASK_24 = 0xFFFFFF BIT_MASK_32 = 0xFFFFFFFF BIT_MASK_64 = 0xFFFFFFFFFFFFFFFF HIGHEST_BIT_64_ONLY = 0x8000000000000000 )
const (
ASCENDING, DESCENDING = true, false
)
const MAP_READ_SLICE_BASIC_FACTOR = 100000 //For very simple types (e.g. int), only do parallel if >= 100000.
Some recommended factors for MapWithReadSlice, depending on the complexity of the functions or values.
const MAP_READ_SLICE_COMPLEX_FACTOR = 1000 //For somewhat complex types (e.g., CRDTs with multiple fields), do parallel if >= 1000.
const MAP_READ_SLICE_MEDIUM_FACTOR = 10000 //For medium complexity types (e.g., register/counter CRDTs, or some basic structs), do parallel if >= 10000.
const MUST_RECALCULATE_LEN = -1
const NOT_FOUND = -1
Variables ¶
This section is empty.
Functions ¶
func ByteSliceGetOrDefault ¶
func CalculateShard ¶
func ConvertOrCopyGenericSlice ¶
This function receives a slice (converted to any, for genericity), and attempts to convert it to []T, if that would be safe. If not, it does a manual copy.
func CopyAnySliceToByteSlice ¶
func CopyByteSliceToAnySlice ¶
func DigitsOf64Bits ¶
Note: Assumes number is non-negative.
func MapCopy ¶
func MapCopy[K comparable, V any](m map[K]V) map[K]V
func MapCopyFromTo ¶
func MapCopyFromTo[K comparable, V any](src map[K]V, dest map[K]V)
func MaxCompFunc ¶
func MinCompFunc ¶
func NewByteSlicePtr ¶
func NewPointer ¶
func NewPointer[T any](src T) *T
func QuickInt32Parse ¶
func QuickPositiveInt32Parse ¶
func QuickPositiveInt32ToBuf ¶
func QuickPositiveInt32ToString ¶
If n has less than nDigits, the remaining positions are filled with 0s.
func RemoveByValueSlice ¶
func RemoveByValueSlice[V comparable](slice *SliceWithCounter[V], value V)
Sadly can't define a generic function whose type is more restrictive directly on the struct... so have to do like this.
func RemoveByValueSliceHideable ¶
func RemoveByValueSliceHideable[V comparable](slice *SliceWithHideable[V], value V)
Sadly can't define a generic function whose type is more restrictive directly on the struct... so have to do like this.
func SortTriple ¶
func UnsafeBytesToString ¶
func UnsafeStringToBytes ¶
Types ¶
type BitSet ¶
type BitSet interface {
Set(pos int)
Unset(pos int)
GetBit(pos int) bool
AnyBitIsSet() bool
Reset()
ToString() string
GetNBitsSet(nBits int) int //Argument is optional. If > 0, it will count check the first nBits for counting. Notes: implementation of this was tested in Go playground.
}
func NewBitSet64 ¶
func NewBitSet64() BitSet
type BitSetImpl ¶
type BitSetImpl struct {
// contains filtered or unexported fields
}
func (BitSetImpl) AnyBitIsSet ¶
func (bs BitSetImpl) AnyBitIsSet() bool
func (BitSetImpl) GetBit ¶
func (bs BitSetImpl) GetBit(pos int) bool
func (BitSetImpl) GetNBitsSet ¶
func (bs BitSetImpl) GetNBitsSet(nBits int) (count int)
func (BitSetImpl) Reset ¶
func (bs BitSetImpl) Reset()
func (BitSetImpl) Set ¶
func (bs BitSetImpl) Set(pos int)
func (BitSetImpl) ToString ¶
func (bs BitSetImpl) ToString() string
func (BitSetImpl) Unset ¶
func (bs BitSetImpl) Unset(pos int)
type CircularArray ¶
type CircularArray[T any] struct { // contains filtered or unexported fields }
func (*CircularArray[T]) Initialize ¶
func (ca *CircularArray[T]) Initialize(length int)
func (*CircularArray[T]) Read ¶
func (ca *CircularArray[T]) Read(pos int) T
Note: pos here is as if in a normal array: from 0 to n. Internally we convert to the right position given startPos offset.
func (*CircularArray[T]) ReadFirst ¶
func (ca *CircularArray[T]) ReadFirst() T
func (*CircularArray[T]) ReadLast ¶
func (ca *CircularArray[T]) ReadLast() T
func (*CircularArray[T]) RemoveNFirst ¶
func (ca *CircularArray[T]) RemoveNFirst(nToRemove int)
func (*CircularArray[T]) RemoveNLast ¶
func (ca *CircularArray[T]) RemoveNLast(nToRemove int)
func (*CircularArray[T]) Write ¶
func (ca *CircularArray[T]) Write(elem T)
type CommonMap ¶
type CommonMap[K comparable, V any] interface { Get(key K) (value V, found bool) GetDirect(key K) (value V) HasKey(key K) (found bool) Delete(key K) Set(key K, value V) Len() int IsNotEmpty() bool }
Simpler interface that is satisfied by both SliceMap, GoMap and the ShardedMaps here.
type ConfigLoader ¶
type ConfigLoader struct {
// contains filtered or unexported fields
}
var (
)
func (*ConfigLoader) GetAndHasConfig ¶
func (config *ConfigLoader) GetAndHasConfig(key string) (value string, has bool)
func (*ConfigLoader) GetBoolConfig ¶
func (config *ConfigLoader) GetBoolConfig(key string, def bool) bool
func (*ConfigLoader) GetConfig ¶
func (config *ConfigLoader) GetConfig(key string) (value string)
func (*ConfigLoader) GetFloatConfig ¶
func (config *ConfigLoader) GetFloatConfig(key string, def float64) float64
func (*ConfigLoader) GetInt32Config ¶
func (config *ConfigLoader) GetInt32Config(key string, def int32) int32
func (*ConfigLoader) GetInt64Config ¶
func (config *ConfigLoader) GetInt64Config(key string, def int64) int64
func (*ConfigLoader) GetIntConfig ¶
func (config *ConfigLoader) GetIntConfig(key string, def int) int
func (*ConfigLoader) GetOrDefault ¶
func (config *ConfigLoader) GetOrDefault(key string, def string) (value string)
func (*ConfigLoader) GetStringSliceCommaConfig ¶
func (config *ConfigLoader) GetStringSliceCommaConfig(key string, def string) []string
Splits by comma instead of space.
func (*ConfigLoader) GetStringSliceConfig ¶
func (config *ConfigLoader) GetStringSliceConfig(key string, def string) []string
Uses a whitespace to slice the string into different substrings
func (*ConfigLoader) HasConfig ¶
func (config *ConfigLoader) HasConfig(key string) (has bool)
func (*ConfigLoader) InitEmptyConfig ¶
func (config *ConfigLoader) InitEmptyConfig()
func (*ConfigLoader) LoadConfigs ¶
func (config *ConfigLoader) LoadConfigs(folder string)
func (*ConfigLoader) ReplaceConfig ¶
func (config *ConfigLoader) ReplaceConfig(key string, value string)
type ConstantSource ¶
type ConstantSource struct {
// contains filtered or unexported fields
}
Implements rand.Source and returns always the same value. Useful for some debugging situations (e.g., ensure queries always use the same random value, despite how many times random is called) The value returned is always 0 or, if seeded, the value of the seed.
func NewConstantSource ¶
func NewConstantSource(seed int64) *ConstantSource
func (*ConstantSource) Int63 ¶
func (s *ConstantSource) Int63() int64
func (*ConstantSource) Seed ¶
func (s *ConstantSource) Seed(seed int64)
type GoMap ¶
type GoMap[K comparable, V any] map[K]V
func (GoMap[K, V]) ApplyToAll ¶
func (m GoMap[K, V]) ApplyToAll(f func(key K, value V))
func (GoMap[K, V]) ApplyToAllKey ¶
func (m GoMap[K, V]) ApplyToAllKey(f func(key K))
func (GoMap[K, V]) ApplyToAllKeySeq ¶
func (m GoMap[K, V]) ApplyToAllKeySeq(f func(key K))
func (GoMap[K, V]) ApplyToAllSeq ¶
func (m GoMap[K, V]) ApplyToAllSeq(f func(key K, value V))
func (GoMap[K, V]) ApplyToAllValue ¶
func (m GoMap[K, V]) ApplyToAllValue(f func(value V))
func (GoMap[K, V]) ApplyToAllValueSeq ¶
func (m GoMap[K, V]) ApplyToAllValueSeq(f func(value V))
func (GoMap[K, V]) CollectToFloat ¶
func (GoMap[K, V]) CollectToFloatSeq ¶
func (GoMap[K, V]) GetConcurrencyFactor ¶
func (GoMap[K, V]) IsNotEmpty ¶
func (GoMap[K, V]) ShallowCopy ¶
type GrowableBitSet ¶
type GrowableBitSet struct {
// contains filtered or unexported fields
}
func (*GrowableBitSet) AnyBitIsSet ¶
func (bs *GrowableBitSet) AnyBitIsSet() bool
func (*GrowableBitSet) GetBit ¶
func (bs *GrowableBitSet) GetBit(pos int) bool
func (*GrowableBitSet) GetNBitsSet ¶
func (bs *GrowableBitSet) GetNBitsSet(nBits int) (count int)
func (*GrowableBitSet) Reset ¶
func (bs *GrowableBitSet) Reset()
func (*GrowableBitSet) Set ¶
func (bs *GrowableBitSet) Set(pos int)
func (*GrowableBitSet) ToString ¶
func (bs *GrowableBitSet) ToString() string
func (*GrowableBitSet) Unset ¶
func (bs *GrowableBitSet) Unset(pos int)
type Heap ¶
type Heap[T any] struct { // contains filtered or unexported fields }
Heap is a generic port of container.Heap. Not safe to use concurrently.
func NewHeapStruct ¶
Use NewHeap when possible. This one only works correctly if saved within a pointer struct
func (*Heap[T]) Clear ¶
func (h *Heap[T]) Clear()
Clear removes all elements from the heap (without reducing the capacity).
func (*Heap[T]) DeepClear ¶
func (h *Heap[T]) DeepClear()
DeepClear fully cleans the heap (including hidden elements), allowing for all elements inside to be GC'd.
func (*Heap[T]) PeekMin ¶
func (h *Heap[T]) PeekMin() T
Peek returns the top value without removing it from the heap.
func (*Heap[T]) Pop ¶
func (h *Heap[T]) Pop() T
Pop returns and removes the top element from the heap. Pre: Len() > 0.
func (*Heap[T]) Push ¶
func (h *Heap[T]) Push(val T)
Push adds new element to the heap in O(log n) time.
func (*Heap[T]) UpdateValue ¶
A bit faster than doing Remove() followed by Push(). However, heaps are not optimized for this.
type Int8InInt64Slice ¶
type Int8InInt64Slice int64
An int64 that stores 8 int8. This is useful when we have a small slice (<=8) and we want to quickly check if any value to it is != than 0.
func (Int8InInt64Slice) CountNonZero ¶
func (s Int8InInt64Slice) CountNonZero() (count int)
func (*Int8InInt64Slice) Dec ¶
func (s *Int8InInt64Slice) Dec(i int, val int8)
func (Int8InInt64Slice) Get ¶
func (s Int8InInt64Slice) Get(i int) int8
func (Int8InInt64Slice) HasValue ¶
func (s Int8InInt64Slice) HasValue() bool
func (*Int8InInt64Slice) Inc ¶
func (s *Int8InInt64Slice) Inc(i int, val int8)
func (*Int8InInt64Slice) Reset ¶
func (s *Int8InInt64Slice) Reset()
func (*Int8InInt64Slice) Set ¶
func (s *Int8InInt64Slice) Set(i int, val int8)
type InterfaceTest ¶
type InterfaceTest[K, V any] interface { // contains filtered or unexported methods }
type IntnInInt64Slice ¶
type IntnInInt64Slice int64
An int64 that stores up to 7 int8, in the lowest 56 bits. The highest 8 bits store the number of int8 stored. // This is useful when we have a small slice (<=7) and we want to quickly check if any value to it is != than 0.
func NewIntnInInt64Slice ¶
func NewIntnInInt64Slice(nNumbers int) IntnInInt64Slice
Pre: nNumbers < 8. For 8, use Int8InInt64Slice.
func (IntnInInt64Slice) CountNonZero ¶
func (s IntnInInt64Slice) CountNonZero() (count int)
func (*IntnInInt64Slice) Dec ¶
func (s *IntnInInt64Slice) Dec(i int, val int8)
func (IntnInInt64Slice) Get ¶
func (s IntnInInt64Slice) Get(i int) int8
func (IntnInInt64Slice) HasValue ¶
func (s IntnInInt64Slice) HasValue() bool
func (*IntnInInt64Slice) Inc ¶
func (s *IntnInInt64Slice) Inc(i int, val int8)
func (*IntnInInt64Slice) Reset ¶
func (s *IntnInInt64Slice) Reset()
func (*IntnInInt64Slice) Set ¶
func (s *IntnInInt64Slice) Set(i int, val int8)
type MapWithReadSlice ¶
type MapWithReadSlice[K comparable, V any] struct { Map map[K]int //int: position in the slice. Slice *SliceWithCounter[Pair[K, V]] ParallelReadingFactor int //Defines minimum size for reading in parallel. (len(Map)/ParallelReadingFactor) +1 routines will be used in parallel processing. }
func (MapWithReadSlice[K, V]) AddAll ¶
func (m MapWithReadSlice[K, V]) AddAll(other map[K]V)
func (MapWithReadSlice[K, V]) ApplyToAll ¶
func (m MapWithReadSlice[K, V]) ApplyToAll(f func(key K, value V))
func (MapWithReadSlice[K, V]) ApplyToAllKey ¶
func (m MapWithReadSlice[K, V]) ApplyToAllKey(f func(key K))
func (MapWithReadSlice[K, V]) ApplyToAllKeySeq ¶
func (m MapWithReadSlice[K, V]) ApplyToAllKeySeq(f func(key K))
func (MapWithReadSlice[K, V]) ApplyToAllSeq ¶
func (m MapWithReadSlice[K, V]) ApplyToAllSeq(f func(key K, value V))
func (MapWithReadSlice[K, V]) ApplyToAllValue ¶
func (m MapWithReadSlice[K, V]) ApplyToAllValue(f func(value V))
func (MapWithReadSlice[K, V]) ApplyToAllValueSeq ¶
func (m MapWithReadSlice[K, V]) ApplyToAllValueSeq(f func(value V))
func (MapWithReadSlice[K, V]) Clear ¶
func (m MapWithReadSlice[K, V]) Clear()
func (MapWithReadSlice[K, V]) CollectToFloat ¶
func (m MapWithReadSlice[K, V]) CollectToFloat(f func(value V) (float64, int)) (result float64, count int)
func (MapWithReadSlice[K, V]) CollectToFloatSeq ¶
func (m MapWithReadSlice[K, V]) CollectToFloatSeq(f func(value V) (float64, int)) (result float64, count int)
func (MapWithReadSlice[K, V]) CopyFrom ¶
func (m MapWithReadSlice[K, V]) CopyFrom(other MyMap[K, V])
func (MapWithReadSlice[K, V]) Delete ¶
func (m MapWithReadSlice[K, V]) Delete(key K)
func (MapWithReadSlice[K, V]) Get ¶
func (m MapWithReadSlice[K, V]) Get(key K) (V, bool)
func (MapWithReadSlice[K, V]) GetConcurrencyFactor ¶
func (m MapWithReadSlice[K, V]) GetConcurrencyFactor() int
func (MapWithReadSlice[K, V]) GetDirect ¶
func (m MapWithReadSlice[K, V]) GetDirect(key K) V
func (MapWithReadSlice[K, V]) HasKey ¶
func (m MapWithReadSlice[K, V]) HasKey(key K) bool
func (MapWithReadSlice[K, V]) IsNotEmpty ¶
func (m MapWithReadSlice[K, V]) IsNotEmpty() bool
func (MapWithReadSlice[K, V]) Len ¶
func (m MapWithReadSlice[K, V]) Len() int
func (MapWithReadSlice[K, V]) Set ¶
func (m MapWithReadSlice[K, V]) Set(key K, value V)
func (MapWithReadSlice[K, V]) ShallowCopy ¶
func (m MapWithReadSlice[K, V]) ShallowCopy() MyMap[K, V]
type MyMap ¶
type MyMap[K comparable, V any] interface { Get(key K) (value V, found bool) GetDirect(key K) (value V) HasKey(key K) (found bool) Set(key K, value V) Delete(key K) AddAll(other map[K]V) Clear() Len() int IsNotEmpty() bool ApplyToAllSeq(func(key K, value V)) //Intended for code that is not go-routine safe. ApplyToAllKeySeq(func(key K)) //Intended for code that is not go-routine safe. ApplyToAllValueSeq(func(value V)) //Intended for code that is not go-routine safe. ApplyToAll(func(key K, value V)) //May be concurrently applied under certain implementations (e.g., ShardedMap) ApplyToAllKey(func(key K)) //May be concurrently applied under certain implementations (e.g., ShardedMap) ApplyToAllValue(func(value V)) //May be concurrently applied under certain implementations (e.g., ShardedMap) CollectToFloatSeq(func(value V) (float64, int)) (float64, int) //Intended for code that is not go-routine safe. Applies the function to all values and returns the sum. Useful for some aggregations. CollectToFloat(func(value V) (float64, int)) (float64, int) //May be concurrently applied. Applies the function to all values and returns the sum. Useful for some aggregations. CopyFrom(other MyMap[K, V]) ShallowCopy() MyMap[K, V] //Returns a newly allocated map with the same contents. Note: this is a shallow copy, i.e., values are not cloned. GetConcurrencyFactor() int //Returns how many goroutines will be used for processing in parallel. }
func NewGoMap ¶
func NewGoMap[K comparable, V any]() MyMap[K, V]
func NewGoMapWithSize ¶
func NewGoMapWithSize[K comparable, V any](size int) MyMap[K, V]
func NewMapWithReadSlice ¶
func NewMapWithReadSlice[K comparable, V any]() MyMap[K, V]
func NewMapWithReadSliceWithSize ¶
func NewMapWithReadSliceWithSize[K comparable, V any](size int) MyMap[K, V]
func NewMapWithReadSliceWithSizeAndFactor ¶
func NewMapWithReadSliceWithSizeAndFactor[K comparable, V any](size int, factor int) MyMap[K, V]
type PairSliceAsc ¶
func (PairSliceAsc[A, B]) Len ¶
func (pair PairSliceAsc[A, B]) Len() int
func (PairSliceAsc[A, B]) Less ¶
func (pair PairSliceAsc[A, B]) Less(i, j int) bool
func (PairSliceAsc[A, B]) Sort ¶
func (pair PairSliceAsc[A, B]) Sort()
func (PairSliceAsc[A, B]) Swap ¶
func (pair PairSliceAsc[A, B]) Swap(i, j int)
type PairSliceDesc ¶
func (PairSliceDesc[A, B]) Len ¶
func (pair PairSliceDesc[A, B]) Len() int
func (PairSliceDesc[A, B]) Less ¶
func (pair PairSliceDesc[A, B]) Less(i, j int) bool
func (PairSliceDesc[A, B]) Sort ¶
func (pair PairSliceDesc[A, B]) Sort()
func (PairSliceDesc[A, B]) Swap ¶
func (pair PairSliceDesc[A, B]) Swap(i, j int)
type ShardedMap ¶
TODO: May be worth to make the map's keys uint64 too. As Go's map performance is worse with strings. But I'm afraid we may need the original keys. TODO: Also consider not having totalLen and instead calculating it when needed. This would avoid the pointer int, and extra overhead on both set and delete. Key must be a string due to the usage of xxh3, which does not support generics. A generic byte slice, while supported for hashing, is not supported as keys by Go maps. Note: Number of shards is fixed for now (i.e., the shards won't resize). Supporting this would require rehashing all keys and re-assigning, which would be expensive.
func (ShardedMap[V]) AddAll ¶
func (m ShardedMap[V]) AddAll(other map[string]V)
func (ShardedMap[V]) ApplyToAll ¶
func (m ShardedMap[V]) ApplyToAll(f func(key string, value V))
func (ShardedMap[V]) ApplyToAllKey ¶
func (m ShardedMap[V]) ApplyToAllKey(f func(key string))
func (ShardedMap[V]) ApplyToAllKeySeq ¶
func (m ShardedMap[V]) ApplyToAllKeySeq(f func(key string))
func (ShardedMap[V]) ApplyToAllSeq ¶
func (m ShardedMap[V]) ApplyToAllSeq(f func(key string, value V))
func (ShardedMap[V]) ApplyToAllValue ¶
func (m ShardedMap[V]) ApplyToAllValue(f func(value V))
func (ShardedMap[V]) ApplyToAllValueSeq ¶
func (m ShardedMap[V]) ApplyToAllValueSeq(f func(value V))
func (ShardedMap[V]) Clear ¶
func (m ShardedMap[V]) Clear()
func (ShardedMap[V]) CollectToFloat ¶
func (m ShardedMap[V]) CollectToFloat(f func(value V) (float64, int)) (result float64, count int)
func (ShardedMap[V]) CollectToFloatSeq ¶
func (m ShardedMap[V]) CollectToFloatSeq(f func(value V) (float64, int)) (result float64, count int)
func (ShardedMap[V]) CopyFrom ¶
func (m ShardedMap[V]) CopyFrom(other MyMap[string, V])
func (ShardedMap[V]) Delete ¶
func (m ShardedMap[V]) Delete(key string)
func (ShardedMap[V]) Get ¶
func (m ShardedMap[V]) Get(key string) (V, bool)
func (ShardedMap[V]) GetConcurrencyFactor ¶
func (m ShardedMap[V]) GetConcurrencyFactor() int
func (ShardedMap[V]) GetDirect ¶
func (m ShardedMap[V]) GetDirect(key string) V
func (ShardedMap[V]) GetNShards ¶
func (m ShardedMap[V]) GetNShards() int
func (ShardedMap[V]) HasKey ¶
func (m ShardedMap[V]) HasKey(key string) bool
func (ShardedMap[V]) IsNotEmpty ¶
func (m ShardedMap[V]) IsNotEmpty() bool
This may be useful later if we remote *totalLen from the map. An efficient check is to see the len of the first entry; if not empty, can return right away (fast path). If not, check other positions.
func (ShardedMap[V]) Len ¶
func (m ShardedMap[V]) Len() int
func (ShardedMap[V]) Set ¶
func (m ShardedMap[V]) Set(key string, value V)
func (ShardedMap[V]) SetInvalidLen ¶
func (m ShardedMap[V]) SetInvalidLen()
func (ShardedMap[V]) ShallowCopy ¶
func (m ShardedMap[V]) ShallowCopy() MyMap[string, V]
type ShardedMapWithBitset ¶
type ShardedMapWithBitset[V any] struct { ShardedMap[V] BitSet //Indicates if a map has been updated }
Keeps a bitset to tell which shards have been modified since a certain point in time. This is useful for scenarios where we need to apply some function only to shards that were modified (e.g., GC)
func (ShardedMapWithBitset[V]) ApplyToAllBitSet ¶
func (m ShardedMapWithBitset[V]) ApplyToAllBitSet(f func(key string, value V))
func (ShardedMapWithBitset[V]) ApplyToAllKeyBitSet ¶
func (m ShardedMapWithBitset[V]) ApplyToAllKeyBitSet(f func(key string))
func (ShardedMapWithBitset[V]) ApplyToAllValueBitSet ¶
func (m ShardedMapWithBitset[V]) ApplyToAllValueBitSet(f func(value V))
func (ShardedMapWithBitset[V]) ClearBits ¶
func (m ShardedMapWithBitset[V]) ClearBits()
func (ShardedMapWithBitset[V]) Set ¶
func (m ShardedMapWithBitset[V]) Set(key string, value V)
type SliceMap ¶
type SliceMap[K comparable, V any] struct { Keys []K Values []V Size int }
A map intended for very small sizes, where it is likely cheaper to search than use hashmap.
func NewSliceMap ¶
func NewSliceMap[K comparable, V any](size int) SliceMap[K, V]
func NewSliceMapPointer ¶
func NewSliceMapPointer[K comparable, V any](size int) *SliceMap[K, V]
func (SliceMap[K, V]) Copy ¶
func (sm SliceMap[K, V]) Copy() SliceMapInterface[K, V]
func (*SliceMap[K, V]) DeleteByPos ¶
func (*SliceMap[K, V]) GetReturnPos ¶
func (SliceMap[K, V]) IsNotEmpty ¶
type SliceMapInterface ¶
type SliceMapInterface[K comparable, V any] interface { Get(key K) (value V, found bool) GetDirect(key K) (value V) GetByPos(pos int) (key K, value V) GetReturnPos(key K) (value V, pos int) HasKey(key K) (found bool) Set(key K, value V) SetOnPos(key K, value V, pos int) SetNew(key K, value V) //For when we know the key is new, avoiding searching for it //Delete(key K) (value V, found bool) //DeleteByPos(pos int) (value V) //Useful for pattern of getReturnPos -> process -> delete object that was returned. Delete(key K) DeleteByPos(pos int) //Useful for pattern of getReturnPos -> process -> delete object that was returned. GetKeys() []K GetValues() []V Len() int Cap() int Copy() SliceMapInterface[K, V] IsNotEmpty() bool }
type SliceNumberMap ¶
type SliceNumberMap[K comparable, V Number] struct { Keys []K Values []V Size int }
func NewSliceNumberMap ¶
func NewSliceNumberMap[K comparable, V Number](size int) SliceNumberMap[K, V]
func NewSliceNumberMapPointer ¶
func NewSliceNumberMapPointer[K comparable, V Number](size int) *SliceNumberMap[K, V]
func (SliceNumberMap[K, V]) Cap ¶
func (sm SliceNumberMap[K, V]) Cap() int
func (SliceNumberMap[K, V]) Copy ¶
func (sm SliceNumberMap[K, V]) Copy() SliceMapInterface[K, V]
func (*SliceNumberMap[K, V]) Decrement ¶
func (sm *SliceNumberMap[K, V]) Decrement(key K, delta V)
func (*SliceNumberMap[K, V]) Delete ¶
func (sm *SliceNumberMap[K, V]) Delete(key K)
func (*SliceNumberMap[K, V]) DeleteByPos ¶
func (sm *SliceNumberMap[K, V]) DeleteByPos(pos int)
func (*SliceNumberMap[K, V]) Get ¶
func (sm *SliceNumberMap[K, V]) Get(key K) (value V, found bool)
func (*SliceNumberMap[K, V]) GetByPos ¶
func (sm *SliceNumberMap[K, V]) GetByPos(pos int) (key K, value V)
func (*SliceNumberMap[K, V]) GetDirect ¶
func (sm *SliceNumberMap[K, V]) GetDirect(key K) (value V)
func (SliceNumberMap[K, V]) GetKeys ¶
func (sm SliceNumberMap[K, V]) GetKeys() []K
func (*SliceNumberMap[K, V]) GetReturnPos ¶
func (sm *SliceNumberMap[K, V]) GetReturnPos(key K) (value V, pos int)
func (SliceNumberMap[K, V]) GetValues ¶
func (sm SliceNumberMap[K, V]) GetValues() []V
func (*SliceNumberMap[K, V]) HasKey ¶
func (sm *SliceNumberMap[K, V]) HasKey(key K) (found bool)
func (*SliceNumberMap[K, V]) Increment ¶
func (sm *SliceNumberMap[K, V]) Increment(key K, delta V)
func (SliceNumberMap[K, V]) IsNotEmpty ¶
func (sm SliceNumberMap[K, V]) IsNotEmpty() bool
func (SliceNumberMap[K, V]) Len ¶
func (sm SliceNumberMap[K, V]) Len() int
func (*SliceNumberMap[K, V]) Set ¶
func (sm *SliceNumberMap[K, V]) Set(key K, value V)
func (*SliceNumberMap[K, V]) SetNew ¶
func (sm *SliceNumberMap[K, V]) SetNew(key K, value V)
func (*SliceNumberMap[K, V]) SetOnPos ¶
func (sm *SliceNumberMap[K, V]) SetOnPos(key K, value V, pos int)
type SliceSet ¶
type SliceSet[V comparable] struct { Values []V Size int }
A set intented for very small sizes, where it is likely cheaper to search than using hashmap. This set is growable.
func NewSliceSet ¶
func NewSliceSet[V comparable](size int) *SliceSet[V]
func (*SliceSet[V]) AddNoCheck ¶
func (ss *SliceSet[V]) AddNoCheck(value V)
func (*SliceSet[V]) Copy ¶
func (ss *SliceSet[V]) Copy() SliceSetInterface[V]
func (*SliceSet[V]) DeleteByPos ¶
type SliceSetInterface ¶
type SliceSetInterface[V comparable] interface { Has(value V) bool Add(value V) bool AddNoCheck(value V) //Adds an element when it is already known that it does not exist. Unlike Add, this is O(1) (except for resize) Delete(value V) bool DeleteByPos(pos int) GetValues() []V Len() int Cap() int Copy() SliceSetInterface[V] }
type SliceWithCounter ¶
type SliceWithCounter[T any] struct { Slice []T //IMPORTANT NOTE: Make sure to always use .ToSlice() when iterating, as the internal slice may have a larger "go length" than its actual length! // contains filtered or unexported fields }
IMPORTANT NOTE: Make sure to always use .ToSlice() when iterating, as the internal slice may have a larger "go length" than its actual length! Slice is only public in order to allow direct position access more efficiently (e.g., for incrementing, setting, etc.)
func NewSliceWithCounter ¶
func NewSliceWithCounter[T any](size int) SliceWithCounter[T]
func NewSliceWithCounterPointer ¶
func NewSliceWithCounterPointer[T any](size int) *SliceWithCounter[T]
func ToSliceWithCounter ¶
func ToSliceWithCounter[T any](initialSlice []T) SliceWithCounter[T]
Note: This will use the initialSlice as the backing slice. Internal len will be set to match the slice's len.
func (*SliceWithCounter[T]) AddAll ¶
func (slice *SliceWithCounter[T]) AddAll(values []T)
Assumes slice has enough space.
func (*SliceWithCounter[T]) AddToEnd ¶
func (slice *SliceWithCounter[T]) AddToEnd(value T)
func (*SliceWithCounter[T]) Append ¶
func (slice *SliceWithCounter[T]) Append(value T)
func (*SliceWithCounter[T]) AppendAll ¶
func (slice *SliceWithCounter[T]) AppendAll(values []T)
func (SliceWithCounter[T]) Cap ¶
func (slice SliceWithCounter[T]) Cap() int
func (*SliceWithCounter[T]) Clear ¶
func (slice *SliceWithCounter[T]) Clear()
func (*SliceWithCounter[T]) Copy ¶
func (slice *SliceWithCounter[T]) Copy() SliceWithCounter[T]
func (*SliceWithCounter[T]) CopyGoSlice ¶
func (slice *SliceWithCounter[T]) CopyGoSlice() (newSlice []T)
func (*SliceWithCounter[T]) DeepClear ¶
func (slice *SliceWithCounter[T]) DeepClear()
func (*SliceWithCounter[T]) Get ¶
func (slice *SliceWithCounter[T]) Get(index int) T
func (SliceWithCounter[T]) IsEmpty ¶
func (slice SliceWithCounter[T]) IsEmpty() bool
func (SliceWithCounter[T]) IsFull ¶
func (slice SliceWithCounter[T]) IsFull() bool
func (SliceWithCounter[T]) Len ¶
func (slice SliceWithCounter[T]) Len() int
func (*SliceWithCounter[T]) Remove ¶
func (slice *SliceWithCounter[T]) Remove(index int)
Replaces removed position with the last element.
func (*SliceWithCounter[T]) RemoveAndGet ¶
func (slice *SliceWithCounter[T]) RemoveAndGet(index int) (removed T)
func (*SliceWithCounter[T]) RemoveAndGetLast ¶
func (slice *SliceWithCounter[T]) RemoveAndGetLast() T
func (*SliceWithCounter[T]) RemoveLast ¶
func (slice *SliceWithCounter[T]) RemoveLast()
func (*SliceWithCounter[T]) Set ¶
func (slice *SliceWithCounter[T]) Set(index int, value T)
func (SliceWithCounter[T]) ToSlice ¶
func (slice SliceWithCounter[T]) ToSlice() []T
type SliceWithHideable ¶
type SliceWithHideable[T any] struct { // contains filtered or unexported fields }
Supports hidding both elements at the start and at the end. It's similar to Go's slicing mechanics, but we allow to recover elements hidden at the start of the slice, unlike Go's slices. It also supports querying how many elements are hidden at the start, but not at the end. Both the original, "hidden" and "visible" slice can be retrieved at any time, and the slice can also be fully cleared for later exterior re-use.
func NewSliceWithHideable ¶
func NewSliceWithHideable[T any](size int) SliceWithHideable[T]
func NewSliceWithHideablePointer ¶
func NewSliceWithHideablePointer[T any](size int) *SliceWithHideable[T]
func ToSliceWithHideable ¶
func ToSliceWithHideable[T any](initialSlice []T) SliceWithHideable[T]
Note: This will use the initialSlice as the backing slice.
func (*SliceWithHideable[T]) AddAll ¶
func (slice *SliceWithHideable[T]) AddAll(values []T)
Assumes slice has enough space.
func (*SliceWithHideable[T]) AddToEnd ¶
func (slice *SliceWithHideable[T]) AddToEnd(value T)
func (*SliceWithHideable[T]) Append ¶
func (slice *SliceWithHideable[T]) Append(value T)
func (*SliceWithHideable[T]) AppendAll ¶
func (slice *SliceWithHideable[T]) AppendAll(values []T)
func (*SliceWithHideable[T]) AppendAndHide ¶
func (slice *SliceWithHideable[T]) AppendAndHide(value T)
func (*SliceWithHideable[T]) Cap ¶
func (slice *SliceWithHideable[T]) Cap() int
func (*SliceWithHideable[T]) Clear ¶
func (slice *SliceWithHideable[T]) Clear()
Note: This also resets slice.start to 0.
func (*SliceWithHideable[T]) Copy ¶
func (slice *SliceWithHideable[T]) Copy() SliceWithHideable[T]
func (*SliceWithHideable[T]) CopyOnlyVisible ¶
func (slice *SliceWithHideable[T]) CopyOnlyVisible() SliceWithHideable[T]
func (*SliceWithHideable[T]) DeepClear ¶
func (slice *SliceWithHideable[T]) DeepClear()
Note: This also resets slice.start to 0.
func (*SliceWithHideable[T]) FullLen ¶
func (slice *SliceWithHideable[T]) FullLen() int
Len without accounting for start
func (*SliceWithHideable[T]) Get ¶
func (slice *SliceWithHideable[T]) Get(index int) T
func (*SliceWithHideable[T]) GetAndHideHead ¶
func (slice *SliceWithHideable[T]) GetAndHideHead() T
func (*SliceWithHideable[T]) GetAndHideTail ¶
func (slice *SliceWithHideable[T]) GetAndHideTail() T
func (*SliceWithHideable[T]) Head ¶
func (slice *SliceWithHideable[T]) Head() T
func (*SliceWithHideable[T]) HideHead ¶
func (slice *SliceWithHideable[T]) HideHead()
func (*SliceWithHideable[T]) HideHeadN ¶
func (slice *SliceWithHideable[T]) HideHeadN(n int)
func (*SliceWithHideable[T]) HideTail ¶
func (slice *SliceWithHideable[T]) HideTail()
func (*SliceWithHideable[T]) HideTailN ¶
func (slice *SliceWithHideable[T]) HideTailN(n int)
func (*SliceWithHideable[T]) IsEmpty ¶
func (slice *SliceWithHideable[T]) IsEmpty() bool
func (*SliceWithHideable[T]) Len ¶
func (slice *SliceWithHideable[T]) Len() int
func (*SliceWithHideable[T]) LenHiddenHead ¶
func (slice *SliceWithHideable[T]) LenHiddenHead() int
func (*SliceWithHideable[T]) Remove ¶
func (slice *SliceWithHideable[T]) Remove(index int)
Replaces removed position with the last element.
func (*SliceWithHideable[T]) RemoveAndGet ¶
func (slice *SliceWithHideable[T]) RemoveAndGet(index int) (removed T)
func (*SliceWithHideable[T]) RemoveAndGetLast ¶
func (slice *SliceWithHideable[T]) RemoveAndGetLast() T
func (*SliceWithHideable[T]) RemoveLast ¶
func (slice *SliceWithHideable[T]) RemoveLast()
func (*SliceWithHideable[T]) Set ¶
func (slice *SliceWithHideable[T]) Set(index int, value T)
func (*SliceWithHideable[T]) ShiftElementsLeft ¶
func (slice *SliceWithHideable[T]) ShiftElementsLeft()
Rewrites the slice, copying everything from [slice.start:slice.len] to [0:]. Also resets the positions after the new length.
func (*SliceWithHideable[T]) Tail ¶
func (slice *SliceWithHideable[T]) Tail() T
func (*SliceWithHideable[T]) ToFullSlice ¶
func (slice *SliceWithHideable[T]) ToFullSlice() []T
func (*SliceWithHideable[T]) ToHiddenHeadSlice ¶
func (slice *SliceWithHideable[T]) ToHiddenHeadSlice() []T
func (*SliceWithHideable[T]) ToOriginalSlice ¶
func (slice *SliceWithHideable[T]) ToOriginalSlice() []T
Returns the slice ignoring start, but accounting for len.
func (*SliceWithHideable[T]) ToSlice ¶
func (slice *SliceWithHideable[T]) ToSlice() []T
func (*SliceWithHideable[T]) UnhideAll ¶
func (slice *SliceWithHideable[T]) UnhideAll()
func (*SliceWithHideable[T]) UnhideHead ¶
func (slice *SliceWithHideable[T]) UnhideHead()
func (*SliceWithHideable[T]) UnhideHeadN ¶
func (slice *SliceWithHideable[T]) UnhideHeadN(n int)
func (*SliceWithHideable[T]) UnhideTail ¶
func (slice *SliceWithHideable[T]) UnhideTail()
func (*SliceWithHideable[T]) UnhideTailN ¶
func (slice *SliceWithHideable[T]) UnhideTailN(n int)
type TripleSliceAsc ¶
func (TripleSliceAsc[A, B, C]) Len ¶
func (triple TripleSliceAsc[A, B, C]) Len() int
func (TripleSliceAsc[A, B, C]) Less ¶
func (triple TripleSliceAsc[A, B, C]) Less(i, j int) bool
func (TripleSliceAsc[A, B, C]) Sort ¶
func (triple TripleSliceAsc[A, B, C]) Sort()
func (TripleSliceAsc[A, B, C]) Swap ¶
func (triple TripleSliceAsc[A, B, C]) Swap(i, j int)
type TripleSliceDesc ¶
func (TripleSliceDesc[A, B, C]) Len ¶
func (triple TripleSliceDesc[A, B, C]) Len() int
func (TripleSliceDesc[A, B, C]) Less ¶
func (triple TripleSliceDesc[A, B, C]) Less(i, j int) bool
func (TripleSliceDesc[A, B, C]) Sort ¶
func (triple TripleSliceDesc[A, B, C]) Sort()
func (TripleSliceDesc[A, B, C]) Swap ¶
func (triple TripleSliceDesc[A, B, C]) Swap(i, j int)