Documentation ¶
Overview ¶
Package ds queue copy from https://github.com/eapache/queue/blob/master/queue.go
Package ds BuiltinSet copy from https://github.com/chen3feng/stl4go/blob/master/builtin_set.go
Package ds stack copy from https://github.com/chen3feng/stl4go/blob/master/stack.go
Index ¶
- Variables
- func BuildOrderTuples[K ttypes.Ordered, V any](m map[K]V) []*ttypes.OrderTuple[K, V]
- func DListIter[T any](a DList[T], iterate func(a DList[T], node T))
- func DListIterAllOk[T any](a DList[T], iterate func(a DList[T], node T) bool) bool
- func DListPartition[T any](a DList[T], iterate func(a DList[T], node T) bool) (DList[T], DList[T])
- func FpPartial[T1, T2, R any](f func(a T1, b T2) R, arg1 T1) func(T2) R
- func FpPartial1[T1, T2, R any](f func(T1, T2) R, arg1 T1) func(T2) R
- func FpPartial2[T1, T2, T3, R any](f func(T1, T2, T3) R, arg1 T1) func(T2, T3) R
- func FpPartial3[T1, T2, T3, T4, R any](f func(T1, T2, T3, T4) R, arg1 T1) func(T2, T3, T4) R
- func FpPartial4[T1, T2, T3, T4, T5, R any](f func(T1, T2, T3, T4, T5) R, arg1 T1) func(T2, T3, T4, T5) R
- func FpPartial5[T1, T2, T3, T4, T5, T6, R any](f func(T1, T2, T3, T4, T5, T6) R, arg1 T1) func(T2, T3, T4, T5, T6) R
- func LowerBound[T ttypes.Ordered](a []T, value T) int
- func LowerBoundFunc[T any](a []T, value T, less ttypes.LessFn[T]) int
- func MapConvertKeyToSlice[T comparable, V any](a map[T]V) []T
- func MapConvertValueToSlice[T comparable, V any](a map[T]V) []V
- func MapConvertZipSliceToMap[T comparable, V any](a []T, b []V) (map[T]V, error)
- func MapEqualCounter[V comparable](c map[V]int, other map[V]int) bool
- func MapIter[K comparable, V any](a map[K]V, iterate func(k K, v V))
- func MapIterAllOk[K comparable, V any](a map[K]V, iterate func(k K, v V) bool) bool
- func MapIterFilter[K comparable, V any](a map[K]V, iterate func(k K, v V) bool) map[K]V
- func MapIterMapKVCopy[K comparable, V any](a map[K]V, iterate func(k K, v V) (K, V)) map[K]V
- func MapIterMapKVInPlace[K comparable, V any](a map[K]V, iterate func(k K, v V) V) map[K]V
- func MapIterPartition[K comparable, V any](a map[K]V, iterate func(a map[K]V, k K, v V) bool) (map[K]V, map[K]V)
- func MapOpAppendValue[K comparable, V any](m map[K][]V, k K, v V) map[K][]V
- func MapOpCopy[K comparable, V any](m map[K]V) map[K]V
- func MapOpDeepCopy[K comparable, V any](m map[K]V) map[K]V
- func MapOpMerge[K comparable, V any](m1 map[K]V, m2 map[K]V) map[K]V
- func MapOpPop[K comparable, V any](m map[K]V, k K) (V, bool)
- func MapOpRemoveValue[K comparable, V comparable](m map[K]V, dv V) map[K]V
- func MapOpRemoveValueInSlice[K comparable, V comparable](m map[K][]V, dv V, del bool) map[K][]V
- func PartQuickSort[T ttypes.Ordered](data []T, k int, max bool) []T
- func SListIter[T any](a SList[T], iterate func(a SList[T], node T))
- func SListIterAllOk[T any](a SList[T], iterate func(a SList[T], node T) bool) bool
- func SListPartition[T any](a SList[T], iterate func(a SList[T], node T) bool) (SList[T], SList[T])
- func SetIter[T comparable](a BuiltinSet[T], iterate func(node T))
- func SetIterAllOk[T comparable](a BuiltinSet[T], iterate func(node T) bool) bool
- func SetPartition[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T) bool) (BuiltinSet[T], BuiltinSet[T])
- func SetToMap[K comparable, V any](u BuiltinSet[K], fn func(K) V) map[K]V
- func SetToSlice[K comparable](u BuiltinSet[K]) []K
- func SliceCmpAbsEqual[T comparable](a []T, b []T) bool
- func SliceCmpAbsSub[T comparable](a []T, b []T) int
- func SliceCmpLogicEqual[T comparable](a []T, b []T) bool
- func SliceCmpLogicSub[T comparable](a []T, b []T) bool
- func SliceCmpTwoDiff[T comparable](a []T, b []T) ([]T, []T)
- func SliceConvertToInt(data interface{}) ([]int, error)
- func SliceConvertToInt64(data interface{}) ([]int64, error)
- func SliceConvertToString(data interface{}) ([]string, error)
- func SliceExclude[T comparable](a []T, b T) bool
- func SliceGetCopy[T any](data []T, ns ...int) []T
- func SliceGetFilter[T any](a []T, filter func(i int) bool) []T
- func SliceGetNthTail[T any](data []T, nth int, d ...T) T
- func SliceGetOne[T any](data []T) (T, error)
- func SliceGetOnlyOne[T any](data []T) (T, error)
- func SliceGetTail[T any](data []T, d ...T) T
- func SliceGroupByHandler[K comparable, V any](data []V, getKeyHandler func(int) K) map[K][]V
- func SliceGroupByHandlerUnique[K comparable, V any](data []V, getKeyHandler func(int) K) map[K]V
- func SliceGroupToCounter[V comparable](data []V) map[V]int
- func SliceGroupToMap[V comparable](data []V) map[V][]V
- func SliceGroupToPartitions[T any](data []T, step int) [][]T
- func SliceGroupToSlice[T any, V any](data []T, handler func(int) (V, bool)) []V
- func SliceGroupToSlices[V ttypes.Ordered](data []V) [][]V
- func SliceGroupToTwoMap[T comparable, K comparable, V any](data []V, groupT func(*V) T, groupK func(*V) K) map[T]map[K][]V
- func SliceGroupUniqueByHandler[K comparable, V any](data []V, getKeyHandler func(int) K) map[K]V
- func SliceInclude[T comparable](a []T, b T) bool
- func SliceIncludeBinarySearch[T ttypes.Ordered](data []T, value T) int
- func SliceIncludeIndex[T comparable](a []T, b T) int
- func SliceIncludeIndexUnpack[T comparable](a T, others ...T) int
- func SliceIncludeUnpack[T comparable](a T, others ...T) bool
- func SliceIncludeWithFn[T comparable](a []T, fn func(a []T, i int) bool) bool
- func SliceIncludeWithFnV2[T comparable](a []T, fn func(int) bool) bool
- func SliceIter[T any](a []T, iterate func(a []T, i int))
- func SliceIterAllOk[T any](a []T, iterate func(a []T, i int) bool) bool
- func SliceIterAllOkV2[T any](a []T, iterate func(i int) bool) bool
- func SliceIterFilter[T any](a []T, iterate func(a []T, i int) bool) []T
- func SliceIterFilterV2[T any](a []T, iterate func(i int) bool) []T
- func SliceIterMapCopy[T any](a []T, iterate func(i int) T) []T
- func SliceIterMapInPlace[T any](a []T, iterate func(i int) T) []T
- func SliceIterPartition[T any](a []T, iterate func(a []T, i int) bool) ([]T, []T)
- func SliceIterV2[T any](a []T, iterate func(i int))
- func SliceMax[T ttypes.Ordered](data []T) T
- func SliceMaxN[T ttypes.Ordered](data []T, n int) []T
- func SliceMaxNWithOrder[T ttypes.Ordered](data []T, n int) []T
- func SliceMaxUnpack[T ttypes.Ordered](data ...T) T
- func SliceMin[T ttypes.Ordered](data []T) T
- func SliceMinN[T ttypes.Ordered](data []T, n int) []T
- func SliceMinNWithOrder[T ttypes.Ordered](data []T, n int) []T
- func SliceMinUnpack[T ttypes.Ordered](data ...T) T
- func SliceOpInsert[T any](data *[]T, i int, x ...T)
- func SliceOpJoinToString[T any](data []T, seps ...string) (string, error)
- func SliceOpMerge[T any](first []T, second []T) []T
- func SliceOpPopBack[T any](data *[]T) (T, bool)
- func SliceOpRemove[T comparable](data *[]T, b T)
- func SliceOpRemoveIndex[T any](data *[]T, i int)
- func SliceOpRemoveMany[T comparable](data *[]T, values []T)
- func SliceOpRemoveRange[T any](data *[]T, i int, j int)
- func SliceOpReplace[T comparable](data []T, a T, b T)
- func SliceOpReverse[T any](data []T)
- func SliceOpReverseCopy[T any](data []T) []T
- func SliceOpShuffle[T any](data []T)
- func SliceOpUnique[T comparable](data []T) []T
- func SliceSetNthTail[T any](data []T, nth int, d T)
- func SliceSetTail[T any](data []T, d T)
- func StrHasContainInsensitive(str string, subStr string) bool
- func StrHasPrefixInsensitive(str string, subStr string) bool
- func StrHasSuffixInsensitive(str string, subStr string) bool
- func StrRemoveHead(s string, n int) string
- func StrRemoveTail(s string, n int) string
- func StrReverse(s string) string
- func StrSplitNth(str string, sep string, total int, nth int) string
- func UpperBound[T ttypes.Ordered](a []T, value T) int
- func UpperBoundFunc[T any](a []T, value T, less ttypes.LessFn[T]) int
- type Bitmap
- type BuiltinSet
- func MapConvertKeyToSet[T comparable, V any](a map[T]V) BuiltinSet[T]
- func MapConvertValueToSet[T comparable, V comparable](a map[T]V) BuiltinSet[V]
- func NewSet[K comparable](n ...int) BuiltinSet[K]
- func SetFromDList[K comparable](list *DList[K]) BuiltinSet[K]
- func SetFromMapKey[K comparable, V any](ks map[K]V) BuiltinSet[K]
- func SetFromMapValue[K comparable, V comparable](ks map[K]V) BuiltinSet[V]
- func SetFromSList[K comparable](list *SList[K]) BuiltinSet[K]
- func SetFromSlice[K comparable](ks []K) BuiltinSet[K]
- func SetFromUnpack[K comparable](ks ...K) BuiltinSet[K]
- func SetIterFilter[T comparable](a BuiltinSet[T], iterate func(node T) bool) BuiltinSet[T]
- func SetIterMapCopy[T comparable](a BuiltinSet[T], iterate func(node T) T) BuiltinSet[T]
- func SetIterMapInPlace[T comparable](a BuiltinSet[T], iterate func(node T) T) BuiltinSet[T]
- func SliceGroupToSet[V comparable](data []V) BuiltinSet[V]
- func (s BuiltinSet[K]) Clear()
- func (s BuiltinSet[K]) Delete(k K)
- func (s BuiltinSet[K]) DeleteN(ks ...K)
- func (s BuiltinSet[K]) Difference(other BuiltinSet[K]) BuiltinSet[K]
- func (s BuiltinSet[K]) Equal(other BuiltinSet[K]) bool
- func (s BuiltinSet[K]) ForEach(cb func(k K))
- func (s BuiltinSet[K]) ForEachIf(cb func(k K) bool)
- func (s BuiltinSet[K]) Has(k K) bool
- func (s BuiltinSet[K]) Insert(k K) bool
- func (s BuiltinSet[K]) InsertN(ks ...K) int
- func (s BuiltinSet[K]) Intersection(other BuiltinSet[K]) BuiltinSet[K]
- func (s BuiltinSet[K]) IsDisjointOf(other BuiltinSet[K]) bool
- func (s BuiltinSet[K]) IsEmpty() bool
- func (s BuiltinSet[K]) IsSubsetOf(other BuiltinSet[K]) bool
- func (s BuiltinSet[K]) IsSupersetOf(other BuiltinSet[K]) bool
- func (s BuiltinSet[K]) Keys() []K
- func (s BuiltinSet[K]) Len() int
- func (s BuiltinSet[K]) Remove(k K) bool
- func (s BuiltinSet[K]) RemoveN(ks ...K) int
- func (s BuiltinSet[K]) String() string
- func (s BuiltinSet[K]) Union(other BuiltinSet[K]) BuiltinSet[K]
- func (s BuiltinSet[K]) Update(other BuiltinSet[K])
- type DList
- func DListFromUnpack[T any](vs ...T) *DList[T]
- func DListIterFilter[T any](a DList[T], iterate func(a DList[T], node T) bool) DList[T]
- func DListIterMapCopy[T any](a DList[T], iterate func(a DList[T], node T) T) DList[T]
- func DListIterMapInPlace[T any](a DList[T], iterate func(a DList[T], node T) T) DList[T]
- func NewDList[T any]() *DList[T]
- func SetToDList[K comparable](u BuiltinSet[K]) *DList[K]
- func (l *DList[T]) Back() T
- func (l *DList[T]) Clear()
- func (l *DList[T]) ForEach(cb func(val T))
- func (l *DList[T]) ForEachIf(cb func(val T) bool)
- func (l *DList[T]) ForEachMutable(cb func(val *T))
- func (l *DList[T]) ForEachMutableIf(cb func(val *T) bool)
- func (l *DList[T]) Front() T
- func (l *DList[T]) InsertLessBound(v T, fn ttypes.LessEqFn[T])
- func (l *DList[T]) IsEmpty() bool
- func (l *DList[T]) Iterate() MutableIterator[T]
- func (l *DList[T]) Len() int
- func (l *DList[T]) PopBack() T
- func (l *DList[T]) PopFront() T
- func (l *DList[T]) PushBack(val T)
- func (l *DList[T]) PushFront(val T)
- func (l *DList[T]) RemoveValue(v T, fn ttypes.CompareFn[T]) bool
- func (l *DList[T]) TryPopBack() (T, bool)
- func (l *DList[T]) TryPopFront() (T, bool)
- func (l *DList[T]) Values() []T
- type Element
- type Interface
- type Iterator
- type MapCompareResult
- func MapCmpFullComplexKey[T comparable, V any](a map[T]V, b map[T]V) MapCompareResult
- func MapCmpFullSimpleKey[T comparable, V ttypes.Ordered](a map[T]V, b map[T]V) MapCompareResult
- func MapCmpWithComplexKey[T comparable, V any](a map[T]V, b map[T]V, key T) MapCompareResult
- func MapCmpWithSimpleKey[T comparable, V ttypes.Ordered](a map[T]V, b map[T]V, key T) MapCompareResult
- type MapLocker
- type MapRWLocker
- type MutableIterator
- type NamedTuple2E
- type NamedTuple3E
- type NamedTuple4E
- type NamedTuple5E
- type Node
- type Option
- type Options
- type OrderSet
- func (o *OrderSet[K]) Clear()
- func (o *OrderSet[K]) Delete(k K)
- func (o *OrderSet[K]) DeleteN(ks ...K)
- func (o *OrderSet[K]) Difference(other *OrderSet[K]) *OrderSet[K]
- func (o *OrderSet[K]) Equal(other *OrderSet[K]) bool
- func (o *OrderSet[K]) ForEach(cb func(k K))
- func (o *OrderSet[K]) ForEachIf(cb func(k K) bool)
- func (o *OrderSet[K]) Has(k K) bool
- func (o *OrderSet[K]) Insert(k K) bool
- func (o *OrderSet[K]) InsertN(ks ...K) int
- func (o *OrderSet[K]) Intersection(other *OrderSet[K]) *OrderSet[K]
- func (o *OrderSet[K]) IsDisjointOf(other *OrderSet[K]) bool
- func (o *OrderSet[K]) IsEmpty() bool
- func (o *OrderSet[K]) IsSubsetOf(other *OrderSet[K]) bool
- func (o *OrderSet[K]) IsSupersetOf(other *OrderSet[K]) bool
- func (o *OrderSet[K]) Keys() *SList[K]
- func (o *OrderSet[K]) Len() int
- func (o *OrderSet[K]) Remove(k K) bool
- func (o *OrderSet[K]) RemoveN(ks ...K) int
- func (o *OrderSet[K]) String() string
- func (o *OrderSet[K]) Union(other *OrderSet[K]) *OrderSet[K]
- func (o *OrderSet[K]) Update(other *OrderSet[K])
- type Queue
- type SList
- func NewSList[T any]() *SList[T]
- func SListFromUnpack[T any](values ...T) *SList[T]
- func SListIterFilter[T any](a SList[T], iterate func(a SList[T], node T) bool) SList[T]
- func SListIterMapCopy[T any](a SList[T], iterate func(a SList[T], node T) T) SList[T]
- func SListIterMapInPlace[T any](a SList[T], iterate func(a SList[T], node T) T) SList[T]
- func SetToSList[K comparable](u BuiltinSet[K]) *SList[K]
- func (l *SList[T]) Back() T
- func (l *SList[T]) Clear()
- func (l *SList[T]) ForEach(cb func(T))
- func (l *SList[T]) ForEachIf(cb func(T) bool)
- func (l *SList[T]) ForEachMutable(cb func(*T))
- func (l *SList[T]) ForEachMutableIf(cb func(*T) bool)
- func (l *SList[T]) Front() T
- func (l *SList[T]) InsertLessBound(v T, fn ttypes.LessEqFn[T])
- func (l *SList[T]) IsEmpty() bool
- func (l *SList[T]) Iterate() MutableIterator[T]
- func (l *SList[T]) Len() int
- func (l *SList[T]) PopFront() T
- func (l *SList[T]) PopTail() T
- func (l *SList[T]) PushBack(v T)
- func (l *SList[T]) PushFront(v T)
- func (l *SList[T]) RemoveValue(v T, fn ttypes.CompareFn[T]) bool
- func (l *SList[T]) Reverse()
- func (l *SList[T]) Values() []T
- type Skiplist
- type Stack
- type Tuple2E
- type Tuple3E
- type Tuple4E
- type Tuple5E
- type TupleName
- type WaitFor
- type WaitForPriorityQueue
Constants ¶
This section is empty.
Variables ¶
var ErrorNotFound = errors.New("not found")
Functions ¶
func BuildOrderTuples ¶ added in v1.0.53
func BuildOrderTuples[K ttypes.Ordered, V any](m map[K]V) []*ttypes.OrderTuple[K, V]
func DListIterAllOk ¶ added in v1.0.53
DListIterAllOk Returns true if all of the values pass the predicate truth test
func DListPartition ¶ added in v1.0.53
DListPartition Split list into two lists: one whose elements all satisfy predicate and one whose elements all do not satisfy predicate
func FpPartial ¶ added in v1.0.8
func FpPartial[T1, T2, R any](f func(a T1, b T2) R, arg1 T1) func(T2) R
FpPartial returns new function that, when called, has its first argument set to the provided value.
func FpPartial1 ¶ added in v1.0.8
func FpPartial1[T1, T2, R any](f func(T1, T2) R, arg1 T1) func(T2) R
FpPartial1 returns new function that, when called, has its first argument set to the provided value.
func FpPartial2 ¶ added in v1.0.8
func FpPartial2[T1, T2, T3, R any](f func(T1, T2, T3) R, arg1 T1) func(T2, T3) R
FpPartial2 returns new function that, when called, has its first argument set to the provided value.
func FpPartial3 ¶ added in v1.0.8
func FpPartial3[T1, T2, T3, T4, R any](f func(T1, T2, T3, T4) R, arg1 T1) func(T2, T3, T4) R
FpPartial3 returns new function that, when called, has its first argument set to the provided value.
func FpPartial4 ¶ added in v1.0.8
func FpPartial4[T1, T2, T3, T4, T5, R any](f func(T1, T2, T3, T4, T5) R, arg1 T1) func(T2, T3, T4, T5) R
FpPartial4 returns new function that, when called, has its first argument set to the provided value.
func FpPartial5 ¶ added in v1.0.8
func FpPartial5[T1, T2, T3, T4, T5, T6, R any](f func(T1, T2, T3, T4, T5, T6) R, arg1 T1) func(T2, T3, T4, T5, T6) R
FpPartial5 returns new function that, when called, has its first argument set to the provided value
func LowerBound ¶ added in v1.0.53
LowerBound returns an index to the first element in the ascending ordered slice a that does not satisfy element < value (i.e. greater or equal to), or len(a) if no such element is found.
Complexity: O(log(len(a))).
func LowerBoundFunc ¶ added in v1.0.53
LowerBoundFunc returns an index to the first element in the ordered slice a that does not satisfy less(element, value)), or len(a) if no such element is found.
The elements in the slice a should sorted according with compare func less.
Complexity: O(log(len(a))).
func MapConvertKeyToSlice ¶ added in v1.0.23
func MapConvertKeyToSlice[T comparable, V any](a map[T]V) []T
MapConvertKeyToSlice 提取map的key, 转成slice
func MapConvertValueToSlice ¶ added in v1.0.23
func MapConvertValueToSlice[T comparable, V any](a map[T]V) []V
MapConvertValueToSlice 提取map的Value转成slice
func MapConvertZipSliceToMap ¶ added in v1.0.23
func MapConvertZipSliceToMap[T comparable, V any](a []T, b []V) (map[T]V, error)
MapConvertZipSliceToMap 两个slice,一个key,一个value转换为map
func MapEqualCounter ¶ added in v1.0.7
func MapEqualCounter[V comparable](c map[V]int, other map[V]int) bool
func MapIter ¶ added in v1.0.23
func MapIter[K comparable, V any](a map[K]V, iterate func(k K, v V))
MapIter 只是迭代元素
func MapIterAllOk ¶ added in v1.0.23
func MapIterAllOk[K comparable, V any](a map[K]V, iterate func(k K, v V) bool) bool
MapIterAllOk Returns true if all of the values pass the predicate truth test
func MapIterFilter ¶ added in v1.0.23
func MapIterFilter[K comparable, V any](a map[K]V, iterate func(k K, v V) bool) map[K]V
MapIterFilter Looks through each value in the map, returning a map of all the values that pass a truth test (predicate).
func MapIterMapKVCopy ¶ added in v1.0.23
func MapIterMapKVCopy[K comparable, V any](a map[K]V, iterate func(k K, v V) (K, V)) map[K]V
MapIterMapKVCopy Produces a new map by mapping each key, value in map through a transformation function (iterate).
func MapIterMapKVInPlace ¶ added in v1.0.23
func MapIterMapKVInPlace[K comparable, V any](a map[K]V, iterate func(k K, v V) V) map[K]V
MapIterMapKVInPlace Map每个kv进行map映射
func MapIterPartition ¶ added in v1.0.23
func MapIterPartition[K comparable, V any](a map[K]V, iterate func(a map[K]V, k K, v V) bool) (map[K]V, map[K]V)
MapIterPartition Split map into two maps: one whose elements all satisfy predicate and one whose elements all do not satisfy predicate
func MapOpAppendValue ¶ added in v1.0.27
func MapOpAppendValue[K comparable, V any](m map[K][]V, k K, v V) map[K][]V
func MapOpCopy ¶ added in v1.0.37
func MapOpCopy[K comparable, V any](m map[K]V) map[K]V
MapOpCopy 快速拷贝一个Map
func MapOpDeepCopy ¶ added in v1.0.37
func MapOpDeepCopy[K comparable, V any](m map[K]V) map[K]V
MapOpDeepCopy 深度拷贝一个Map
func MapOpMerge ¶ added in v1.0.23
func MapOpMerge[K comparable, V any](m1 map[K]V, m2 map[K]V) map[K]V
MapOpMerge 合并两个map,如果key重复则以第二个元素中的key为主
func MapOpPop ¶ added in v1.0.37
func MapOpPop[K comparable, V any](m map[K]V, k K) (V, bool)
MapOpPop 弹出Map中的元素
func MapOpRemoveValue ¶ added in v1.0.36
func MapOpRemoveValue[K comparable, V comparable](m map[K]V, dv V) map[K]V
MapOpRemoveValue 删除符合条件的值
func MapOpRemoveValueInSlice ¶ added in v1.0.36
func MapOpRemoveValueInSlice[K comparable, V comparable](m map[K][]V, dv V, del bool) map[K][]V
MapOpRemoveValueInSlice 删除符合条件的值
func PartQuickSort ¶ added in v1.0.46
func SListIterAllOk ¶ added in v1.0.53
SListIterAllOk Returns true if all of the values pass the predicate truth test
func SListPartition ¶ added in v1.0.53
SListPartition Split list into two lists: one whose elements all satisfy predicate and one whose elements all do not satisfy predicate
func SetIter ¶ added in v1.0.23
func SetIter[T comparable](a BuiltinSet[T], iterate func(node T))
SetIter 迭代元素
func SetIterAllOk ¶ added in v1.0.23
func SetIterAllOk[T comparable](a BuiltinSet[T], iterate func(node T) bool) bool
SetIterAllOk Returns true if all of the values pass the predicate truth test
func SetPartition ¶ added in v1.0.23
func SetPartition[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T) bool) (BuiltinSet[T], BuiltinSet[T])
SetPartition Split set into two sets: one whose elements all satisfy predicate and one whose elements all do not satisfy predicate
func SetToMap ¶ added in v1.0.52
func SetToMap[K comparable, V any](u BuiltinSet[K], fn func(K) V) map[K]V
SetToMap convert set to map
func SetToSlice ¶
func SetToSlice[K comparable](u BuiltinSet[K]) []K
SetToSlice convert set to slice
func SliceCmpAbsEqual ¶ added in v1.0.23
func SliceCmpAbsEqual[T comparable](a []T, b []T) bool
SliceCmpAbsEqual 判断两个slice是否一样,严格按照顺序比较
func SliceCmpAbsSub ¶ added in v1.0.23
func SliceCmpAbsSub[T comparable](a []T, b []T) int
SliceCmpAbsSub 判断b切片是否是a切片的子集,严格比较
func SliceCmpLogicEqual ¶ added in v1.0.23
func SliceCmpLogicEqual[T comparable](a []T, b []T) bool
SliceCmpLogicEqual 判断两个Slice是否逻辑一样,和顺序无关
func SliceCmpLogicSub ¶ added in v1.0.23
func SliceCmpLogicSub[T comparable](a []T, b []T) bool
SliceCmpLogicSub 判断b切片是否是a切片的子集
func SliceCmpTwoDiff ¶ added in v1.0.23
func SliceCmpTwoDiff[T comparable](a []T, b []T) ([]T, []T)
SliceCmpTwoDiff 显示两个切片的区别
func SliceConvertToInt ¶ added in v1.0.1
SliceConvertToInt 切片集合统一转换为[]int
func SliceConvertToInt64 ¶ added in v1.0.1
SliceConvertToInt64 切片集合统一转换为[]int64
func SliceConvertToString ¶ added in v1.0.1
SliceConvertToString 切片集合统一转换为[]string
func SliceGetCopy ¶ added in v1.0.23
SliceGetCopy 复制切片
func SliceGetFilter ¶ added in v1.0.23
SliceGetFilter 过滤slice
func SliceGetNthTail ¶ added in v1.0.35
SliceGetNthTail 获取切片倒数第N个元素,如果没有则用默认值
func SliceGetOne ¶ added in v1.0.48
SliceGetOne 从切片中取出第一个元素
func SliceGetOnlyOne ¶ added in v1.0.48
SliceGetOnlyOne 切片只能有一个元素,并取出
func SliceGetTail ¶ added in v1.0.23
func SliceGetTail[T any](data []T, d ...T) T
SliceGetTail 获取切片最后一个元素,如果没有则用默认值
func SliceGroupByHandler ¶ added in v1.0.7
func SliceGroupByHandler[K comparable, V any](data []V, getKeyHandler func(int) K) map[K][]V
SliceGroupByHandler 对切片进行分类
func SliceGroupByHandlerUnique ¶ added in v1.0.25
func SliceGroupByHandlerUnique[K comparable, V any](data []V, getKeyHandler func(int) K) map[K]V
SliceGroupByHandlerUnique 对切片按照元素进行分类, 结果以map形式返回
func SliceGroupToCounter ¶ added in v1.0.23
func SliceGroupToCounter[V comparable](data []V) map[V]int
SliceGroupToCounter 对切片按照元素进行计数
func SliceGroupToMap ¶ added in v1.0.23
func SliceGroupToMap[V comparable](data []V) map[V][]V
SliceGroupToMap 对切片按照元素进行分类, 结果以map形式返回
func SliceGroupToPartitions ¶ added in v1.0.46
SliceGroupToPartitions 按照指定步长切割Slice
func SliceGroupToSlice ¶ added in v1.0.46
SliceGroupToSlice 切片转换为新的切片,一般用于提取其内部元素
func SliceGroupToSlices ¶ added in v1.0.23
SliceGroupToSlices 对切片按照元素进行分类,结果以二维数组形式返回
func SliceGroupToTwoMap ¶ added in v1.0.28
func SliceGroupToTwoMap[T comparable, K comparable, V any](data []V, groupT func(*V) T, groupK func(*V) K) map[T]map[K][]V
func SliceGroupUniqueByHandler ¶ added in v1.0.36
func SliceGroupUniqueByHandler[K comparable, V any](data []V, getKeyHandler func(int) K) map[K]V
SliceGroupUniqueByHandler 对切片进行分类
func SliceIncludeBinarySearch ¶ added in v1.0.23
SliceIncludeBinarySearch 二分搜索
func SliceIncludeIndex ¶ added in v1.0.23
func SliceIncludeIndex[T comparable](a []T, b T) int
SliceIncludeIndex 获取元素在切片中的下标,如果不存在返回-1
func SliceIncludeIndexUnpack ¶ added in v1.0.23
func SliceIncludeIndexUnpack[T comparable](a T, others ...T) int
SliceIncludeIndexUnpack 获取元素在切片中的下标,如果不存在返回-1
func SliceIncludeUnpack ¶ added in v1.0.23
func SliceIncludeUnpack[T comparable](a T, others ...T) bool
SliceIncludeUnpack 判断第一个元素是否在后续元素集合中
func SliceIncludeWithFn ¶ added in v1.0.26
func SliceIncludeWithFn[T comparable](a []T, fn func(a []T, i int) bool) bool
func SliceIncludeWithFnV2 ¶ added in v1.0.51
func SliceIncludeWithFnV2[T comparable](a []T, fn func(int) bool) bool
func SliceIterAllOk ¶ added in v1.0.23
func SliceIterAllOkV2 ¶ added in v1.0.51
SliceIterAllOkV2 Returns true if all of the values pass the predicate truth test
func SliceIterFilter ¶ added in v1.0.23
SliceIterFilter Looks through each value in the slice, returning a slice of all the values that pass a truth test (predicate).
func SliceIterFilterV2 ¶ added in v1.0.50
SliceIterFilterV2 Looks through each value in the slice, returning a slice of all the values that pass a truth test (predicate).
func SliceIterMapCopy ¶ added in v1.0.23
SliceIterMapCopy Produces a new slice by mapping each value in list through a transformation function (iterate).
func SliceIterMapInPlace ¶ added in v1.0.23
SliceIterMapInPlace Slice每个元素进行map映射
func SliceIterPartition ¶ added in v1.0.23
SliceIterPartition Split slice into two slices: one whose elements all satisfy predicate and one whose elements all do not satisfy predicate
func SliceIterV2 ¶ added in v1.0.49
SliceIterV2 只是迭代元素
func SliceMaxNWithOrder ¶ added in v1.0.7
SliceMaxNWithOrder 按序返回切片中最大的N个元素
func SliceMaxUnpack ¶ added in v1.0.23
SliceMaxUnpack 求最大值
func SliceMinNWithOrder ¶ added in v1.0.7
SliceMinNWithOrder 有序返回切片中最小的N个元素
func SliceMinUnpack ¶ added in v1.0.23
SliceMinUnpack 求最小值
func SliceOpInsert ¶ added in v1.0.23
SliceOpInsert 把元素插入到data的指定位置
func SliceOpJoinToString ¶ added in v1.0.47
SliceOpJoinToString 切片合并成字符串
func SliceOpMerge ¶ added in v1.0.24
func SliceOpMerge[T any](first []T, second []T) []T
SliceOpMerge 合并两个切片
func SliceOpPopBack ¶ added in v1.0.23
SliceOpPopBack 弹出切片最后一个元素
func SliceOpRemove ¶ added in v1.0.23
func SliceOpRemove[T comparable](data *[]T, b T)
SliceOpRemove 原地删除元素
func SliceOpRemoveIndex ¶ added in v1.0.23
SliceOpRemoveIndex 删除某个索引位置的切片
func SliceOpRemoveMany ¶ added in v1.0.23
func SliceOpRemoveMany[T comparable](data *[]T, values []T)
SliceOpRemoveMany 从Slice集合中移除另外一个Slice中的元素
func SliceOpRemoveRange ¶ added in v1.0.23
SliceOpRemoveRange 删除某个范围内的切片
func SliceOpReplace ¶ added in v1.0.23
func SliceOpReplace[T comparable](data []T, a T, b T)
SliceOpReplace 原地替换元素
func SliceOpReverseCopy ¶ added in v1.0.23
func SliceOpReverseCopy[T any](data []T) []T
SliceOpReverseCopy 转置切片并复制
func SliceOpShuffle ¶ added in v1.0.23
func SliceOpShuffle[T any](data []T)
SliceOpShuffle shuffle 切片
func SliceOpUnique ¶ added in v1.0.23
func SliceOpUnique[T comparable](data []T) []T
SliceOpUnique 去重切片
func SliceSetNthTail ¶ added in v1.0.42
SliceSetNthTail 设置切片倒数第N个元素
func SliceSetTail ¶ added in v1.0.42
func SliceSetTail[T any](data []T, d T)
SliceSetTail 设置切片最后一个元素值
func StrHasContainInsensitive ¶ added in v1.0.31
StrHasContainInsensitive 大小写无关的包含判断
func StrHasPrefixInsensitive ¶ added in v1.0.7
StrHasPrefixInsensitive 判断str是以subStr开始, subStr不关注大小写
func StrHasSuffixInsensitive ¶ added in v1.0.7
StrHasSuffixInsensitive 判断str是以subStr结尾, subStr不关注大小写
func StrRemoveHead ¶ added in v1.0.7
StrRemoveHead 删除str起始n个元素
func StrRemoveTail ¶ added in v1.0.7
StrRemoveTail 删除str末尾n个元素
func StrSplitNth ¶ added in v1.0.7
StrSplitNth 字符串分割按照sep分割,约定total个,返回第nth个元素 total == -1表示不关注total元素个数 nth <0 表示返回倒数第N个元素
func UpperBound ¶ added in v1.0.53
UpperBound returns an index to the first element in the ascending ordered slice a such that value < element (i.e. strictly greater), or len(a) if no such element is found.
Complexity: O(log(len(a))).
func UpperBoundFunc ¶ added in v1.0.53
UpperBoundFunc returns an index to the first element in the ordered slice a such that less(value, element)) is true (i.e. strictly greater), or len(a) if no such element is found.
The elements in the slice a should sorted according with compare func less.
Complexity: O(log(len(a))).
Types ¶
type Bitmap ¶ added in v1.0.17
type Bitmap struct {
// contains filtered or unexported fields
}
Bitmap is a mapping from some domain (for example, a range of integers) to bits. It is also called a bit array or bitmap index
func NewFromData ¶ added in v1.0.17
NewFromData creates a bitmap from the exported data
type BuiltinSet ¶
type BuiltinSet[K comparable] map[K]struct{}
BuiltinSet is an associative container that contains an unordered set of unique objects of type K.
func MapConvertKeyToSet ¶ added in v1.0.24
func MapConvertKeyToSet[T comparable, V any](a map[T]V) BuiltinSet[T]
MapConvertKeyToSet 提取map的key,转成Set
func MapConvertValueToSet ¶ added in v1.0.37
func MapConvertValueToSet[T comparable, V comparable](a map[T]V) BuiltinSet[V]
MapConvertValueToSet 提取map的value转成Set
func NewSet ¶
func NewSet[K comparable](n ...int) BuiltinSet[K]
func SetFromDList ¶ added in v1.0.52
func SetFromDList[K comparable](list *DList[K]) BuiltinSet[K]
SetFromDList 从单向链表构造Set集合
func SetFromMapKey ¶ added in v1.0.52
func SetFromMapKey[K comparable, V any](ks map[K]V) BuiltinSet[K]
SetFromMapKey 从map的key构造Set集合
func SetFromMapValue ¶ added in v1.0.52
func SetFromMapValue[K comparable, V comparable](ks map[K]V) BuiltinSet[V]
SetFromMapValue 从map的value构造Set集合
func SetFromSList ¶ added in v1.0.52
func SetFromSList[K comparable](list *SList[K]) BuiltinSet[K]
SetFromSList 从单向链表构造Set集合
func SetFromSlice ¶
func SetFromSlice[K comparable](ks []K) BuiltinSet[K]
SetFromSlice create a new BuiltinSet object with the initial content from slice.
func SetFromUnpack ¶ added in v1.0.52
func SetFromUnpack[K comparable](ks ...K) BuiltinSet[K]
SetFromUnpack creates a new BuiltinSet object with the initial content from ks.
func SetIterFilter ¶ added in v1.0.23
func SetIterFilter[T comparable](a BuiltinSet[T], iterate func(node T) bool) BuiltinSet[T]
SetIterFilter Looks through each value in the set, returning a set of all the values that pass a truth test (predicate).
func SetIterMapCopy ¶ added in v1.0.23
func SetIterMapCopy[T comparable](a BuiltinSet[T], iterate func(node T) T) BuiltinSet[T]
SetIterMapCopy Produces a new list by mapping each value in list through a transformation function (iterate).
func SetIterMapInPlace ¶ added in v1.0.23
func SetIterMapInPlace[T comparable](a BuiltinSet[T], iterate func(node T) T) BuiltinSet[T]
SetIterMapInPlace Iterates over set, yielding each value in turn to an iterate function, Returns the set for chaining.
func SliceGroupToSet ¶ added in v1.0.23
func SliceGroupToSet[V comparable](data []V) BuiltinSet[V]
SliceGroupToSet 对切片按照元素进行分类,结果以Set形式返回
func (BuiltinSet[K]) Clear ¶
func (s BuiltinSet[K]) Clear()
Clear implements the Container interface.
func (BuiltinSet[K]) Delete ¶
func (s BuiltinSet[K]) Delete(k K)
Delete deletes an element from the set. It returns nothing, so it's faster than Remove.
func (BuiltinSet[K]) DeleteN ¶ added in v1.0.52
func (s BuiltinSet[K]) DeleteN(ks ...K)
DeleteN delete elements from the set
func (BuiltinSet[K]) Difference ¶
func (s BuiltinSet[K]) Difference(other BuiltinSet[K]) BuiltinSet[K]
Difference returns a new set with elements in the set that are not in other.
func (BuiltinSet[K]) Equal ¶ added in v1.0.24
func (s BuiltinSet[K]) Equal(other BuiltinSet[K]) bool
func (BuiltinSet[K]) ForEach ¶
func (s BuiltinSet[K]) ForEach(cb func(k K))
ForEach implements the Set interface.
func (BuiltinSet[K]) ForEachIf ¶
func (s BuiltinSet[K]) ForEachIf(cb func(k K) bool)
ForEachIf implements the Container interface.
func (BuiltinSet[K]) Insert ¶
func (s BuiltinSet[K]) Insert(k K) bool
Insert implements the Set interface.
func (BuiltinSet[K]) InsertN ¶
func (s BuiltinSet[K]) InsertN(ks ...K) int
InsertN implements the Set interface.
func (BuiltinSet[K]) Intersection ¶
func (s BuiltinSet[K]) Intersection(other BuiltinSet[K]) BuiltinSet[K]
Intersection returns a new set with elements common to the set and other.
func (BuiltinSet[K]) IsDisjointOf ¶
func (s BuiltinSet[K]) IsDisjointOf(other BuiltinSet[K]) bool
IsDisjointOf return True if the set has no elements in common with other. Sets are disjoint if and only if their intersection is the empty set.
func (BuiltinSet[K]) IsEmpty ¶
func (s BuiltinSet[K]) IsEmpty() bool
IsEmpty implements the Container interface.
func (BuiltinSet[K]) IsSubsetOf ¶
func (s BuiltinSet[K]) IsSubsetOf(other BuiltinSet[K]) bool
IsSubsetOf tests whether every element in the set is in other.
func (BuiltinSet[K]) IsSupersetOf ¶
func (s BuiltinSet[K]) IsSupersetOf(other BuiltinSet[K]) bool
IsSupersetOf tests whether every element in other is in the set.
func (BuiltinSet[K]) Keys ¶
func (s BuiltinSet[K]) Keys() []K
Keys return a copy of all keys as a slice.
func (BuiltinSet[K]) Remove ¶
func (s BuiltinSet[K]) Remove(k K) bool
Remove implements the Set interface.
func (BuiltinSet[K]) RemoveN ¶
func (s BuiltinSet[K]) RemoveN(ks ...K) int
RemoveN implements the Set interface.
func (BuiltinSet[K]) String ¶
func (s BuiltinSet[K]) String() string
String implements the fmt.Stringer interface.
func (BuiltinSet[K]) Union ¶
func (s BuiltinSet[K]) Union(other BuiltinSet[K]) BuiltinSet[K]
Union returns a new set with elements from the set and other.
func (BuiltinSet[K]) Update ¶
func (s BuiltinSet[K]) Update(other BuiltinSet[K])
Update adds all elements from other to set. set |= other.
type DList ¶ added in v1.0.17
type DList[T any] struct { // contains filtered or unexported fields }
DList is a doubly linked list.
func DListFromUnpack ¶ added in v1.0.52
DListFromUnpack make a new DList from a serial of values.
func DListIterFilter ¶ added in v1.0.53
DListIterFilter Looks through each value in the list, returning a list of all the values that pass a truth test (predicate).
func DListIterMapCopy ¶ added in v1.0.53
DListIterMapCopy Produces a new list by mapping each value in list through a transformation function (iterate).
func DListIterMapInPlace ¶ added in v1.0.53
DListIterMapInPlace Iterates over list, yielding each value in turn to an iterate function, Returns the list for chaining.
func SetToDList ¶ added in v1.0.52
func SetToDList[K comparable](u BuiltinSet[K]) *DList[K]
SetToDList SetToList convert set to list
func (*DList[T]) Back ¶ added in v1.0.17
func (l *DList[T]) Back() T
Back returns the last element in the container.
func (*DList[T]) ForEach ¶ added in v1.0.17
func (l *DList[T]) ForEach(cb func(val T))
ForEach iterate the list, apply each element to the cb callback function.
func (*DList[T]) ForEachIf ¶ added in v1.0.17
ForEachIf iterate the list, apply each element to the cb callback function, stop if cb returns false.
func (*DList[T]) ForEachMutable ¶ added in v1.0.17
func (l *DList[T]) ForEachMutable(cb func(val *T))
ForEachMutable iterate the list, apply pointer of each element to the cb callback function.
func (*DList[T]) ForEachMutableIf ¶ added in v1.0.17
ForEachMutableIf iterate the list, apply pointer of each element to the cb callback function, stop if cb returns false.
func (*DList[T]) Front ¶ added in v1.0.17
func (l *DList[T]) Front() T
Front returns the first element in the container.
func (*DList[T]) InsertLessBound ¶ added in v1.0.53
func (*DList[T]) Iterate ¶ added in v1.0.17
func (l *DList[T]) Iterate() MutableIterator[T]
func (*DList[T]) PopBack ¶ added in v1.0.17
func (l *DList[T]) PopBack() T
PopBack popups an element from the back of the list.
func (*DList[T]) PopFront ¶ added in v1.0.17
func (l *DList[T]) PopFront() T
PopFront popups an element from the front of the list.
func (*DList[T]) PushBack ¶ added in v1.0.17
func (l *DList[T]) PushBack(val T)
PushBack pushes an element at the back of the list.
func (*DList[T]) PushFront ¶ added in v1.0.17
func (l *DList[T]) PushFront(val T)
PushFront pushes an element at the front of the list.
func (*DList[T]) RemoveValue ¶ added in v1.0.53
func (*DList[T]) TryPopBack ¶ added in v1.0.17
TryPopBack tries to pop up an element from the back of the list.
func (*DList[T]) TryPopFront ¶ added in v1.0.17
TryPopFront tries to pop up an element from the front of the list.
type Interface ¶ added in v1.0.37
type Interface interface {
DeepCopy() interface{}
}
Interface for delegating copy process to type
type Iterator ¶ added in v1.0.1
type Iterator[T any] interface { IsNotEnd() bool // Whether it is point to the end of the range. MoveToNext() // Let it point to the next element. Value() T // Return the value of current element. }
Iterator is the interface for container's iterator.
type MapCompareResult ¶ added in v1.0.1
type MapCompareResult int
const ( LeftKeyMiss MapCompareResult = iota + 1 RightKeyMiss AllKeyMiss NotEqual Equal LeftLargeThanRight LeftLessThanRight )
func MapCmpFullComplexKey ¶ added in v1.0.23
func MapCmpFullComplexKey[T comparable, V any](a map[T]V, b map[T]V) MapCompareResult
MapCmpFullComplexKey 复杂值的全部比较
func MapCmpFullSimpleKey ¶ added in v1.0.23
func MapCmpFullSimpleKey[T comparable, V ttypes.Ordered](a map[T]V, b map[T]V) MapCompareResult
MapCmpFullSimpleKey 简单值的全部比较
func MapCmpWithComplexKey ¶ added in v1.0.23
func MapCmpWithComplexKey[T comparable, V any](a map[T]V, b map[T]V, key T) MapCompareResult
MapCmpWithComplexKey 复杂值的key比较
func MapCmpWithSimpleKey ¶ added in v1.0.23
func MapCmpWithSimpleKey[T comparable, V ttypes.Ordered](a map[T]V, b map[T]V, key T) MapCompareResult
MapCmpWithSimpleKey 简单值的key比较
type MapLocker ¶
type MapLocker[K comparable, V any] struct { // contains filtered or unexported fields }
MapLocker 带锁的map,用于简单的并发读写场景
func MapNewMapLocker ¶ added in v1.0.7
func MapNewMapLocker[K comparable, V any]() *MapLocker[K, V]
type MapRWLocker ¶
type MapRWLocker[K comparable, V any] struct { // contains filtered or unexported fields }
MapRWLocker 简单的读写锁map
func MapNewMapRWLocker ¶ added in v1.0.7
func MapNewMapRWLocker[K comparable, V any]() *MapRWLocker[K, V]
func (*MapRWLocker[K, V]) Contain ¶
func (m *MapRWLocker[K, V]) Contain(key K) bool
func (*MapRWLocker[K, V]) Foreach ¶
func (m *MapRWLocker[K, V]) Foreach(handler func(key K, value V))
func (*MapRWLocker[K, V]) Get ¶
func (m *MapRWLocker[K, V]) Get(key K) (V, bool)
func (*MapRWLocker[K, V]) Set ¶
func (m *MapRWLocker[K, V]) Set(key K, value V)
type MutableIterator ¶ added in v1.0.1
type MutableIterator[T any] interface { Iterator[T] Pointer() *T // Return the pointer to the value of current element. }
MutableIterator is the interface for container's mutable iterator.
type NamedTuple2E ¶ added in v1.0.29
func NewNamedTuple2E ¶ added in v1.0.29
func NewNamedTuple2E[A any, B any](na string, a A, nb string, b B) *NamedTuple2E[A, B]
func (*NamedTuple2E[A, B]) Get ¶ added in v1.0.29
func (nt *NamedTuple2E[A, B]) Get(name string) interface{}
func (*NamedTuple2E[A, B]) Unpack ¶ added in v1.0.29
func (nt *NamedTuple2E[A, B]) Unpack() (A, B)
type NamedTuple3E ¶ added in v1.0.29
type NamedTuple3E[A any, B any, C any] struct { NamedTuple2E[A, B] E3 C }
func NewNamedTuple3E ¶ added in v1.0.29
func (*NamedTuple3E[A, B, C]) Get ¶ added in v1.0.29
func (nt *NamedTuple3E[A, B, C]) Get(name string) interface{}
func (*NamedTuple3E[A, B, C]) Unpack ¶ added in v1.0.29
func (nt *NamedTuple3E[A, B, C]) Unpack() (A, B, C)
type NamedTuple4E ¶ added in v1.0.29
type NamedTuple4E[A any, B any, C any, D any] struct { NamedTuple3E[A, B, C] E4 D }
func NewNamedTuple4E ¶ added in v1.0.29
func (*NamedTuple4E[A, B, C, D]) Get ¶ added in v1.0.29
func (nt *NamedTuple4E[A, B, C, D]) Get(name string) interface{}
func (*NamedTuple4E[A, B, C, D]) Unpack ¶ added in v1.0.29
func (nt *NamedTuple4E[A, B, C, D]) Unpack() (A, B, C, D)
type NamedTuple5E ¶ added in v1.0.29
func NewNamedTuple5E ¶ added in v1.0.29
func (*NamedTuple5E[A, B, C, D, E]) Get ¶ added in v1.0.29
func (nt *NamedTuple5E[A, B, C, D, E]) Get(name string) interface{}
func (*NamedTuple5E[A, B, C, D, E]) Unpack ¶ added in v1.0.29
func (nt *NamedTuple5E[A, B, C, D, E]) Unpack() (A, B, C, D, E)
type Node ¶ added in v1.0.17
type Node[K, V any] struct { // contains filtered or unexported fields }
Node is a list node
type Option ¶ added in v1.0.17
type Option func(option *Options)
Option is a function used to set Options
func WithMaxLevel ¶ added in v1.0.17
WithMaxLevel sets max level of Skiplist
type Options ¶ added in v1.0.17
type Options struct {
// contains filtered or unexported fields
}
Options holds Skiplist's options
type OrderSet ¶ added in v1.0.53
func NewOrderSet ¶ added in v1.0.53
func OrderSetFromSet ¶ added in v1.0.53
func OrderSetFromSet[K ttypes.Ordered](set BuiltinSet[K]) *OrderSet[K]
func OrderSetFromUnpack ¶ added in v1.0.53
func (*OrderSet[K]) Clear ¶ added in v1.0.53
func (o *OrderSet[K]) Clear()
Clear implements the Container interface.
func (*OrderSet[K]) Difference ¶ added in v1.0.53
Difference returns a new set with elements in the set that are not in other.
func (*OrderSet[K]) ForEach ¶ added in v1.0.53
func (o *OrderSet[K]) ForEach(cb func(k K))
ForEach implements the Set interface.
func (*OrderSet[K]) Intersection ¶ added in v1.0.53
Intersection returns a new set with elements common to the set and other.
func (*OrderSet[K]) IsDisjointOf ¶ added in v1.0.53
IsDisjointOf return True if the set has no elements in common with other. Sets are disjoint if and only if their intersection is the empty set.
func (*OrderSet[K]) IsSubsetOf ¶ added in v1.0.53
IsSubsetOf tests whether every element in the set is in other.
func (*OrderSet[K]) IsSupersetOf ¶ added in v1.0.53
IsSupersetOf tests whether every element in other is in the set.
type Queue ¶ added in v1.0.1
type Queue[T any] struct { // contains filtered or unexported fields }
Queue represents a single instance of the queue data structure.
func (*Queue[T]) Add ¶ added in v1.0.1
func (q *Queue[T]) Add(elem T)
Add puts an element on the end of the queue.
func (*Queue[T]) Get ¶ added in v1.0.1
Get returns the element at index i in the queue. If the index is invalid, the call will panic. This method accepts both positive and negative index values. Index 0 refers to the first element, and index -1 refers to the last.
func (*Queue[T]) Length ¶ added in v1.0.1
Length returns the number of elements currently stored in the queue.
type SList ¶ added in v1.0.17
type SList[T any] struct { // contains filtered or unexported fields }
SList is a singly linked list.
func SListFromUnpack ¶ added in v1.0.52
SListFromUnpack return a SList that contains values.
func SListIterFilter ¶ added in v1.0.53
SListIterFilter Looks through each value in the list, returning a list of all the values that pass a truth test (predicate).
func SListIterMapCopy ¶ added in v1.0.53
SListIterMapCopy Produces a new list by mapping each value in list through a transformation function (iterate).
func SListIterMapInPlace ¶ added in v1.0.53
SListIterMapInPlace Iterates over list, yielding each value in turn to an iterate function, Returns the list for chaining.
func SetToSList ¶ added in v1.0.52
func SetToSList[K comparable](u BuiltinSet[K]) *SList[K]
SetToSList SetToList convert set to list
func (*SList[T]) Back ¶ added in v1.0.17
func (l *SList[T]) Back() T
Back returns the last element in the list.
func (*SList[T]) Clear ¶ added in v1.0.17
func (l *SList[T]) Clear()
Clear erases all elements from the container. After this call, Len() returns zero.
func (*SList[T]) ForEach ¶ added in v1.0.17
func (l *SList[T]) ForEach(cb func(T))
ForEach iterate the list, apply each element to the cb callback function.
func (*SList[T]) ForEachIf ¶ added in v1.0.17
ForEachIf iterate the container, apply each element to the cb callback function, stop if cb returns false.
func (*SList[T]) ForEachMutable ¶ added in v1.0.17
func (l *SList[T]) ForEachMutable(cb func(*T))
ForEachMutable iterate the container, apply pointer of each element to the cb callback function.
func (*SList[T]) ForEachMutableIf ¶ added in v1.0.17
ForEachMutableIf iterate the container, apply pointer of each element to the cb callback function, stop if cb returns false.
func (*SList[T]) Front ¶ added in v1.0.17
func (l *SList[T]) Front() T
Front returns the first element in the list.
func (*SList[T]) InsertLessBound ¶ added in v1.0.53
func (*SList[T]) Iterate ¶ added in v1.0.17
func (l *SList[T]) Iterate() MutableIterator[T]
Iterate returns an iterator to the whole container.
func (*SList[T]) PopFront ¶ added in v1.0.17
func (l *SList[T]) PopFront() T
PopFront popups an element from the front of the list. The list must be non-empty!
func (*SList[T]) PopTail ¶ added in v1.0.53
func (l *SList[T]) PopTail() T
PopTail popups an element from the tail of the list. The list must be non-empty!
func (*SList[T]) PushBack ¶ added in v1.0.17
func (l *SList[T]) PushBack(v T)
PushBack pushed an element to the tail of the list.
func (*SList[T]) PushFront ¶ added in v1.0.17
func (l *SList[T]) PushFront(v T)
PushFront pushed an element to the front of the list.
func (*SList[T]) RemoveValue ¶ added in v1.0.53
type Skiplist ¶ added in v1.0.17
type Skiplist[K, V any] struct { // contains filtered or unexported fields }
Skiplist is a kind of data structure which can search quickly by exchanging space for time
func NewSkipList ¶ added in v1.0.17
NewSkipList news a Skiplist
func (*Skiplist[K, V]) Get ¶ added in v1.0.17
Get returns the value associated with the passed key if the key is in the skiplist, otherwise returns error
func (*Skiplist[K, V]) Insert ¶ added in v1.0.17
func (sl *Skiplist[K, V]) Insert(key K, value V)
Insert inserts a key-value pair into the skiplist
func (*Skiplist[K, V]) Keys ¶ added in v1.0.17
func (sl *Skiplist[K, V]) Keys() []K
Keys returns all keys in the skiplist
func (*Skiplist[K, V]) Len ¶ added in v1.0.17
Len returns the amount of key-value pair in the skiplist
type Stack ¶ added in v1.0.1
type Stack[T any] struct { // contains filtered or unexported fields }
Stack s is a container adaptor that provides the functionality of a stack, a LIFO (last-in, first-out) data structure.
func NewStackCap ¶ added in v1.0.1
NewStackCap creates a new Stack object with the specified capacity.
func (*Stack[T]) Clear ¶ added in v1.0.1
func (s *Stack[T]) Clear()
Clear implements the Container interface.
func (*Stack[T]) Pop ¶ added in v1.0.1
func (s *Stack[T]) Pop() T
Pop popups an element from the top of the stack. It must be called when IsEmpty() returned false, otherwise it will panic.
func (*Stack[T]) Push ¶ added in v1.0.1
func (s *Stack[T]) Push(t T)
Push pushes the element to the top of the stack.
type Tuple3E ¶ added in v1.0.1
func NewTuple3E ¶ added in v1.0.1
type Tuple4E ¶ added in v1.0.1
func NewTuple4E ¶ added in v1.0.1
type Tuple5E ¶ added in v1.0.1
func NewTuple5E ¶ added in v1.0.1
type TupleName ¶ added in v1.0.29
type TupleName struct {
// contains filtered or unexported fields
}
type WaitFor ¶ added in v1.0.4
type WaitFor[T comparable] struct { // contains filtered or unexported fields }
WaitFor holds the data to add and the time it should be added
type WaitForPriorityQueue ¶ added in v1.0.4
type WaitForPriorityQueue[T comparable] struct { // contains filtered or unexported fields }
WaitForPriorityQueue implements a priority queue for WaitFor items.
WaitForPriorityQueue implements heap.Interface. The item occurring next in time (i.e., the item with the smallest readyAt) is at the root (index 0). Peek returns this minimum item at index 0. Pop returns the minimum item after it has been removed from the queue and placed at index Len()-1 by container/heap. Push adds an item at index Len(), and container/heap percolates it into the correct location.
func NewWaitForPriorityQueue ¶ added in v1.0.4
func NewWaitForPriorityQueue[T comparable]() *WaitForPriorityQueue[T]
func (*WaitForPriorityQueue[T]) Len ¶ added in v1.0.4
func (pq *WaitForPriorityQueue[T]) Len() int
func (*WaitForPriorityQueue[T]) Peek ¶ added in v1.0.4
func (pq *WaitForPriorityQueue[T]) Peek() *WaitFor[T]
Peek returns the item at the beginning of the queue, without removing the item or otherwise mutating the queue. It is safe to call directly.
func (*WaitForPriorityQueue[T]) Pop ¶ added in v1.0.4
func (pq *WaitForPriorityQueue[T]) Pop() *WaitFor[T]
Pop 弹出优先级队列元素
func (*WaitForPriorityQueue[T]) Push ¶ added in v1.0.4
func (pq *WaitForPriorityQueue[T]) Push(entry *WaitFor[T], ignore bool)
Push adds the entry to the priority queue, or updates the readyAt if it already exists in the queue