Documentation ¶
Index ¶
- type Map
- func (slf Map[K, V]) Clear() Map[K, V]
- func (slf Map[K, V]) Delete(key K) Map[K, V]
- func (slf Map[K, V]) Distinct(handle func(key K, value V) bool) Map[K, V]
- func (slf Map[K, V]) Filter(handle func(key K, value V) bool) Map[K, V]
- func (slf Map[K, V]) FilterKey(keys ...K) Map[K, V]
- func (slf Map[K, V]) FilterValue(values ...V) Map[K, V]
- func (slf Map[K, V]) GetValueOr(key K, value V) V
- func (slf Map[K, V]) Merge(maps ...map[K]V) Map[K, V]
- func (slf Map[K, V]) RandomDelete(n int) Map[K, V]
- func (slf Map[K, V]) RandomKeep(n int) Map[K, V]
- func (slf Map[K, V]) RandomReplace(values ...V) Map[K, V]
- func (slf Map[K, V]) Range(handle func(key K, value V) bool) Map[K, V]
- func (slf Map[K, V]) Set(key K, value V) Map[K, V]
- func (slf Map[K, V]) ToMap() map[K]V
- func (slf Map[K, V]) ToSliceStream() Slice[V]
- func (slf Map[K, V]) ToSliceStreamWithKey() Slice[K]
- func (slf Map[K, V]) ToSyncMap() *concurrent.BalanceMap[K, V]
- func (slf Map[K, V]) ValueOr(key K, value V) Map[K, V]
- type Slice
- func (slf Slice[V]) Clear() Slice[V]
- func (slf Slice[V]) ContainsHandle(value V, handle func(slice Slice[V]) Slice[V]) Slice[V]
- func (slf Slice[V]) Delete(index int) Slice[V]
- func (slf Slice[V]) Distinct() Slice[V]
- func (slf Slice[V]) Filter(handle func(index int, value V) bool) Slice[V]
- func (slf Slice[V]) FilterIndex(indexes ...int) Slice[V]
- func (slf Slice[V]) FilterValue(values ...V) Slice[V]
- func (slf Slice[V]) GetEndPart(n int) Slice[V]
- func (slf Slice[V]) GetPart(start, end int) Slice[V]
- func (slf Slice[V]) GetStartPart(n int) Slice[V]
- func (slf Slice[V]) Merge(values ...V) Slice[V]
- func (slf Slice[V]) RandomDelete(n int) Slice[V]
- func (slf Slice[V]) RandomKeep(n int) Slice[V]
- func (slf Slice[V]) Reverse() Slice[V]
- func (slf Slice[V]) Set(index int, value V) Slice[V]
- func (slf Slice[V]) Shuffle() Slice[V]
- func (slf Slice[V]) ToMapStream() Map[int, V]
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] map[K]V
Map 提供了 map 的链式操作
func WithMap ¶
func WithMap[K comparable, V any](m map[K]V) Map[K, V]
WithMap 使用传入的 map 执行链式操作
- 该函数将会直接影响到传入的 map
Example ¶
package main import ( "fmt" "github.com/kercylan98/minotaur/utils/stream" ) func main() { m := stream.WithMap(map[int]string{1: "a", 2: "b", 3: "c", 4: "d", 5: "d"}).Filter(func(key int, value string) bool { return key > 3 }) fmt.Println(len(m)) }
Output: 2
func WithMapCopy ¶
func WithMapCopy[K comparable, V any](m map[K]V) Map[K, V]
WithMapCopy 使用传入的 map 执行链式操作
- 该函数不会影响到传入的 map
Example ¶
package main import ( "fmt" "github.com/kercylan98/minotaur/utils/stream" ) func main() { m := stream.WithMapCopy(map[int]string{1: "a", 2: "b", 3: "c", 4: "d", 5: "d"}).Filter(func(key int, value string) bool { return key > 3 }) fmt.Println(len(m)) }
Output: 2
func (Map[K, V]) FilterValue ¶
FilterValue 过滤特定的 value
func (Map[K, V]) GetValueOr ¶
func (slf Map[K, V]) GetValueOr(key K, value V) V
GetValueOr 当 key 不存在时,返回一个默认值
func (Map[K, V]) RandomDelete ¶
RandomDelete 随机删除 n 个元素
func (Map[K, V]) RandomKeep ¶
RandomKeep 随机保留 n 个元素
func (Map[K, V]) RandomReplace ¶
RandomReplace 将 values 覆盖到当前的 map 中
- 如果 values 的长度大于当前 map 的长度,则只会覆盖当前 map 的长度
func (Map[K, V]) ToSliceStream ¶
ToSliceStream 将当前 Map stream 转换为 Slice stream
func (Map[K, V]) ToSliceStreamWithKey ¶
ToSliceStreamWithKey 将当前 Map stream 转换为 Slice stream,key 为 Slice 的元素
func (Map[K, V]) ToSyncMap ¶
func (slf Map[K, V]) ToSyncMap() *concurrent.BalanceMap[K, V]
ToSyncMap 将当前 Map 转换为 concurrent.BalanceMap
type Slice ¶
type Slice[V any] []V
Slice 提供了 slice 的链式操作
func (Slice[V]) ContainsHandle ¶
ContainsHandle 如果包含指定的元素则执行 handle
func (Slice[V]) FilterIndex ¶
FilterIndex 过滤特定的 index
func (Slice[V]) FilterValue ¶
FilterValue 过滤特定的 value
func (Slice[V]) GetStartPart ¶
GetStartPart 获取前 n 个元素
func (Slice[V]) RandomDelete ¶
RandomDelete 随机删除 n 个元素
func (Slice[V]) ToMapStream ¶
ToMapStream 将当前的 Slice stream 转换为 Map stream
Click to show internal directories.
Click to hide internal directories.