implicit final class ConvenientCollection[Element, Collection[Element] <: Iterable[Element]] extends AnyVal
This class extends the interface of scala.Iterable
with convenience methods.
- Alphabetic
- By Inheritance
- ConvenientCollection
- AnyVal
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new ConvenientCollection(self: Collection[Element])
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- Any
- final def ##(): Int
- Definition Classes
- Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def frequencies: Map[Element, Int]
Constructs and returns a new map with the collection’s elements as keys and each element’s occurrence counts as the corresponding values.
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 )
. - def getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
- def ifNonEmpty[Result](compute: (Collection[Element]) => Result): Option[Result]
Applies the given function to the collection in case there’s at least one element there.
Applies the given function to the collection in case there’s at least one element there. Returns
None
if the collection is empty. - final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def log(format: (Iterable[Element]) => String = _.toString): Collection[Element]
Prints out the collection, then returns the unmodified collection.
Prints out the collection, then returns the unmodified collection.
- format
a function from the collection to the desired printout; defaults to
_.toString
- def mapFromID[ID](formID: (Element) => ID): Map[ID, Element]
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.
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)
.- formID
a function called on each element of the collection to obtain the keys
- def mapGroups[Key, Value](formKey: (Element) => Key)(transformGroup: (Iterable[Element]) => Value): Map[Key, Value]
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 permapValues
).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 permapValues
).- 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
- def mapTo[Value](formValue: (Element) => Value): Map[Element, Value]
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.
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)
.- formValue
a function called on each element of the collection to obtain the keys
- def mapify[Key, Value](formKey: (Element) => Key)(formValue: (Element) => Value): Map[Key, Value]
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.
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
.- 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
- def slidingPairs: Iterator[(Element, Element)]
Returns an iterator of pairs (tuples) that “slide across” the collection as per
sliding
. - def tap(effect: (Element) => Unit): Collection[Element]
Performs a given side effect at each element of the collection.
Performs a given side effect at each element of the collection. Returns the unmodified collection.
- def toLazy: LazyList[Element]
Returns a
LazyList
containing the collection’s elements.Returns a
LazyList
containing the collection’s elements. This is equivalent toto(LazyList)
. - def toString: String
- Definition Classes
- Any