Documentation
¶
Index ¶
- func BinarySearch[T ttypes.Ordered](data []T, value T) int
- func Max[T ttypes.Ordered](data ...T) T
- func Min[T ttypes.Ordered](data ...T) T
- func SliceAbsoluteEqual[T comparable](a []T, b []T) bool
- func SliceCopy[T any](data []T) []T
- func SliceFilter[T any](a []T, filter func(v T) bool) []T
- func SliceLogicalEqual[T comparable](a []T, b []T) bool
- func SliceMap[T any](a []T, handler func(v *T))
- func SliceMax[T ttypes.Ordered](data []T) T
- func SliceMin[T ttypes.Ordered](data []T) T
- func SliceReverse[T any](data []T)
- func SliceUnique[T comparable](data []T) []T
- type BuiltinSet
- 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 CounterMap
- type GroupMap
- type ListNode
- type SortedMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SliceAbsoluteEqual ¶
func SliceAbsoluteEqual[T comparable](a []T, b []T) bool
SliceAbsoluteEqual 判断两个slice是否一样,严格按照顺序比较
func SliceLogicalEqual ¶
func SliceLogicalEqual[T comparable](a []T, b []T) bool
SliceLogicalEqual 判断两个Slice是否逻辑一样,和顺序无关
Types ¶
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 NewSet ¶
func NewSet[K comparable]() BuiltinSet[K]
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 CounterMap ¶
type CounterMap[K comparable] map[K]int
func NewCounterMap ¶
func NewCounterMap[K comparable](data []K) CounterMap[K]
func (CounterMap[K]) Equal ¶
func (c CounterMap[K]) Equal(other CounterMap[K]) bool
type GroupMap ¶
type GroupMap[K comparable, V any] map[K][]V
func NewGroupMap ¶
func NewGroupMap[K comparable, V any](data []V, getKeyHandler func(V) K) GroupMap[K, V]