Documentation
¶
Index ¶
- func FindPosition[T Number](p T) func(T) bool
- func Max[T Ordered](a, b T) bool
- func Min[T Ordered](a, b T) bool
- func OrderAsc[T Ordered](a, b T) bool
- func OrderDesc[T Ordered](a, b T) bool
- func OrderStructAsc[T OrderedStruct[T]](a, b T) bool
- func OrderStructDesc[T OrderedStruct[T]](a, b T) bool
- func Println[T any](v T)
- func Println2[K comparable, T any](k K, v T)
- func Sum[T Number](a, b T) T
- type List
- func (list List[T]) AllMatch(predicate func(T) bool) bool
- func (list List[T]) AnyMatch(predicate func(T) bool) bool
- func (list List[T]) Collect() []T
- func (list List[T]) Count() int
- func (list List[T]) DropWhile(predicate func(T) bool) Steam[T]
- func (list List[T]) Filter(predicate func(T) bool) Steam[T]
- func (list List[T]) FilterMap(predicate func(T) bool, mapper func(T) T) Steam[T]
- func (list List[T]) FilterMapToInt(predicate func(T) bool, mapper func(T) int) Steam[int]
- func (list List[T]) FilterMapToString(predicate func(T) bool, mapper func(T) string) Steam[string]
- func (list List[T]) FindFirst() nilo.Option[T]
- func (list List[T]) FindOne(predicate func(T) bool) nilo.Option[T]
- func (list List[T]) FlatMap(mapper func(T) Steam[T]) Steam[T]
- func (list List[T]) FlatMapToInt(mapper func(T) Steam[int]) Steam[int]
- func (list List[T]) FlatMapToString(mapper func(T) Steam[string]) Steam[string]
- func (list List[T]) ForEach(consumer func(T))
- func (list List[T]) ForEachWithIndex(consumer func(int, T))
- func (list List[T]) GetCompared(cmp func(T, T) bool) nilo.Option[T]
- func (list List[T]) Last() nilo.Option[T]
- func (list List[T]) Limit(limit int) Steam[T]
- func (list List[T]) Map(mapper func(T) T) Steam[T]
- func (list List[T]) MapToInt(mapper func(T) int) Steam[int]
- func (list List[T]) MapToString(mapper func(T) string) Steam[string]
- func (list List[T]) NoneMatch(predicate func(T) bool) bool
- func (list List[T]) Peek(consumer func(T)) Steam[T]
- func (list List[T]) Position(predicate func(T) bool) nilo.Option[int]
- func (list List[T]) Reduce(initValue T, acc func(T, T) T) T
- func (list List[T]) Reverse() Steam[T]
- func (list List[T]) Skip(n int) Steam[T]
- func (list List[T]) Sorted(cmp func(T, T) bool) Steam[T]
- func (list List[T]) TakeWhile(predicate func(T) bool) Steam[T]
- type Map
- func (m Map[K, V]) AllMatch(predicate func(K, V) bool) bool
- func (m Map[K, V]) AnyMatch(predicate func(K, V) bool) bool
- func (m Map[K, V]) Collect() map[K]V
- func (m Map[K, V]) Count() int
- func (m Map[K, V]) Filter(predicate func(K, V) bool) Steam2[K, V]
- func (m Map[K, V]) FilterMap(predicate func(K, V) bool, mapper func(K, V) V) Steam2[K, V]
- func (m Map[K, V]) FilterMapToInt(predicate func(K, V) bool, mapper func(K, V) int) Steam2[K, int]
- func (m Map[K, V]) FilterMapToString(predicate func(K, V) bool, mapper func(K, V) string) Steam2[K, string]
- func (m Map[K, V]) ForEach(consumer func(K, V))
- func (m Map[K, V]) GetCompared(cmp func(K, K) bool) nilo.Option[Pair[K, V]]
- func (m Map[K, V]) KeysToSteam() Steam[K]
- func (m Map[K, V]) Limit(limit int) Steam2[K, V]
- func (m Map[K, V]) Map(mapper func(K, V) V) Steam2[K, V]
- func (m Map[K, V]) MapToInt(mapper func(K, V) int) Steam2[K, int]
- func (m Map[K, V]) MapToString(mapper func(K, V) string) Steam2[K, string]
- func (m Map[K, V]) NoneMatch(predicate func(K, V) bool) bool
- func (m Map[K, V]) Peek(consumer func(K, V)) Steam2[K, V]
- func (m Map[K, V]) Sorted(cmp func(K, K) bool) Steam2[K, V]
- func (m Map[K, V]) ToAnySteam(mapper func(K, V) any) Steam[any]
- func (m Map[K, V]) ValuesToSteam() Steam[V]
- type Number
- type Ordered
- type OrderedStruct
- type Pair
- type Steam
- func CollectSteam2ToSteam[K comparable, V, R any](s Steam2[K, V], mapper func(K, V) R) Steam[R]
- func Distinct[T comparable](s Steam[T]) Steam[T]
- func FlatMapper[T, R any](s Steam[T], mapper func(T) Steam[R]) Steam[R]
- func Mapper[T, R any](s Steam[T], mapper func(T) R) Steam[R]
- func Of[T any](args ...T) Steam[T]
- func OfSlice[T any](slice []T) Steam[T]
- func Zip[T, R any](s1 Steam[T], s2 Steam[R]) ...
- type Steam2
- func CollectSteamToSteam2[K comparable, V, T any](s Steam[T], keyFunc func(T) K, valueFunc func(T) V) Steam2[K, V]
- func GroupBy[K comparable, V any](s Steam[V], classifier func(V) K) Steam2[K, Steam[V]]
- func GroupByCounting[K comparable, V any](s Steam[V], classifier func(V) K) Steam2[K, int]
- func OfMap[K comparable, V any](m map[K]V) Steam2[K, V]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindPosition ¶
FindPosition returns a function that checks if a given value x is equal to the specified position p. The returned function takes a single argument of type T and returns true if it matches p.
func Max ¶
Max returns true if the first argument a is less than the second argument b. It is intended to be used with types that implement the Ordered interface, which allows for comparison operations.
func Min ¶
Min returns true if the first argument a is greater than the second argument b. It is intended to be used with types that implement the Ordered interface, which allows for comparison operations.
func OrderAsc ¶
OrderAsc compares two Ordered values in ascending order. It returns true if the first value is greater than the second.
func OrderDesc ¶
OrderDesc compares two Ordered values in descending order. It returns true if the first value is less than the second.
func OrderStructAsc ¶
func OrderStructAsc[T OrderedStruct[T]](a, b T) bool
OrderStructAsc compares two OrderedStructs in ascending order. It returns true if the first struct is greater than the second.
func OrderStructDesc ¶
func OrderStructDesc[T OrderedStruct[T]](a, b T) bool
OrderStructDesc compares two OrderedStructs in descending order. It returns true if the first struct is less than the second.
func Println ¶
func Println[T any](v T)
Println prints the value of the provided argument v to the standard output. It can accept any type of value due to the use of a type parameter T.
func Println2 ¶
func Println2[K comparable, T any](k K, v T)
Println prints the values of the provided arguments k and v to the standard output. It can accept a comparable K value and any type to second value due to the use of a type parameter T.
Types ¶
type List ¶
type List[T any] []T
List is a generic type that represents a slice of elements of type T. It provides methods to perform various operations on the list, following a functional programming style.
func (List[T]) AllMatch ¶
AllMatch checks if all elements in the List match the provided predicate function. It returns true if all elements match, false otherwise.
func (List[T]) AnyMatch ¶
AnyMatch checks if any element in the List matches the provided predicate function. It returns true if at least one element matches, false otherwise.
func (List[T]) Collect ¶
func (list List[T]) Collect() []T
Collect returns the underlying slice of the List.
func (List[T]) DropWhile ¶
DropWhile returns a slice of List that skips elements from the start of the List as long as they match the provided predicate function. It includes all subsequent elements after the first non-matching element.
func (List[T]) Filter ¶
Filter returns a new List containing only the elements that match the provided predicate function.
func (List[T]) FilterMap ¶ added in v1.5.0
FilterMap filters the elements based on the provided predicate and then maps the remaining elements using the provided mapper function, returning the List modified of type T.
func (List[T]) FilterMapToInt ¶ added in v1.0.0
FilterMapToInt filters the elements based on the provided predicate and then maps the remaining elements using the provided mapper function, returning a new List of type int.
func (List[T]) FilterMapToString ¶ added in v1.0.0
FilterMapToString filters the elements based on the provided predicate and then maps the remaining elements using the provided mapper function, returning a new List of type string.
func (List[T]) FindFirst ¶
FindFirst returns an Option containing the first element of the List if it is present; otherwise, it returns an empty Option.
func (List[T]) FindOne ¶ added in v1.4.0
FindOne returns a nilo.Option[T] that match the given predicate function.
func (List[T]) FlatMap ¶ added in v1.5.0
FlatMap applies the provided mapper function to each element in the List, which returns a Steam, and concatenates the results into a single List of type T.
func (List[T]) FlatMapToInt ¶ added in v0.2.0
FlatMapToInt applies the provided mapper function to each element in the List, which returns a Steam, and concatenates the results into a single List of type int.
func (List[T]) FlatMapToString ¶ added in v0.2.0
FlatMapToString applies the provided mapper function to each element in the List, which returns a Steam, and concatenates the results into a single List of type string.
func (List[T]) ForEach ¶
func (list List[T]) ForEach(consumer func(T))
ForEach applies the provided consumer function to each element in the List.
func (List[T]) ForEachWithIndex ¶ added in v1.2.0
ForEachWithIndex applies the provided index and consumer function to each element in the List.
func (List[T]) GetCompared ¶
GetCompared returns an Option containing the element that is compared according to the provided comparison function. If the List is empty, it returns an empty Option.
func (List[T]) Last ¶
Last returns an Option containing the last element of the List if it is present; otherwise, it returns an empty Option.
func (List[T]) Limit ¶
Limit restricts the number of elements in the List to the specified limit and returns a slice of List.
func (List[T]) Map ¶ added in v1.5.0
Map applies the provided mapper function to each element in the List and returns the List modified of type T. If result to specific type is needed, use integration function Mapping[T, R](s Steam[T], mapper func(T) R)
func (List[T]) MapToInt ¶
MapToInt applies the provided mapper function to each element in the List and returns a new List of integers.
func (List[T]) MapToString ¶
MapToString applies the provided mapper function to each element in the List and returns a new List of strings.
func (List[T]) NoneMatch ¶
NoneMatch checks if no elements in the List match the provided predicate function. It returns true if no elements match, false otherwise.
func (List[T]) Peek ¶
Peek applies the provided consumer function to each element in the List without modifying it, and returns the original List.
func (List[T]) Position ¶
Position returns an Option containing the index of the first element that matches the provided predicate function; otherwise, it returns an empty Option.
func (List[T]) Reduce ¶
func (list List[T]) Reduce(initValue T, acc func(T, T) T) T
Reduce applies an accumulator function to the elements of the List, starting with the provided initial value. It returns the final accumulated value.
func (List[T]) Skip ¶
Skip returns a slice of List that skips the first n elements of the original List. If n is greater than or equal to the length of the List, it returns an empty List.
type Map ¶
type Map[K comparable, V any] map[K]V
Map is a generic type that represents a collection of key-value pairs, where keys are of type K and values are of type V.
func (Map[K, V]) AllMatch ¶
AllMatch checks if all key-value pairs in the Map match the provided predicate function. It returns true if all pairs match; otherwise, it returns false.
func (Map[K, V]) AnyMatch ¶
AnyMatch checks if any key-value pair in the Map matches the provided predicate function. It returns true if at least one pair matches; otherwise, it returns false.
func (Map[K, V]) Collect ¶
func (m Map[K, V]) Collect() map[K]V
Collect returns the underlying map of key-value pairs.
func (Map[K, V]) Filter ¶
Filter returns a the Map containing only the key-value pairs that match the provided predicate function.
func (Map[K, V]) FilterMap ¶ added in v1.5.0
FilterMap filters the key-value pairs based on the provided predicate and then maps the remaining pairs using the provided mapper function, returning a the Map with values of type V.
func (Map[K, V]) FilterMapToInt ¶ added in v1.0.0
FilterMapToInt filters the key-value pairs based on the provided predicate and then maps the remaining pairs using the provided mapper function, returning a new Map with values of type int.
func (Map[K, V]) FilterMapToString ¶ added in v1.0.0
func (m Map[K, V]) FilterMapToString(predicate func(K, V) bool, mapper func(K, V) string) Steam2[K, string]
FilterMapToString filters the key-value pairs based on the provided predicate and then maps the remaining pairs using the provided mapper function, returning a new Map with values of type string.
func (Map[K, V]) ForEach ¶
func (m Map[K, V]) ForEach(consumer func(K, V))
ForEach applies the provided consumer function to each key-value pair in the Map.
func (Map[K, V]) GetCompared ¶
GetCompared returns an Option containing the key-value pair that is compared according to the provided comparison function. If the Map is empty, it returns an empty Option.
func (Map[K, V]) KeysToSteam ¶
KeysToSteam returns a Steam containing all the keys from the Map.
func (Map[K, V]) Limit ¶
Limit restricts the number of key-value pairs in the Map to the specified limit and returns a the Map containing only the first 'limit' pairs.
func (Map[K, V]) Map ¶ added in v1.5.0
Map applies the provided mapper function to each key-value pair in the Map and returns the Map with values of type V.
func (Map[K, V]) MapToInt ¶
MapToInt applies the provided mapper function to each key-value pair in the Map and returns a new Map with values of type int.
func (Map[K, V]) MapToString ¶
MapToString applies the provided mapper function to each key-value pair in the Map and returns a new Map with values of type string.
func (Map[K, V]) NoneMatch ¶
NoneMatch checks if no key-value pairs in the Map match the provided predicate function. It returns true if no pairs match; otherwise, it returns false.
func (Map[K, V]) Peek ¶
Peek applies the provided consumer function to each key-value pair in the Map without modifying it, and returns the original Map.
func (Map[K, V]) Sorted ¶
Sorted returns a new Map containing the key-value pairs sorted according to the provided comparison function. The comparison function should define the order of the keys.
func (Map[K, V]) ToAnySteam ¶
ToAnySteam applies the provided mapper function to each key-value pair in the Map and returns a Steam containing the mapped values of type any.
func (Map[K, V]) ValuesToSteam ¶
ValuesToSteam returns a Steam containing all the values from the Map.
type Number ¶
type Number interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64
}
Number is a type constraint that includes all sumable types. It allows for summing various numeric types.
type Ordered ¶
Ordered is a type constraint that includes all ordered types. It allows for comparison of various numeric types and strings.
type OrderedStruct ¶
OrderedStruct is an interface for structs that can be compared. It requires the implementation of a Compare method that returns an integer. The method should return a negative value if the receiver is less than the other, zero if they are equal, and a positive value if the receiver is greater.
type Pair ¶
type Pair[K comparable, V any] struct { Key K Value V }
Pair is a generic struct that holds a key-value pair.
type Steam ¶
type Steam[T any] interface { // Filter returns a new Steam containing only the elements that match the // given predicate function. Filter(predicate func(T) bool) Steam[T] // Map transforms each element of the Steam using the provided mapper // function and returns a new Steam of type T. // If result to specific type is needed, use integration function Mapping[T, R](s Steam[T], mapper func(T) R) Map(mapper func(T) T) Steam[T] // MapToInt transforms each element of the Steam using the provided mapper // function and returns a new Steam of type int. MapToInt(mapper func(T) int) Steam[int] // MapToString transforms each element of the Steam using the provided mapper // function and returns a new Steam of type string. MapToString(mapper func(T) string) Steam[string] // FilterMap combines filtering and mapping. Returns a new Steam containing // elements that match the predicate and are transformed by the mapper. FilterMap(predicate func(T) bool, mapper func(T) T) Steam[T] // FilterMapToInt combines filtering and mapping. Returns a new Steam containing // elements that match the predicate and are transformed by the mapper. FilterMapToInt(predicate func(T) bool, mapper func(T) int) Steam[int] // FilterMapToString combines filtering and mapping. Returns a new Steam containing // elements that match the predicate and are transformed by the mapper. FilterMapToString(predicate func(T) bool, mapper func(T) string) Steam[string] // FlatMap transforms each element of the Steam into a new Steam using // the provided mapper function and flattens the result into a single Steam. FlatMap(mapper func(T) Steam[T]) Steam[T] // FlatMapToInt transforms each element of the Steam into a new Steam using // the provided mapper function and flattens the result into a single Steam. FlatMapToInt(mapper func(T) Steam[int]) Steam[int] // FlatMapToString transforms each element of the Steam into a new Steam using // the provided mapper function and flattens the result into a single Steam. FlatMapToString(mapper func(T) Steam[string]) Steam[string] // ForEach executes the provided consumer function for each element in the Steam. ForEach(consumer func(T)) // ForEachWithIndex executes the provided index and consumer function for each element in the Steam. ForEachWithIndex(consumer func(int, T)) // Peek allows for inspecting each element without consuming it. It returns // a new Steam that allows for further operations after consuming the elements. Peek(consumer func(T)) Steam[T] // Limit returns a new Steam containing only the first 'limit' elements. Limit(limit int) Steam[T] // AllMatch returns true if all elements match the given predicate. AllMatch(predicate func(T) bool) bool // AnyMatch returns true if any element matches the given predicate. AnyMatch(predicate func(T) bool) bool // NoneMatch returns true if no elements match the given predicate. NoneMatch(predicate func(T) bool) bool // TakeWhile returns a new Steam containing elements as long as they match // the given predicate. TakeWhile(predicate func(T) bool) Steam[T] // DropWhile returns a new Steam that skips elements as long as they match // the given predicate. DropWhile(predicate func(T) bool) Steam[T] // Reduce combines elements of the Steam into a single value using the provided // accumulator function, starting with the given initial value. Reduce(initValue T, acc func(T, T) T) T // Reverse returns a new Steam with the elements in reverse order. Reverse() Steam[T] // Sorted returns a new Steam with the elements sorted according to the // provided comparison function. Sorted(cmp func(T, T) bool) Steam[T] // GetCompared returns the first element that matches the comparison function // wrapped in a nilo.Option[T]. // This can be used as an implementation of Max or Min function. GetCompared(cmp func(T, T) bool) nilo.Option[T] // FindFirst returns the first element in the Steam as a nilo.Option[T] // indicating if an element exists. FindFirst() nilo.Option[T] // FindOne returns a nilo.Option[T] that match the given predicate function. FindOne(predicate func(T) bool) nilo.Option[T] // Last returns an nilo.Option of the last element in the Steam // indicating if an element exists. Last() nilo.Option[T] // Position returns the index of the first element that matches the predicate // wrapped in a nilo.Option[int]. Position(predicate func(T) bool) nilo.Option[int] // Skip returns a new Steam that skips the first 'n' elements. Skip(n int) Steam[T] // Count returns the number of elements in the Steam. Count() int // Collect returns a slice containing all elements in the Steam. Collect() []T }
Steam[T] is an interface for a collection of elements of type T, providing various methods for functional-style processing.
func CollectSteam2ToSteam ¶
func CollectSteam2ToSteam[K comparable, V, R any](s Steam2[K, V], mapper func(K, V) R) Steam[R]
CollectSteam2ToSteam transforms a Steam2 of key-value pairs into a Steam of type R, using the provided mapper function to convert each key-value pair into a single value of type R.
func Distinct ¶
func Distinct[T comparable](s Steam[T]) Steam[T]
Distinct returns a new Steam containing only the unique elements from the input Steam. It uses a map to track seen elements and filters out duplicates.
func FlatMapper ¶ added in v1.5.0
FlatMapper applies the provided mapper function to each element in the List and returns a new List of type R.
func Mapper ¶ added in v1.5.0
Mapper applies the provided mapper function to each element in the List and returns a new List of type R.
type Steam2 ¶
type Steam2[K comparable, V any] interface { // Filter returns a new Steam2 instance containing only the elements that match the given predicate. // The predicate function takes a key and a value and returns true if the element should be included. Filter(predicate func(K, V) bool) Steam2[K, V] // Map transforms the elements of the Steam2 instance using the provided mapper function, // which takes a key and a value and returns a value of V type. // The result is a new Steam2 instance with the transformed values. Map(mapper func(K, V) V) Steam2[K, V] // MapToInt transforms the elements of the Steam2 instance using the provided mapper function, // which takes a key and a value and returns an int. // The result is a new Steam2 instance with the transformed integer values. MapToInt(mapper func(K, V) int) Steam2[K, int] // MapToString transforms the elements of the Steam2 instance using the provided mapper function, // which takes a key and a value and returns a string. // The result is a new Steam2 instance with the transformed string values. MapToString(mapper func(K, V) string) Steam2[K, string] // FilterMap applies a predicate to filter elements and then maps the remaining elements // using the provided mapper function. The result is a new Steam2 instance with the transformed values. FilterMap(predicate func(K, V) bool, mapper func(K, V) V) Steam2[K, V] // FilterMapToInt applies a predicate to filter elements and then maps the remaining elements // using the provided mapper function. The result is a new Steam2 instance with the transformed values. FilterMapToInt(predicate func(K, V) bool, mapper func(K, V) int) Steam2[K, int] // FilterMapToString applies a predicate to filter elements and then maps the remaining elements // using the provided mapper function. The result is a new Steam2 instance with the transformed values. FilterMapToString(predicate func(K, V) bool, mapper func(K, V) string) Steam2[K, string] // ForEach applies the provided consumer function to each element in the Steam2 instance. // The consumer function takes a key and a value and performs an action for each element. ForEach(consumer func(K, V)) // Peek allows you to inspect each element in the Steam2 instance using the provided consumer function // without modifying the stream. The result is a new Steam2 instance with the same elements. Peek(consumer func(K, V)) Steam2[K, V] // Limit restricts the number of elements in the Steam2 instance to the specified limit. // The result is a new Steam2 instance containing only the first 'limit' elements. Limit(limit int) Steam2[K, V] // AllMatch checks if all elements in the Steam2 instance match the given predicate. // The predicate function takes a key and a value and returns true if the element matches. // It returns true if the stream is empty. AllMatch(predicate func(K, V) bool) bool // AnyMatch checks if any element in the Steam2 instance matches the given predicate. // The predicate function takes a key and a value and returns true if the element matches. // It returns false if the stream is empty. AnyMatch(predicate func(K, V) bool) bool // NoneMatch checks if no elements in the Steam2 instance match the given predicate. // The predicate function takes a key and a value and returns true if the element matches. // It returns true if the stream is empty. NoneMatch(predicate func(K, V) bool) bool // Sorted returns a new Steam2 instance with elements sorted according to the provided comparison function. // The comparison function takes two keys and returns true if the first key is less than the second. Sorted(cmp func(K, K) bool) Steam2[K, V] // GetCompared returns an Option Pair containing the first two elements of the stream compared // using the provided comparison function. If the stream has fewer than two elements, it returns an empty Option. GetCompared(cmp func(K, K) bool) nilo.Option[Pair[K, V]] // Count returns the number of elements in the Steam2 instance. Count() int // Collect gathers all elements in the Steam2 instance into a map with keys of type K and values of type V. Collect() map[K]V // KeysToSteam returns a new Steam instance containing only the keys from the Steam2 instance. KeysToSteam() Steam[K] // ValuesToSteam returns a new Steam instance containing only the values from the Steam2 instance. ValuesToSteam() Steam[V] // ToAnySteam transforms the elements of the Steam2 instance using the provided mapper function, // which takes a key and a value and returns a value of any type. // The result is a new Steam instance with the transformed values. ToAnySteam(mapper func(K, V) any) Steam[any] }
Steam2[K, V] is an interface for a map of elements of type K and V, providing various methods for functional-style processing. Steam2 is a generic interface that provides a fluent API for processing key-value pairs.
func CollectSteamToSteam2 ¶
func CollectSteamToSteam2[K comparable, V, T any](s Steam[T], keyFunc func(T) K, valueFunc func(T) V) Steam2[K, V]
CollectSteamToSteam2 transforms a Steam of type T into a Steam2 of key-value pairs, where keys and values are derived from the provided keyFunc and valueFunc. It collects elements from the input Steam and maps them to a new Steam2 instance.
func GroupBy ¶
func GroupBy[K comparable, V any](s Steam[V], classifier func(V) K) Steam2[K, Steam[V]]
GroupBy groups elements of a Steam by a classifier function that maps each element to a key. It returns a Steam2 where each key corresponds to a Steam of elements that share that key.
func GroupByCounting ¶
func GroupByCounting[K comparable, V any](s Steam[V], classifier func(V) K) Steam2[K, int]
GroupByCounting groups elements of a Steam by a classifier function and counts the occurrences of each key. It returns a Steam2 where each key corresponds to the count of elements that share that key.
func OfMap ¶
func OfMap[K comparable, V any](m map[K]V) Steam2[K, V]
OfMap creates a Steam2 from a map of key-value pairs. The keys and values are derived from the provided map.