Documentation
¶
Index ¶
- Constants
- type Float32
- func (slc Float32) Chunk(size int) [][]float32
- func (slc Float32) Contains(needle float32) bool
- func (slc Float32) Each(f func(float32))
- func (slc Float32) Filter(f func(float32) bool) Float32
- func (slc Float32) IfEach(f func(float32) bool) (int, bool)
- func (slc Float32) IndexOf(needle float32) int
- func (slc Float32) Map(f func(float32) float32)
- func (slc Float32) Reverse() Float32
- func (slc Float32) SortAsc() Float32
- func (slc Float32) SortDesc() Float32
- func (slc Float32) TryEach(f func(float32) error) (int, error)
- func (slc Float32) Unique() Float32
- func (slc Float32) Value() []float32
- type Float64
- func (slc Float64) Chunk(size int) [][]float64
- func (slc Float64) Contains(needle float64) bool
- func (slc Float64) Each(f func(float64))
- func (slc Float64) Filter(f func(float64) bool) Float64
- func (slc Float64) IfEach(f func(float64) bool) (int, bool)
- func (slc Float64) IndexOf(needle float64) int
- func (slc Float64) Map(f func(float64) float64)
- func (slc Float64) Reverse() Float64
- func (slc Float64) SortAsc() Float64
- func (slc Float64) SortDesc() Float64
- func (slc Float64) TryEach(f func(float64) error) (int, error)
- func (slc Float64) Unique() Float64
- func (slc Float64) Value() []float64
- type Int
- func (slc Int) Chunk(size int) [][]int
- func (slc Int) Contains(needle int) bool
- func (slc Int) Each(f func(int))
- func (slc Int) Filter(f func(int) bool) Int
- func (slc Int) IfEach(f func(int) bool) (int, bool)
- func (slc Int) IndexOf(needle int) int
- func (slc Int) Map(f func(int) int)
- func (slc Int) Reverse() Int
- func (slc Int) SortAsc() Int
- func (slc Int) SortDesc() Int
- func (slc Int) TryEach(f func(int) error) (int, error)
- func (slc Int) Unique() Int
- func (slc Int) Value() []int
- type Int16
- func (slc Int16) Chunk(size int) [][]int16
- func (slc Int16) Contains(needle int16) bool
- func (slc Int16) Each(f func(int16))
- func (slc Int16) Filter(f func(int16) bool) Int16
- func (slc Int16) IfEach(f func(int16) bool) (int, bool)
- func (slc Int16) IndexOf(needle int16) int
- func (slc Int16) Map(f func(int16) int16)
- func (slc Int16) Reverse() Int16
- func (slc Int16) SortAsc() Int16
- func (slc Int16) SortDesc() Int16
- func (slc Int16) TryEach(f func(int16) error) (int, error)
- func (slc Int16) Unique() Int16
- func (slc Int16) Value() []int16
- type Int32
- func (slc Int32) Chunk(size int) [][]int32
- func (slc Int32) Contains(needle int32) bool
- func (slc Int32) Each(f func(int32))
- func (slc Int32) Filter(f func(int32) bool) Int32
- func (slc Int32) IfEach(f func(int32) bool) (int, bool)
- func (slc Int32) IndexOf(needle int32) int
- func (slc Int32) Map(f func(int32) int32)
- func (slc Int32) Reverse() Int32
- func (slc Int32) SortAsc() Int32
- func (slc Int32) SortDesc() Int32
- func (slc Int32) TryEach(f func(int32) error) (int, error)
- func (slc Int32) Unique() Int32
- func (slc Int32) Value() []int32
- type Int64
- func (slc Int64) Chunk(size int) [][]int64
- func (slc Int64) Contains(needle int64) bool
- func (slc Int64) Each(f func(int64))
- func (slc Int64) Filter(f func(int64) bool) Int64
- func (slc Int64) IfEach(f func(int64) bool) (int, bool)
- func (slc Int64) IndexOf(needle int64) int
- func (slc Int64) Map(f func(int64) int64)
- func (slc Int64) Reverse() Int64
- func (slc Int64) SortAsc() Int64
- func (slc Int64) SortDesc() Int64
- func (slc Int64) TryEach(f func(int64) error) (int, error)
- func (slc Int64) Unique() Int64
- func (slc Int64) Value() []int64
- type Int8
- func (slc Int8) Chunk(size int) [][]int8
- func (slc Int8) Contains(needle int8) bool
- func (slc Int8) Each(f func(int8))
- func (slc Int8) Filter(f func(int8) bool) Int8
- func (slc Int8) IfEach(f func(int8) bool) (int, bool)
- func (slc Int8) IndexOf(needle int8) int
- func (slc Int8) Map(f func(int8) int8)
- func (slc Int8) Reverse() Int8
- func (slc Int8) SortAsc() Int8
- func (slc Int8) SortDesc() Int8
- func (slc Int8) TryEach(f func(int8) error) (int, error)
- func (slc Int8) Unique() Int8
- func (slc Int8) Value() []int8
- type String
- func (slc String) Chunk(size int) [][]string
- func (slc String) Contains(needle string) bool
- func (slc String) Each(f func(string))
- func (slc String) Filter(f func(string) bool) String
- func (slc String) IfEach(f func(string) bool) (int, bool)
- func (slc String) IndexOf(needle string) int
- func (slc String) Map(f func(string) string)
- func (slc String) Reverse() String
- func (slc String) SortAsc() String
- func (slc String) SortDesc() String
- func (slc String) TryEach(f func(string) error) (int, error)
- func (slc String) Unique() String
- func (slc String) Value() []string
- type UInt
- func (slc UInt) Chunk(size int) [][]uint
- func (slc UInt) Contains(needle uint) bool
- func (slc UInt) Each(f func(uint))
- func (slc UInt) Filter(f func(uint) bool) UInt
- func (slc UInt) IfEach(f func(uint) bool) (int, bool)
- func (slc UInt) IndexOf(needle uint) int
- func (slc UInt) Map(f func(uint) uint)
- func (slc UInt) Reverse() UInt
- func (slc UInt) SortAsc() UInt
- func (slc UInt) SortDesc() UInt
- func (slc UInt) TryEach(f func(uint) error) (int, error)
- func (slc UInt) Unique() UInt
- func (slc UInt) Value() []uint
- type UInt16
- func (slc UInt16) Chunk(size int) [][]uint16
- func (slc UInt16) Contains(needle uint16) bool
- func (slc UInt16) Each(f func(uint16))
- func (slc UInt16) Filter(f func(uint16) bool) UInt16
- func (slc UInt16) IfEach(f func(uint16) bool) (int, bool)
- func (slc UInt16) IndexOf(needle uint16) int
- func (slc UInt16) Map(f func(uint16) uint16)
- func (slc UInt16) Reverse() UInt16
- func (slc UInt16) SortAsc() UInt16
- func (slc UInt16) SortDesc() UInt16
- func (slc UInt16) TryEach(f func(uint16) error) (int, error)
- func (slc UInt16) Unique() UInt16
- func (slc UInt16) Value() []uint16
- type UInt32
- func (slc UInt32) Chunk(size int) [][]uint32
- func (slc UInt32) Contains(needle uint32) bool
- func (slc UInt32) Each(f func(uint32))
- func (slc UInt32) Filter(f func(uint32) bool) UInt32
- func (slc UInt32) IfEach(f func(uint32) bool) (int, bool)
- func (slc UInt32) IndexOf(needle uint32) int
- func (slc UInt32) Map(f func(uint32) uint32)
- func (slc UInt32) Reverse() UInt32
- func (slc UInt32) SortAsc() UInt32
- func (slc UInt32) SortDesc() UInt32
- func (slc UInt32) TryEach(f func(uint32) error) (int, error)
- func (slc UInt32) Unique() UInt32
- func (slc UInt32) Value() []uint32
- type UInt64
- func (slc UInt64) Chunk(size int) [][]uint64
- func (slc UInt64) Contains(needle uint64) bool
- func (slc UInt64) Each(f func(uint64))
- func (slc UInt64) Filter(f func(uint64) bool) UInt64
- func (slc UInt64) IfEach(f func(uint64) bool) (int, bool)
- func (slc UInt64) IndexOf(needle uint64) int
- func (slc UInt64) Map(f func(uint64) uint64)
- func (slc UInt64) Reverse() UInt64
- func (slc UInt64) SortAsc() UInt64
- func (slc UInt64) SortDesc() UInt64
- func (slc UInt64) TryEach(f func(uint64) error) (int, error)
- func (slc UInt64) Unique() UInt64
- func (slc UInt64) Value() []uint64
- type UInt8
- func (slc UInt8) Chunk(size int) [][]uint8
- func (slc UInt8) Contains(needle uint8) bool
- func (slc UInt8) Each(f func(uint8))
- func (slc UInt8) Filter(f func(uint8) bool) UInt8
- func (slc UInt8) IfEach(f func(uint8) bool) (int, bool)
- func (slc UInt8) IndexOf(needle uint8) int
- func (slc UInt8) Map(f func(uint8) uint8)
- func (slc UInt8) Reverse() UInt8
- func (slc UInt8) SortAsc() UInt8
- func (slc UInt8) SortDesc() UInt8
- func (slc UInt8) TryEach(f func(uint8) error) (int, error)
- func (slc UInt8) Unique() UInt8
- func (slc UInt8) Value() []uint8
Examples ¶
Constants ¶
const (
// NotInSlice signifies that the searched element is not in a slice
NotInSlice = -1
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Float32 ¶
type Float32 []float32
Float32 is the alias of []float32
func (Float32) Chunk ¶
Chunk will divide the slice of float32 into smaller slicify defined by chunk length
func (Float32) Each ¶
Each will apply a function to each float32 in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
func (Float32) Filter ¶
Filter will return all float32 values that evaluate true in the user-supplied function
func (Float32) IfEach ¶
IfEach will apply a function to each float32 in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (Float32) Map ¶
Map will apply a function to each float32 in the slice and replace the previous value
func (Float32) TryEach ¶
TryEach will apply a function to each float32 in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.
type Float64 ¶
type Float64 []float64
Float64 is the alias of []float64
func (Float64) Chunk ¶
Chunk will divide the slice of float64 into smaller slicify defined by chunk length
func (Float64) Each ¶
Each will apply a function to each float64 in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
func (Float64) Filter ¶
Filter will return all float64 values that evaluate true in the user-supplied function
func (Float64) IfEach ¶
IfEach will apply a function to each float64 in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (Float64) Map ¶
Map will apply a function to each float64 in the slice and replace the previous value
func (Float64) TryEach ¶
TryEach will apply a function to each float64 in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.
type Int ¶
type Int []int
Int is the alias of []int
func (Int) Each ¶
Each will apply a function to each int in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
func (Int) Filter ¶
Filter will return all int values that evaluate true in the user-supplied function
func (Int) IfEach ¶
IfEach will apply a function to each int in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (Int) TryEach ¶
TryEach will apply a function to each int in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.
type Int16 ¶
type Int16 []int16
Int16 is the alias of []int16
func (Int16) Chunk ¶
Chunk will divide the slice of int16 into smaller slicify defined by chunk length
func (Int16) Each ¶
Each will apply a function to each int16 in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
func (Int16) Filter ¶
Filter will return all int16 values that evaluate true in the user-supplied function
func (Int16) IfEach ¶
IfEach will apply a function to each int16 in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (Int16) Map ¶
Map will apply a function to each int16 in the slice and replace the previous value
func (Int16) TryEach ¶
TryEach will apply a function to each int16 in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.
type Int32 ¶
type Int32 []int32
Int32 is the alias of []int32
func (Int32) Chunk ¶
Chunk will divide the slice of int32 into smaller slicify defined by chunk length
func (Int32) Each ¶
Each will apply a function to each int32 in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
func (Int32) Filter ¶
Filter will return all int32 values that evaluate true in the user-supplied function
func (Int32) IfEach ¶
IfEach will apply a function to each int32 in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (Int32) Map ¶
Map will apply a function to each int32 in the slice and replace the previous value
func (Int32) TryEach ¶
TryEach will apply a function to each int32 in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.
type Int64 ¶
type Int64 []int64
Int64 is the alias of []int64
func (Int64) Chunk ¶
Chunk will divide the slice of int64 into smaller slicify defined by chunk length
func (Int64) Each ¶
Each will apply a function to each int64 in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
func (Int64) Filter ¶
Filter will return all int64 values that evaluate true in the user-supplied function
func (Int64) IfEach ¶
IfEach will apply a function to each int64 in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (Int64) Map ¶
Map will apply a function to each int64 in the slice and replace the previous value
func (Int64) TryEach ¶
TryEach will apply a function to each int64 in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.
type Int8 ¶
type Int8 []int8
Int8 is the alias of []int8
func (Int8) Chunk ¶
Chunk will divide the slice of int8 into smaller slicify defined by chunk length
func (Int8) Each ¶
Each will apply a function to each int8 in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
func (Int8) Filter ¶
Filter will return all int8 values that evaluate true in the user-supplied function
func (Int8) IfEach ¶
IfEach will apply a function to each int8 in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (Int8) Map ¶
Map will apply a function to each int8 in the slice and replace the previous value
func (Int8) TryEach ¶
TryEach will apply a function to each int8 in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.
type String ¶
type String []string
String is the alias of []string
func (String) Chunk ¶
Chunk will divide the slice of string into smaller slicify defined by chunk length
Example ¶
package main import ( "fmt" "github.com/schigh/slice" ) func main() { slc := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"} chunks := slice.String(slc).Chunk(4) for _, chunk := range chunks { fmt.Printf("%v\n", chunk) } }
Output: [a b c d] [e f g h] [i j k l] [m]
func (String) Each ¶
Each will apply a function to each string in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
Example ¶
package main import ( "fmt" "sync/atomic" "github.com/schigh/slice" ) func main() { var v atomic.Value v.Store("") slc := []string{"h", "e", "l", "l", "o", ",", " ", "w", "o", "r", "l", "d", "!"} slice.String(slc).Each(func(s string) { vv := v.Load().(string) vv = vv + s v.Store(vv) }) vv := v.Load().(string) fmt.Println(vv) }
Output: hello, world!
func (String) Filter ¶
Filter will return all string values that evaluate true in the user-supplied function
Example ¶
package main import ( "fmt" "github.com/schigh/slice" ) func main() { slc := []string{"foo", "bar", "baz", "fizz", "buzz"} // starts with f fslice := slice.String(slc).Filter(func(s string) bool { return s != "" && s[0] == 'f' }) // starts with b bslice := slice.String(slc).Filter(func(s string) bool { return s != "" && s[0] == 'b' }) fmt.Printf("%v\n", fslice) fmt.Printf("%v\n", bslice) }
Output: [foo fizz] [bar baz buzz]
func (String) IfEach ¶
IfEach will apply a function to each string in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (String) Map ¶
Map will apply a function to each string in the slice and replace the previous value
Example ¶
package main import ( "fmt" "strings" "github.com/schigh/slice" ) func main() { slc := []string{"foo", "bar", "baz", "fizz", "buzz"} slice.String(slc).Map(func(s string) string { return strings.ToUpper(s) }) fmt.Printf("%v\n", slc) }
Output: [FOO BAR BAZ FIZZ BUZZ]
func (String) TryEach ¶
TryEach will apply a function to each string in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.
type UInt ¶
type UInt []uint
UInt is the alias of []uint
func (UInt) Chunk ¶
Chunk will divide the slice of uint into smaller slicify defined by chunk length
func (UInt) Each ¶
Each will apply a function to each uint in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
func (UInt) Filter ¶
Filter will return all uint values that evaluate true in the user-supplied function
func (UInt) IfEach ¶
IfEach will apply a function to each uint in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (UInt) Map ¶
Map will apply a function to each uint in the slice and replace the previous value
func (UInt) TryEach ¶
TryEach will apply a function to each uint in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.
type UInt16 ¶
type UInt16 []uint16
UInt16 is the alias of []uint16
func (UInt16) Chunk ¶
Chunk will divide the slice of uint16 into smaller slicify defined by chunk length
func (UInt16) Each ¶
Each will apply a function to each uint16 in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
func (UInt16) Filter ¶
Filter will return all uint16 values that evaluate true in the user-supplied function
func (UInt16) IfEach ¶
IfEach will apply a function to each uint16 in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (UInt16) Map ¶
Map will apply a function to each uint16 in the slice and replace the previous value
func (UInt16) TryEach ¶
TryEach will apply a function to each uint16 in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.
type UInt32 ¶
type UInt32 []uint32
UInt32 is the alias of []uint32
func (UInt32) Chunk ¶
Chunk will divide the slice of uint32 into smaller slicify defined by chunk length
func (UInt32) Each ¶
Each will apply a function to each uint32 in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
func (UInt32) Filter ¶
Filter will return all uint32 values that evaluate true in the user-supplied function
func (UInt32) IfEach ¶
IfEach will apply a function to each uint32 in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (UInt32) Map ¶
Map will apply a function to each uint32 in the slice and replace the previous value
func (UInt32) TryEach ¶
TryEach will apply a function to each uint32 in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.
type UInt64 ¶
type UInt64 []uint64
UInt64 is the alias of []uint64
func (UInt64) Chunk ¶
Chunk will divide the slice of uint64 into smaller slicify defined by chunk length
func (UInt64) Each ¶
Each will apply a function to each uint64 in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
func (UInt64) Filter ¶
Filter will return all uint64 values that evaluate true in the user-supplied function
func (UInt64) IfEach ¶
IfEach will apply a function to each uint64 in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (UInt64) Map ¶
Map will apply a function to each uint64 in the slice and replace the previous value
func (UInt64) TryEach ¶
TryEach will apply a function to each uint64 in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.
type UInt8 ¶
type UInt8 []uint8
UInt8 is the alias of []uint8
func (UInt8) Chunk ¶
Chunk will divide the slice of uint8 into smaller slicify defined by chunk length
func (UInt8) Each ¶
Each will apply a function to each uint8 in the slice. This function will iterate over the slice completely. No items in the slice should be mutated by this operation.
func (UInt8) Filter ¶
Filter will return all uint8 values that evaluate true in the user-supplied function
func (UInt8) IfEach ¶
IfEach will apply a function to each uint8 in the slice. If the function returns false, the iteration will stop and return the index of the element that caused the function to return false. The second returned value will be true if all members of the slice cause the provided function to return true, and false otherwise. No items in the slice should be mutated by this operation.
func (UInt8) Map ¶
Map will apply a function to each uint8 in the slice and replace the previous value
func (UInt8) TryEach ¶
TryEach will apply a function to each uint8 in the slice. If the function returns an error, the iteration will stop and return the index of the element that caused the function to return the error. The second returned value will be first error returned from the supplied function, and nil otherwise. No items in the slice should be mutated by this operation.