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 FpEachMap[K comparable, V any](a map[K]V, iterate func(a map[K]V, k K, v V) V) map[K]V
- func FpEachSlice[T any](a []T, iterate func(a []T, i int) T) []T
- func FpEveryList[T any](a DList[T], iterate func(a DList[T], node T) bool) bool
- func FpEveryMap[K comparable, V any](a map[K]V, iterate func(a map[K]V, k K, v V) bool) bool
- func FpEverySet[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T) bool) bool
- func FpEverySlice[T any](a []T, iterate func(a []T, i int) bool) bool
- func FpFilterMap[K comparable, V any](a map[K]V, iterate func(a map[K]V, k K, v V) bool) map[K]V
- func FpFilterSlice[T any](a []T, iterate func(a []T, i int) bool) []T
- func FpIterList[T any](a DList[T], iterate func(a DList[T], node T))
- func FpIterMap[K comparable, V any](a map[K]V, iterate func(a map[K]V, k K, v V))
- func FpIterSet[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T))
- func FpIterSlice[T any](a []T, iterate func(a []T, i int))
- func FpMapMap[K comparable, V any](a map[K]V, iterate func(a map[K]V, k K, v V) (K, V)) map[K]V
- func FpMapSlice[T any](a []T, iterate func(a []T, i int) T) []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 FpPartitionList[T any](a DList[T], iterate func(a DList[T], node T) bool) (DList[T], DList[T])
- func FpPartitionMap[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 FpPartitionSet[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T) bool) (BuiltinSet[T], BuiltinSet[T])
- func FpPartitionSlice[T any](a []T, iterate func(a []T, i int) bool) ([]T, []T)
- func MapEqualCounter[V comparable](c map[V]int, other map[V]int) bool
- func MapKeyToSlice[T comparable, V any](a map[T]V) []T
- func MapMerge[K comparable, V any](m1 map[K]V, m2 map[K]V) map[K]V
- func MapRemoveEmptyString[K comparable](m map[K]interface{}) map[K]interface{}
- func MapValueToSlice[T comparable, V any](a map[T]V) []V
- func MapZipSliceToMap[T comparable, V any](a []T, b []V) (map[T]V, error)
- func SetToSlice[K comparable](u BuiltinSet[K]) []K
- func SliceAbsoluteEqual[T comparable](a []T, b []T) bool
- func SliceBinarySearch[T ttypes.Ordered](data []T, value T) int
- func SliceConvertToInt(data interface{}) ([]int, error)
- func SliceConvertToInt64(data interface{}) ([]int64, error)
- func SliceConvertToString(data interface{}) ([]string, error)
- func SliceCopy[T any](data []T, ns ...int) []T
- func SliceExclude[T comparable](a []T, b T) bool
- func SliceFilter[T any](a []T, filter func(i int) bool) []T
- func SliceGroupByCounter[V comparable](data []V) map[V]int
- func SliceGroupByHandler[K comparable, V any](data []V, getKeyHandler func(int) K) map[K][]V
- func SliceGroupByValue[V comparable](data []V) map[V][]V
- func SliceGroupIntoSlice[V ttypes.Ordered](data []V) [][]V
- func SliceInclude[T comparable](a []T, b T) bool
- func SliceIndex[T comparable](a []T, b T) int
- func SliceIndexOrder[T ttypes.Ordered](a []T, b T) int
- func SliceInsert[T any](data *[]T, i int, x ...T)
- func SliceLogicalEqual[T comparable](a []T, b []T) bool
- 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 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 SlicePopBack[T any](data *[]T) (T, bool)
- func SliceRemove[T comparable](data *[]T, b T)
- func SliceRemoveIndex[T any](data *[]T, i int)
- func SliceRemoveRange[T any](data *[]T, i int, j int)
- func SliceReplace[T comparable](data []T, a T, b T)
- func SliceReverse[T any](data []T)
- func SliceReverseCopy[T any](data []T) []T
- func SliceShuffle[T any](data []T)
- func SliceTail[T any](data []T, d ...T) T
- func SliceTwoDiff[T comparable](a []T, b []T) ([]T, []T)
- func SliceUnique[T comparable](data []T) []T
- func SliceUnpackInclude[T comparable](a T, others ...T) bool
- func SliceUnpackMax[T ttypes.Ordered](data ...T) T
- func SliceUnpackMin[T ttypes.Ordered](data ...T) T
- 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 StrSplitNth(str string, sep string, total int, nth int) string
- type Bitmap
- type BuiltinSet
- func FpEachSet[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T) T) BuiltinSet[T]
- func FpFilterSet[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T) bool) BuiltinSet[T]
- func FpMapSet[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T) T) BuiltinSet[T]
- func NewSet[K comparable](n ...int) BuiltinSet[K]
- func SetFromSlice[K comparable](ks []K) BuiltinSet[K]
- func SetOf[K comparable](ks ...K) BuiltinSet[K]
- func (s BuiltinSet[K]) Clear()
- func (s BuiltinSet[K]) Delete(k K)
- func (s BuiltinSet[K]) Difference(other BuiltinSet[K]) BuiltinSet[K]
- 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 (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]) 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]) TryPopBack() (T, bool)
- func (l *DList[T]) TryPopFront() (T, bool)
- type Element
- type Iterator
- type MapCompareResult
- func MapComplexCompareWithKey[T comparable, V any](a map[T]V, b map[T]V, key T) MapCompareResult
- func MapComplexFullCompare[T comparable, V any](a map[T]V, b map[T]V) MapCompareResult
- func MapNativeCompareWithKey[T comparable, V ttypes.Ordered](a map[T]V, b map[T]V, key T) MapCompareResult
- func MapNativeFullCompare[T comparable, V ttypes.Ordered](a map[T]V, b map[T]V) MapCompareResult
- type MapLocker
- type MapRWLocker
- type MutableIterator
- type Node
- type Option
- type Options
- type Queue
- type SList
- 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]) 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]) PushBack(v T)
- func (l *SList[T]) PushFront(v T)
- func (l *SList[T]) Reverse()
- func (l *SList[T]) Values() []T
- type Skiplist
- type SortedMap
- type Stack
- type Tuple10E
- type Tuple2E
- type Tuple3E
- type Tuple4E
- type Tuple5E
- type Tuple6E
- type Tuple7E
- type Tuple8E
- type Tuple9E
- type WaitFor
- type WaitForPriorityQueue
Constants ¶
This section is empty.
Variables ¶
var ErrorNotFound = errors.New("not found")
Functions ¶
func FpEachMap ¶ added in v1.0.8
func FpEachMap[K comparable, V any](a map[K]V, iterate func(a map[K]V, k K, v V) V) map[K]V
FpEachMap Iterates over map, yielding each key, value in turn to an iterate function, Returns the map for chaining.
func FpEachSlice ¶ added in v1.0.8
FpEachSlice Iterates over a slice of elements, yielding each in turn to an iterate function, Returns the slice for chaining.
func FpEveryList ¶ added in v1.0.8
FpEveryList Returns true if all of the values pass the predicate truth test
func FpEveryMap ¶ added in v1.0.8
func FpEveryMap[K comparable, V any](a map[K]V, iterate func(a map[K]V, k K, v V) bool) bool
FpEveryMap Returns true if all of the values pass the predicate truth test
func FpEverySet ¶ added in v1.0.8
func FpEverySet[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T) bool) bool
FpEverySet Returns true if all of the values pass the predicate truth test
func FpEverySlice ¶ added in v1.0.8
FpEverySlice Returns true if all of the values pass the predicate truth test
func FpFilterMap ¶ added in v1.0.8
func FpFilterMap[K comparable, V any](a map[K]V, iterate func(a map[K]V, k K, v V) bool) map[K]V
FpFilterMap Looks through each value in the map, returning a map of all the values that pass a truth test (predicate).
func FpFilterSlice ¶ added in v1.0.8
FpFilterSlice Looks through each value in the slice, returning a slice of all the values that pass a truth test (predicate).
func FpIterList ¶ added in v1.0.8
FpIterList Iterate list by iterate func, do not modify list
func FpIterMap ¶ added in v1.0.8
func FpIterMap[K comparable, V any](a map[K]V, iterate func(a map[K]V, k K, v V))
FpIterMap Iterate map by iterate func, do not modify map
func FpIterSet ¶ added in v1.0.8
func FpIterSet[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T))
FpIterSet Iterate set by iterate func, do not modify set
func FpIterSlice ¶ added in v1.0.8
FpIterSlice Iterate slice by iterate func, do not modify slice
func FpMapMap ¶ added in v1.0.8
func FpMapMap[K comparable, V any](a map[K]V, iterate func(a map[K]V, k K, v V) (K, V)) map[K]V
FpMapMap Produces a new map by mapping each key, value in map through a transformation function (iterate).
func FpMapSlice ¶ added in v1.0.8
FpMapSlice Produces a new slice by mapping each value in list through a transformation function (iterate).
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 FpPartitionList ¶ added in v1.0.8
FpPartitionList Split list into two lists: one whose elements all satisfy predicate and one whose elements all do not satisfy predicate
func FpPartitionMap ¶ added in v1.0.8
func FpPartitionMap[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)
FpPartitionMap Split map into two maps: one whose elements all satisfy predicate and one whose elements all do not satisfy predicate
func FpPartitionSet ¶ added in v1.0.8
func FpPartitionSet[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T) bool) (BuiltinSet[T], BuiltinSet[T])
FpPartitionSet Split set into two sets: one whose elements all satisfy predicate and one whose elements all do not satisfy predicate
func FpPartitionSlice ¶ added in v1.0.8
FpPartitionSlice Split slice into two slices: one whose elements all satisfy predicate and one whose elements all do not satisfy predicate
func MapEqualCounter ¶ added in v1.0.7
func MapEqualCounter[V comparable](c map[V]int, other map[V]int) bool
func MapKeyToSlice ¶ added in v1.0.1
func MapKeyToSlice[T comparable, V any](a map[T]V) []T
MapKeyToSlice 提取map的key
func MapMerge ¶ added in v1.0.12
func MapMerge[K comparable, V any](m1 map[K]V, m2 map[K]V) map[K]V
MapMerge 合并两个map,如果key重复则以第二个元素中的key为主
func MapRemoveEmptyString ¶ added in v1.0.13
func MapRemoveEmptyString[K comparable](m map[K]interface{}) map[K]interface{}
MapRemoveEmptyString 删除空字符串的
func MapValueToSlice ¶ added in v1.0.1
func MapValueToSlice[T comparable, V any](a map[T]V) []V
MapValueToSlice 提取map的值
func MapZipSliceToMap ¶ added in v1.0.1
func MapZipSliceToMap[T comparable, V any](a []T, b []V) (map[T]V, error)
MapZipSliceToMap 两个slice,一个key,一个value转换为map
func SetToSlice ¶
func SetToSlice[K comparable](u BuiltinSet[K]) []K
SetToSlice convert from set to slice
func SliceAbsoluteEqual ¶
func SliceAbsoluteEqual[T comparable](a []T, b []T) bool
SliceAbsoluteEqual 判断两个slice是否一样,严格按照顺序比较
func SliceBinarySearch ¶ added in v1.0.7
SliceBinarySearch 二分搜索
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 SliceGroupByCounter ¶ added in v1.0.7
func SliceGroupByCounter[V comparable](data []V) map[V]int
SliceGroupByCounter 对元素按照Value进行进行计数
func SliceGroupByHandler ¶ added in v1.0.7
func SliceGroupByHandler[K comparable, V any](data []V, getKeyHandler func(int) K) map[K][]V
SliceGroupByHandler 对切片进行分类
func SliceGroupByValue ¶ added in v1.0.7
func SliceGroupByValue[V comparable](data []V) map[V][]V
SliceGroupByValue 对切片按照元素进行分类
func SliceGroupIntoSlice ¶ added in v1.0.7
SliceGroupIntoSlice 切片按照元素内容分成不同Slice
func SliceIndex ¶ added in v1.0.1
func SliceIndex[T comparable](a []T, b T) int
SliceIndex 获取元素在切片中的下标,如果不存在返回-1
func SliceIndexOrder ¶ added in v1.0.3
SliceIndexOrder 有序slice的元素搜索
func SliceInsert ¶ added in v1.0.3
SliceInsert 把元素插入到data的指定位置
func SliceLogicalEqual ¶
func SliceLogicalEqual[T comparable](a []T, b []T) bool
SliceLogicalEqual 判断两个Slice是否逻辑一样,和顺序无关
func SliceMaxNWithOrder ¶ added in v1.0.7
SliceMaxNWithOrder 按序返回切片中最大的N个元素
func SliceMinNWithOrder ¶ added in v1.0.7
SliceMinNWithOrder 有序返回切片中最小的N个元素
func SlicePopBack ¶ added in v1.0.3
SlicePopBack 弹出切片最后一个元素
func SliceRemove ¶ added in v1.0.1
func SliceRemove[T comparable](data *[]T, b T)
SliceRemove 原地删除元素
func SliceRemoveIndex ¶ added in v1.0.3
SliceRemoveIndex 删除某个索引位置的切片
func SliceRemoveRange ¶ added in v1.0.3
SliceRemoveRange 删除某个范围内的切片
func SliceReplace ¶ added in v1.0.1
func SliceReplace[T comparable](data []T, a T, b T)
SliceReplace 原地替换元素
func SliceReverseCopy ¶ added in v1.0.1
func SliceReverseCopy[T any](data []T) []T
SliceReverseCopy 转置切片并复制
func SliceTail ¶ added in v1.0.3
func SliceTail[T any](data []T, d ...T) T
SliceTail 获取切片最后一个元素,如果没有则用默认值
func SliceTwoDiff ¶ added in v1.0.6
func SliceTwoDiff[T comparable](a []T, b []T) ([]T, []T)
SliceTwoDiff 显示两个切片的区别
func SliceUnpackInclude ¶ added in v1.0.7
func SliceUnpackInclude[T comparable](a T, others ...T) bool
SliceUnpackInclude 判断第一个元素是否在后续元素集合中
func SliceUnpackMax ¶ added in v1.0.7
SliceUnpackMax 求最大值
func SliceUnpackMin ¶ added in v1.0.7
SliceUnpackMin 求最小值
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个元素
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 FpEachSet ¶ added in v1.0.8
func FpEachSet[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T) T) BuiltinSet[T]
FpEachSet Iterates over set, yielding each value in turn to an iterate function, Returns the set for chaining.
func FpFilterSet ¶ added in v1.0.8
func FpFilterSet[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T) bool) BuiltinSet[T]
FpFilterSet Looks through each value in the set, returning a set of all the values that pass a truth test (predicate).
func FpMapSet ¶ added in v1.0.8
func FpMapSet[T comparable](a BuiltinSet[T], iterate func(a BuiltinSet[T], node T) T) BuiltinSet[T]
FpMapSet Produces a new list by mapping each value in list through a transformation function (iterate).
func NewSet ¶
func NewSet[K comparable](n ...int) BuiltinSet[K]
func SetFromSlice ¶
func SetFromSlice[K comparable](ks []K) BuiltinSet[K]
SetFromSlice create a new BuiltinSet object with the initial content from slice.
func SetOf ¶
func SetOf[K comparable](ks ...K) BuiltinSet[K]
SetOf creates a new BuiltinSet object with the initial content from ks.
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]) 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]) 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 FpEachList ¶ added in v1.0.8
FpEachList Iterates over list, yielding each value in turn to an iterate function, Returns the list for chaining.
func FpFilterList ¶ added in v1.0.8
FpFilterList Looks through each value in the list, returning a list of all the values that pass a truth test (predicate).
func FpMapList ¶ added in v1.0.8
FpMapList Produces a new list by mapping each value in list through a transformation function (iterate).
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]) 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]) 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 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 MapComplexCompareWithKey ¶ added in v1.0.1
func MapComplexCompareWithKey[T comparable, V any](a map[T]V, b map[T]V, key T) MapCompareResult
MapComplexCompareWithKey 复杂值的key比较
func MapComplexFullCompare ¶ added in v1.0.1
func MapComplexFullCompare[T comparable, V any](a map[T]V, b map[T]V) MapCompareResult
MapComplexFullCompare 复杂值的全部比较
func MapNativeCompareWithKey ¶ added in v1.0.1
func MapNativeCompareWithKey[T comparable, V ttypes.Ordered](a map[T]V, b map[T]V, key T) MapCompareResult
MapNativeCompareWithKey 简单值的key比较
func MapNativeFullCompare ¶ added in v1.0.1
func MapNativeFullCompare[T comparable, V ttypes.Ordered](a map[T]V, b map[T]V) MapCompareResult
MapNativeFullCompare 简单值的全部比较
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 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 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 (*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]) 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]) 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.
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 SortedMap ¶
type SortedMap[K ttypes.Ordered, V any] struct { ReverseOpt bool Tuples []ttypes.Tuple[K, V] RawMap map[K]V }
SortedMap 有序Map,底层维护了有序切片 如果需要对map进行修改需要执行Rebuild来维护有序行,否则会导致不一致
func MapNewSortedMap ¶ added in v1.0.7
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 Tuple10E ¶ added in v1.0.1
type Tuple10E[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any] struct { Tuple9E[A, B, C, D, E, F, G, H, I] E10 J }
func NewTuple10E ¶ added in v1.0.1
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 Tuple6E ¶ added in v1.0.1
func NewTuple6E ¶ added in v1.0.1
type Tuple7E ¶ added in v1.0.1
type Tuple7E[A any, B any, C any, D any, E any, F any, G any] struct { Tuple6E[A, B, C, D, E, F] E7 G }
func NewTuple7E ¶ added in v1.0.1
type Tuple8E ¶ added in v1.0.1
type Tuple8E[A any, B any, C any, D any, E any, F any, G any, H any] struct { Tuple7E[A, B, C, D, E, F, G] E8 H }
func NewTuple8E ¶ added in v1.0.1
type Tuple9E ¶ added in v1.0.1
type Tuple9E[A any, B any, C any, D any, E any, F any, G any, H any, I any] struct { Tuple8E[A, B, C, D, E, F, G, H] E9 I }
func NewTuple9E ¶ added in v1.0.1
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