Documentation
¶
Overview ¶
Package slices implements the functions, types, and interfaces for the module.
Index ¶
- Variables
- func Append[T types.Slice[S], S E](arr T, v S) (T, int)
- func Contains[T types.Slice[S], S E](s, sub T) bool
- func ContainsArray[T types.Slice[S], S E](s T, e S) bool
- func CopyAt[T types.Slice[S], S E](s, t T, i int) T
- func Count[T types.Slice[S], S E](s, sub T) int
- func CountArray[T types.Slice[S], S E](ss T, s S) int
- func Cut[T types.Slice[S], S E](s, sep T) (before, after T, found bool)
- func Equal[T types.Slice[S], S E](a, b T) bool
- func HasPrefix[T types.Slice[S], S E](s, prefix T) bool
- func HasSuffix[T types.Slice[S], S E](s, suffix T) bool
- func Index[T types.Slice[S], S E](s, sep T) int
- func IndexArray[T types.Slice[S], S E](s T, r S) int
- func InsertWith[T types.Slice[S], S E](s T, v S, fn func(a, b S) bool) T
- func Join[T types.Slice[S], S E](s []T, sep T) T
- func LastIndex[T types.Slice[S], S E](s, sep T) int
- func LastIndexArray[T types.Slice[S], S E](s T, c S) int
- func OverWithError[S any](s []S, err error) func(func(int, S) bool)
- func Read[T types.Slice[S], S E](arr T, offset int, limit int) T
- func RemoveWith[T types.Slice[S], S E](s T, fn func(a S) bool) T
- func Repeat[T types.Slice[S], S E](b T, count int) T
- func Transform[TS types.Slice[S], S any, T any](s TS, f func(S) (T, bool)) []T
- type Bytes
- type E
- type Runes
- type Slicer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTooLarge is an error when number is too large than length ErrTooLarge = errors.New("slices.Array: number is too large than length") // ErrTooSmall is an error when number is too small than length ErrTooSmall = errors.New("slices.Array: number is too small than length") // ErrWrongIndex is an error when index is out of range ErrWrongIndex = errors.New("slices.Array: wrong index") )
Functions ¶
func ContainsArray ¶
ContainsArray reports whether any Unicode code points in chars are within s.
func Count ¶
Count counts the number of non-overlapping instances of substr in s. If substr is an empty Array, Count returns 1 + the number of Unicode code points in s.
func CountArray ¶
CountArray counts the number of non-overlapping instances of c in s.
func Cut ¶
Cut slices s around the first instance of sep, returning the text before and after sep. The found result reports whether sep appears in s. If sep does not appear in s, cut returns s, "", false.
func Equal ¶
Equal reports whether a and b are the same length and contain the same runes. A nil argument is equivalent to an empty slice.
func Index ¶
Index returns the index of the first instance of substr in s, or -1 if substr is not present in s.
func IndexArray ¶
IndexArray returns the index of the first instance of the runes point r, or -1 if rune is not present in s.
func InsertWith ¶
InsertWith inserts v into s at the first index where fn(a, b) is true.
func Join ¶
Join concatenates the elements of its first argument to create a single Array[S]. The separator Array[S] sep is placed between elements in the resulting Array[S].
func LastIndex ¶
LastIndex returns the index of the last instance of substr in s, or -1 if substr is not present in s.
func LastIndexArray ¶
LastIndexArray returns the index of the last instance of c in s, or -1 if c is not present in s.
func Read ¶
Read returns a slice of the Array[S] s beginning at offset and length limit. If offset or limit is negative, it is treated as if it were zero.
func RemoveWith ¶
RemoveWith removes the first index where fn(a, b) is true.
Types ¶
type Bytes ¶
type Bytes []byte
func StringToBytes ¶
func (Bytes) FindString ¶
func (Bytes) StringArray ¶
type Runes ¶
type Runes []rune