slices

package
v0.0.0-...-202847b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2023 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Overview

Package slices contains functions for working on specific slice types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Int64

type Int64 []int64

Int64Slice contains Map/Filter/Reduce/Sort/Unique/etc method receivers for []int64. @todo think about the necessary gen functions +gen slice:"Where,Count,GroupBy[int64]"

func (Int64) All

func (l Int64) All(f func(int64) bool) bool

All returns true if all of the int64s in the slice satisfy the predicate f.

func (Int64) Any

func (l Int64) Any(f func(int64) bool) bool

Any returns true if one of the int64s in the slice satisfies the predicate f.

func (*Int64) Append

func (l *Int64) Append(s ...int64) Int64

Append adds s (variadic) to the Int64Slice

func (Int64) Contains

func (l Int64) Contains(t int64) bool

Contains returns true if the target int64 t is in the slice.

func (*Int64) Delete

func (l *Int64) Delete(i int) error

Delete removes index i from slice

func (Int64) Index

func (l Int64) Index(t int64) int

Index returns -1 if not found or the current index for target t.

func (Int64) Len

func (l Int64) Len() int

Len returns the length

func (Int64) Less

func (l Int64) Less(i, j int) bool

Less compares two slice values

func (*Int64) Map

func (l *Int64) Map(f func(int64) int64) Int64

Map changes itself containing the results of applying the function f to each int64 in itself.

func (*Int64) Reduce

func (l *Int64) Reduce(f func(int64) bool) Int64

Reduce reduces itself containing all int64s in the slice that satisfy the predicate f.

func (Int64) Reverse

func (l Int64) Reverse() Int64

Reverse is a convenience method.

func (Int64) Sort

func (l Int64) Sort() Int64

Sort is a convenience method.

func (Int64) Sum

func (l Int64) Sum() int64

Sum returns the sum

func (Int64) Swap

func (l Int64) Swap(i, j int)

Swap changes the position

func (Int64) ToInt64

func (l Int64) ToInt64() []int64

ToInt64 converts to type int64 slice.

func (*Int64) Unique

func (l *Int64) Unique() Int64

Unique removes duplicate entries in O(n)

func (*Int64) Update

func (l *Int64) Update(i int, s int64) error

Update sets the int64 s on index i. If index is not found returns an fatal error behaviour.

type String

type String []string

String contains Map/Filter/Reduce/Sort/Unique/etc method receivers for []string.

func (String) All

func (l String) All(f func(string) bool) bool

All returns true if all of the strings in the slice satisfy the predicate f.

func (String) Any

func (l String) Any(f func(string) bool) bool

Any returns true if one of the strings in the slice satisfies the predicate f.

func (*String) Append

func (l *String) Append(s ...string) String

Append adds s (variadic) to the StringSlice

func (String) Contains

func (l String) Contains(t string) bool

Contains returns true if the target string t is in the slice.

func (String) ContainsReverse

func (l String) ContainsReverse(s string) bool

ContainsReverse checks if the StringSlice has at least one occurrence in the string s.

func (*String) Delete

func (l *String) Delete(i int) error

Delete removes index i from slice

func (String) Filter

func (l String) Filter(f func(string) bool) String

Filter filters all strings in the slice that satisfy the predicate f and returns a new slice.

func (String) Index

func (l String) Index(t string) int

Index returns -1 if not found or the current index for target t.

func (String) Join

func (l String) Join(sep string) string

Join joins the slice using a separator.

func (String) Len

func (l String) Len() int

Len returns the length

func (String) Less

func (l String) Less(i, j int) bool

Less compares two slice values

func (*String) Map

func (l *String) Map(f func(string) string) String

Map changes itself containing the results of applying the function f to each string in itself.

func (*String) Reduce

func (l *String) Reduce(f func(string) bool) String

Reduce reduces itself containing all strings in the slice that satisfy the predicate f.

func (*String) ReduceContains

func (l *String) ReduceContains(in ...string) String

ReduceContains reduces itself if the parts of the in slice are contained within itself.

func (*String) Shuffle

func (l *String) Shuffle() String

Shuffle destroys the order

func (String) Sort

func (l String) Sort() String

Sort is a convenience method.

func (*String) Split

func (l *String) Split(s, sep string) String

Split uses string s and a separator and appends the parts to the slice.

func (*String) SplitStringer8

func (l *String) SplitStringer8(n string, ps ...uint8) String

SplitStringer8 uses a name and position indexes to split the name and appends the parts to the slice. Cracking the names and indexes which the stringer command generates.

func (String) StartsWithReverse

func (l String) StartsWithReverse(s string) bool

StartsWithReverse checks if the StringSlice can be found at least once in the provided string s.

func (String) Swap

func (l String) Swap(i, j int)

Swap changes the position

func (String) ToString

func (l String) ToString() []string

ToString converts to string slice.

func (*String) Unique

func (l *String) Unique() String

Unique removes duplicate entries and discards "" empty strings.

func (*String) Update

func (l *String) Update(i int, s string) error

Update sets the string s on index i. If index is not found returns an fatal error behaviour.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL