Documentation ¶
Index ¶
- func Contains[T comparable](srcs []T, e T) bool
- func ContainsFunc[T any](srcs []T, fn func(src T) bool) bool
- func First[T any](srcs []T) T
- func Last[T any](srcs []T) T
- func Reduce[T, E any](srcs []T, fn func(dst E, src T) E) E
- func Some[T any](srcs []T, fn func(src T) bool) bool
- type Slice
- func Chunk[T any](srcs []T, size int) []Slice[T]
- func Delete[T any](srcs []T, i int) Slice[T]
- func Excludes[T comparable](base []T, target []T) Slice[T]
- func Filter[T any](srcs []T, fn func(src T) bool) Slice[T]
- func FilterMap[T, E any](srcs []T, fn func(src T) (bool, E)) Slice[E]
- func FilterMapWithIndex[T, E any](srcs []T, fn func(index int) (bool, E)) Slice[E]
- func FilterWithIndex[T any](srcs []T, fn func(index int) bool) Slice[T]
- func ForEach[T any](srcs []T, fn func(src T)) Slice[T]
- func Insert[T any](srcs []T, i int, v ...T) Slice[T]
- func Map[T, E any](srcs []T, fn func(src T) E) Slice[E]
- func MapWithIndex[T, E any](srcs []T, fn func(index int) E) Slice[E]
- func NewSlice[T any](srcs []T) Slice[T]
- func Pop[T any](srcs []T) (T, Slice[T])
- func Shift[T any](srcs []T) (T, Slice[T])
- func Shuffle[T any](srcs []T) Slice[T]
- func Sort[T any](srcs []T, fn func(i, j int) bool) Slice[T]
- func Uniq[T comparable](srcs []T) Slice[T]
- func (s Slice[T]) Chunk(size int) []Slice[T]
- func (s Slice[T]) ContainsFunc(fn func(src T) bool) bool
- func (s Slice[T]) Delete(i int) Slice[T]
- func (s Slice[T]) Filter(fn func(src T) bool) Slice[T]
- func (s Slice[T]) FilterWithIndex(fn func(index int) bool) Slice[T]
- func (s Slice[T]) First() T
- func (s Slice[T]) ForEach(fn func(src T)) Slice[T]
- func (s Slice[T]) Insert(i int, v ...T) Slice[T]
- func (s Slice[T]) Last() T
- func (s Slice[T]) Len() int
- func (s Slice[T]) Pop() (T, Slice[T])
- func (s Slice[T]) Shift() (T, Slice[T])
- func (s Slice[T]) Shuffle() Slice[T]
- func (s Slice[T]) Some(fn func(src T) bool) bool
- func (s Slice[T]) Sort(fn func(i, j int) bool) Slice[T]
- type Stream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsFunc ¶ added in v1.5.0
ContainsFunc ... 配列に要素が含まれているか
Types ¶
type Slice ¶ added in v1.5.1
type Slice[T any] []T
func Excludes ¶
func Excludes[T comparable](base []T, target []T) Slice[T]
Excludes ... 配列で指定したbaseの中でtargetに含まれない値の配列を取得
func FilterMapWithIndex ¶ added in v1.5.8
FilterMapWithIndex ... Filter して Map する
func FilterWithIndex ¶ added in v1.5.1
FilterWithIndex ... 条件に合う要素のみを抽出する
func MapWithIndex ¶ added in v1.5.1
MapWithIndex ... 配列の要素を変換する
func (Slice[T]) ContainsFunc ¶ added in v1.5.1
ContainsFunc ... 配列に要素が含まれているか
func (Slice[T]) FilterWithIndex ¶ added in v1.5.1
FilterWithIndex ... 条件に合う要素のみを抽出する
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func (*Stream) Contains ¶
dst := StreamOf(hoges).
Contains(func(hoge *Hoge) bool { return hoge.ID == "abc" })
要素の存在確認
func (*Stream) Filter ¶
dst := StreamOf(hoges).
Filter(func(hoge *Hoge) bool { return hoge.Num > 3 }).Out().([]*Hoge)
要素のフィルタリング
func (*Stream) ForEach ¶
dst := StreamOf(hoges).
ForEach(func(hoge *Hoge, i int) { hoge.ID = "abc" })
要素のループ
func (*Stream) Map ¶
dst := StreamOf(hoges).
Map(func(hoge *Hoge) string { return hoge.ID }).Out().([]string)
要素の変換
Click to show internal directories.
Click to hide internal directories.