collection
Provides nice extensions to the interface of scala.Iterable
, for convenience.
Extensions
Extensions
Constructs and returns a new map with the collection’s elements as keys and each element’s
occurrence counts as the corresponding values. This is equivalent to mapGroups(identity)( _.size )
.
Constructs and returns a new map with the collection’s elements as keys and each element’s
occurrence counts as the corresponding values. This is equivalent to mapGroups(identity)( _.size )
.
Applies the given function to the collection in case there’s at least one element there.
Returns None
if the collection is empty.
Applies the given function to the collection in case there’s at least one element there.
Returns None
if the collection is empty.
Prints out the collection, then returns the unmodified collection.
Prints out the collection, then returns the unmodified collection.
- Value parameters:
- format
a function from the collection to the desired printout; defaults to
_.toString
Constructs and returns a new map by applying an ID-generating function to each
element of the collection and using the collection’s elements as values. This is
equivalent to calling mapify(formID)(identity)
.
Constructs and returns a new map by applying an ID-generating function to each
element of the collection and using the collection’s elements as values. This is
equivalent to calling mapify(formID)(identity)
.
- Value parameters:
- formID
a function called on each element of the collection to obtain the keys
Constructs and returns a new map by using one given function to group the elements
of the collection (as per groupBy
) and then transforming each of the groups using
another given function (as per mapValues
).
Constructs and returns a new map by using one given function to group the elements
of the collection (as per groupBy
) and then transforming each of the groups using
another given function (as per mapValues
).
- Value parameters:
- formKey
a function called on each element of the collection to generate groups of values
- transformGroup
a function called on each group to obtain the values for the resulting collection
Constructs and returns a new map by applying a value-generating function
to each element of the collection and using the collection’s elements as keys.
This is equivalent to calling mapify(identity)(formValue)
.
Constructs and returns a new map by applying a value-generating function
to each element of the collection and using the collection’s elements as keys.
This is equivalent to calling mapify(identity)(formValue)
.
- Value parameters:
- formValue
a function called on each element of the collection to obtain the keys
Constructs and returns a new map by applying a key-generating function as well as
a value-generating function to each element of the collection. The respective
outputs of the functions are paired to form the key—value pairs of the Map
.
Constructs and returns a new map by applying a key-generating function as well as
a value-generating function to each element of the collection. The respective
outputs of the functions are paired to form the key—value pairs of the Map
.
- Value parameters:
- formKey
a function called on each element of the collection to obtain the keys
- formValue
a function called on each element of the collection to obtain the values
Returns an iterator of pairs (tuples) that “slide across” the collection as per sliding
.
Returns an iterator of pairs (tuples) that “slide across” the collection as per sliding
.