Documentation ¶
Index ¶
- func Clone[T any](src []T) []T
- func Filter[I any](slice []I, f func(index int, value I) (keep bool)) []I
- func FilterOn[I any](slice *[]I, f func(index int, value I) (keep bool))
- func Foreach(slice interface{}, f func(i int, v interface{}))
- func Map[I, O any](input []I, f func(index int, value I) O) []O
- func Reduce[I, V any](slice []I, initReduceValue V, f func(reduceValue V, index int, value I) V) (reduceValue V)
- func ToMap[I any, K comparable, V any](slice []I, kf func(I) K, vf func(I) V) map[K]V
- func ToMapItself[I any, K comparable](slice []I, kf func(I) K) map[K]I
- type BidirectionalManyToManyMap
- func (m *BidirectionalManyToManyMap[K, V]) DeleteKey(k K)
- func (m *BidirectionalManyToManyMap[K, V]) DeleteValue(v V)
- func (m *BidirectionalManyToManyMap[K, V]) Insert(k K, v V)
- func (m *BidirectionalManyToManyMap[K, V]) Keys() []K
- func (m *BidirectionalManyToManyMap[K, V]) KeysOf(v V) map[K]struct{}
- func (m *BidirectionalManyToManyMap[K, V]) Values(k K) []V
- func (m *BidirectionalManyToManyMap[K, V]) ValuesOf(k K) map[V]struct{}
- type KV
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToMap ¶
func ToMap[I any, K comparable, V any](slice []I, kf func(I) K, vf func(I) V) map[K]V
ToMap convert a slice to a map if vf is nil, will try to use elem of slice as value
func ToMapItself ¶ added in v0.2.0
func ToMapItself[I any, K comparable](slice []I, kf func(I) K) map[K]I
ToMapItself convert a slice to a map like ToMap, but the value of map is the elem of slice itself
Types ¶
type BidirectionalManyToManyMap ¶ added in v0.2.5
type BidirectionalManyToManyMap[K, V comparable] struct { // contains filtered or unexported fields }
func (*BidirectionalManyToManyMap[K, V]) DeleteKey ¶ added in v0.2.5
func (m *BidirectionalManyToManyMap[K, V]) DeleteKey(k K)
func (*BidirectionalManyToManyMap[K, V]) DeleteValue ¶ added in v0.2.5
func (m *BidirectionalManyToManyMap[K, V]) DeleteValue(v V)
func (*BidirectionalManyToManyMap[K, V]) Insert ¶ added in v0.2.5
func (m *BidirectionalManyToManyMap[K, V]) Insert(k K, v V)
func (*BidirectionalManyToManyMap[K, V]) Keys ¶ added in v0.2.5
func (m *BidirectionalManyToManyMap[K, V]) Keys() []K
func (*BidirectionalManyToManyMap[K, V]) KeysOf ¶ added in v0.2.5
func (m *BidirectionalManyToManyMap[K, V]) KeysOf(v V) map[K]struct{}
should not write to returned map
func (*BidirectionalManyToManyMap[K, V]) Values ¶ added in v0.2.5
func (m *BidirectionalManyToManyMap[K, V]) Values(k K) []V
func (*BidirectionalManyToManyMap[K, V]) ValuesOf ¶ added in v0.2.5
func (m *BidirectionalManyToManyMap[K, V]) ValuesOf(k K) map[V]struct{}
should not write to returned map
type KV ¶
type KV[K comparable, V any] struct { Key K Value V }
func KVsOfMap ¶
func KVsOfMap[K comparable, V any](m map[K]V) []KV[K, V]
KVsOfMap return a kv slice from map
Click to show internal directories.
Click to hide internal directories.