Documentation
¶
Index ¶
- func All[S Slice[S, E], E any](slice S) iter.Seq2[int, E]
- func Append[S Slice[S, E], E any](slice S, elems ...E) S
- func AppendSeq[S Slice[S, E], E any](s S, seq iter.Seq[E]) S
- func Backward[S Slice[S, E], E any](s S) iter.Seq2[int, E]
- func BinarySearchFunc[S Slice[S, E], E, T any](x S, target T, cmp func(E, T) int) (int, bool)
- func Chunk[S Slice[S, E], E any](s S, n int) iter.Seq[S]
- func Clear[S Slice[S, E], E any](slice S)
- func Clip[S Slice[S, E], E any](s S) S
- func Clone[S Slice[S, E], E any](s S) S
- func Collect[S Slice[S, E], E any](seq iter.Seq[E]) S
- func Compact[S Slice[S, E], E comparable](s S) S
- func CompactFunc[S Slice[S, E], E any](s S, eq func(E, E) bool) S
- func CompareFunc[S1 Slice[S1, E1], S2 Slice[S2, E2], E1, E2 any](s1 S1, s2 S2, cmp func(E1, E2) int) int
- func Concat[S Slice[S, E], E any](slices ...S) S
- func Contains[S Slice[S, E], E comparable](s S, v E) bool
- func ContainsFunc[S Slice[S, E], E any](s S, f func(E) bool) bool
- func Copy[S Slice[S, E], E any](dst, src S) int
- func Delete[S Slice[S, E], E any](s S, i, j int) S
- func DeleteFunc[S Slice[S, E], E any](s S, del func(E) bool) S
- func Equal[S Slice[S, E], E comparable](s1, s2 S) bool
- func EqualFunc[S1 Slice[S1, E1], S2 Slice[S2, E2], E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool
- func Grow[S Slice[S, E], E any](s S, n int) S
- func Index[S Slice[S, E], E comparable](s S, v E) int
- func IndexFunc[S Slice[S, E], E any](s S, f func(E) bool) int
- func Insert[S Slice[S, E], E any](s S, i int, v ...E) S
- func IsSortedFunc[S Slice[S, E], E any](x S, cmp func(a, b E) int) bool
- func Make[S Slice[S, E], E any](len, cap int) S
- func MaxFunc[S Slice[S, E], E any](x S, cmp func(a, b E) int) E
- func MinFunc[S Slice[S, E], E any](x S, cmp func(a, b E) int) E
- func Repeat[S Slice[S, E], E any](x S, count int) S
- func Replace[S Slice[S, E], E any](s S, i, j int, v ...E) S
- func Reverse[S Slice[S, E], E any](s S)
- func SortFunc[S Slice[S, E], E any](x S, cmp func(a, b E) int)
- func SortStableFunc[S Slice[S, E], E any](x S, cmp func(a, b E) int)
- func SortedFunc[S Slice[S, E], E any](seq iter.Seq[E], cmp func(E, E) int) S
- func SortedStableFunc[S Slice[S, E], E any](seq iter.Seq[E], cmp func(E, E) int) S
- func Values[S Slice[S, E], E any](s S) iter.Seq[E]
- type Slice
- type Slicer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Backward ¶
Backward returns an iterator over index-value pairs in the slice, traversing it backward with descending indices.
func BinarySearchFunc ¶
BinarySearchFunc searches for target in a sorted Slice.
func Compact ¶
func Compact[S Slice[S, E], E comparable](s S) S
Compact removes duplicates from the slice.
func CompactFunc ¶
CompactFunc removes duplicates from the slice comparing the elements with the given function.
func CompareFunc ¶
func CompareFunc[S1 Slice[S1, E1], S2 Slice[S2, E2], E1, E2 any](s1 S1, s2 S2, cmp func(E1, E2) int) int
CompareFunc compares 2 slices.
func Contains ¶
func Contains[S Slice[S, E], E comparable](s S, v E) bool
Contains checks if the slice contains the element.
func ContainsFunc ¶
ContainsFunc checks if the slice contains an element that satisfies the predicate.
func DeleteFunc ¶
DeleteFunc deletes elements that satisfy the predicate.
func Equal ¶
func Equal[S Slice[S, E], E comparable](s1, s2 S) bool
Equal checks equality of two slices.
func EqualFunc ¶
func EqualFunc[S1 Slice[S1, E1], S2 Slice[S2, E2], E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool
EqualFunc checks equality of two slices by a predicate.
func Index ¶
func Index[S Slice[S, E], E comparable](s S, v E) int
Index returns the index of the first occurrence of the element if it exists. Otherwise, it returns -1.
func IndexFunc ¶
IndexFunc returns the index of the first occurrence of the element that satisfies the predicate. If not exists, it returns -1.
func IsSortedFunc ¶
IsSortedFunc checks if the elements are sorted.
func SortStableFunc ¶
SortStableFunc stable sorts the slice.
func SortedFunc ¶
SortedFunc collects values from seq into a new sorted slice.
func SortedStableFunc ¶
SortedStableFunc collects values from seq into a new stable-sorted slice.
Types ¶
type Slice ¶
type Slice[S Slicer[S, E], E any] interface { Slicer[S, E] // Get gets the value of the index. i.e. s[n] Get(int) E // Set sets the value of the index. i.e. s[n] = v Set(int, E) // Len returns the length of the slice. i.e. len(s) Len() int // Cap returns the capacity of the slice. i.e. cap(s) Cap() int }
Slice is a structure-of-arrays slice derived from a struct E.