Documentation ¶
Index ¶
- type Vec
- func (v *Vec[T]) BinarySearch(target T) (int, bool)
- func (v *Vec[T]) BinarySearchFunc(target T, cmp func(val T, target T) int) (int, bool)
- func (v *Vec[T]) Cap() int
- func (v *Vec[T]) Clear() *Vec[T]
- func (v *Vec[T]) Clip() *Vec[T]
- func (v *Vec[T]) Clone() *Vec[T]
- func (v *Vec[T]) CloneToSlice() []T
- func (v *Vec[T]) CmpEqual(v1, v2 T) bool
- func (v *Vec[T]) CmpLess(v1, v2 T) bool
- func (v *Vec[T]) Compact() *Vec[T]
- func (v *Vec[T]) CompactFunc(eq func(T, T) bool)
- func (v *Vec[T]) Compare(other Vec[T]) int
- func (v *Vec[T]) CompareFunc(other Vec[T], cmpLess, cmpEqual func(T, T) bool) int
- func (v *Vec[T]) ConpareAndRemove(i int, val T) (e T, ok bool)
- func (v *Vec[T]) Contains(val T) bool
- func (v *Vec[T]) ContainsFunc(cmp func(v T) (matched bool)) bool
- func (v *Vec[T]) Cut(i, j int) (e []T)
- func (v *Vec[T]) Delete(i, j int)
- func (v *Vec[T]) Equal(i, j int) bool
- func (v *Vec[T]) EqualSlice(other []T) bool
- func (v *Vec[T]) EqualSliceFunc(other []T, eq func(T, T) bool) bool
- func (v *Vec[T]) EqualVec(other Vec[T]) bool
- func (v *Vec[T]) EqualVecFunc(other Vec[T], eq func(T, T) bool) bool
- func (v *Vec[T]) First() (e T, ok bool)
- func (v *Vec[T]) Get(i int) (e T, ok bool)
- func (v *Vec[T]) Grow(n int) *Vec[T]
- func (v *Vec[T]) Insert(i int, val ...T) *Vec[T]
- func (v *Vec[T]) IsEmpty() bool
- func (v *Vec[T]) IsSorted() bool
- func (v *Vec[T]) IsSortedFunc(cmpLess, cmpEqual func(T, T) bool) bool
- func (v *Vec[T]) Last() (e T, ok bool)
- func (v *Vec[T]) Len() int
- func (v *Vec[T]) Less(i, j int) bool
- func (v *Vec[T]) Max() T
- func (v *Vec[T]) MaxFunc(cmpLess, cmpEqual func(T, T) bool) T
- func (v *Vec[T]) Min() T
- func (v *Vec[T]) MinFunc(cmpLess, cmpEqual func(T, T) bool) T
- func (v *Vec[T]) Pop() (e T, ok bool)
- func (v *Vec[T]) Push(val ...T) *Vec[T]
- func (v *Vec[T]) Range(cbk func(i int, val T) (Continue bool))
- func (v *Vec[T]) Remove(i int) (e T, ok bool)
- func (v *Vec[T]) Replace(i int, j int, val ...T)
- func (v *Vec[T]) Reverse() *Vec[T]
- func (v *Vec[T]) Search(target T) (index int)
- func (v *Vec[T]) SearchAll(target T) (indexs []int)
- func (v *Vec[T]) SearchAllFunc(cbk func(v T) (Matched bool)) (indexs []int)
- func (v *Vec[T]) SearchFunc(cbk func(v T) (Matched bool)) (index int)
- func (v *Vec[T]) Set(i int, val T) (ok bool)
- func (v *Vec[T]) SetCmpEqual(cmpEqual func(T, T) bool) *Vec[T]
- func (v *Vec[T]) SetCmpLess(cmpLess func(T, T) bool) *Vec[T]
- func (v *Vec[T]) Slice() []T
- func (v *Vec[T]) SliceCut(i, j int) []T
- func (v *Vec[T]) Sort() *Vec[T]
- func (v *Vec[T]) SortFunc(cmpLess, cmpEqual func(T, T) bool) *Vec[T]
- func (v *Vec[T]) SortStable() *Vec[T]
- func (v *Vec[T]) SortStableFunc(cmpLess, cmpEqual func(T, T) bool) *Vec[T]
- func (v *Vec[T]) SplitOff(i int) *Vec[T]
- func (v *Vec[T]) Swap(i, j int)
- type VecConf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Vec ¶
type Vec[T any] struct { // contains filtered or unexported fields }
func (*Vec[T]) BinarySearch ¶
BinarySearch searches for target in a sorted slice and returns the position where target is found, or the position where target would appear in the sort order;
it also returns a bool saying whether the target is really found in the slice.
The slice must be sorted in increasing order.
func (*Vec[T]) BinarySearchFunc ¶
func (*Vec[T]) CloneToSlice ¶
func (v *Vec[T]) CloneToSlice() []T
func (*Vec[T]) Compact ¶
Compact removes all identical adjacent elements. Only the first element of each group of equal elements is preserved. Must be sorted, Called after sorting.
func (*Vec[T]) CompactFunc ¶
Compact removes all identical adjacent elements. Only the first element of each group of equal elements is preserved. Must be sorted, Called after sorting.
func (*Vec[T]) Compare ¶
returns 0 the result is 0 if len(s1) == len(s2), -1 if len(s1) < len(s2), and +1 if len(s1) > len(s2).
func (*Vec[T]) CompareFunc ¶
func (*Vec[T]) ConpareAndRemove ¶
ConpareAndRemove removes the element at index i if it is equal to val.
func (*Vec[T]) ContainsFunc ¶
func (*Vec[T]) EqualSlice ¶
func (*Vec[T]) EqualSliceFunc ¶
func (*Vec[T]) Grow ¶
After Grow(n), at least n elements can be appended to the slice without another allocation.
func (*Vec[T]) Insert ¶
Insert into constraints.Ordered position.
if i < 0 or i out of range, panic.
func (*Vec[T]) IsSortedFunc ¶
func (*Vec[T]) SearchAllFunc ¶
func (*Vec[T]) SearchFunc ¶
func (*Vec[T]) SetCmpEqual ¶
func (*Vec[T]) SetCmpLess ¶
func (*Vec[T]) Sort ¶
Sort sorts a vec of any ordered type in ascending order.
When sorting floating-point numbers, NaNs are ordered before other values.
func (*Vec[T]) SortStable ¶
SortStableFunc sorts the vec x while keeping the original order of equal elements, using cmp to compare elements in the same way as SortFunc.