com.daodecode.scalax.collection.extensions
Applies a binary operator to a start value and all elements of this collection while predicate p
is satisfied,
going left to right.
Applies a binary operator to a start value and all elements of this collection while predicate p
is satisfied,
going left to right.
Example:
scala> val xs = Iterable(List(1,2,3), List(4,5), List(6,7,8,9)). | foldLeftWhile(List.empty[Int])(_.size < 4){ case (acc, l) => acc ++ l } xs: List[Int] = List(1, 2, 3, 4, 5)
the result type of the binary operator.
the start value.
the predicate used to test if folding should continue.
the binary operator.
the result of inserting op
between consecutive elements of this collection while predicate p
is satisfied,
going left to right with the start value z
on the left.
0.1.0
Applies a binary operator to all elements of this collection and a start value while predicate p
is satisfied,
going right to left.
Applies a binary operator to all elements of this collection and a start value while predicate p
is satisfied,
going right to left.
Example:
scala> val xs = Iterable(List(1,2,3), List(4,5), List(6,7,8,9)). | foldRightWhile(List.empty[Int])(_.size < 5){ case (l, acc) => l ::: acc } xs: List[Int] = List(4, 5, 6, 7, 8, 9)
the result type of the binary operator.
the start value.
the predicate used to test if folding should continue.
the binary operator.
the result of inserting op
between consecutive elements of this collection while predicate p
is satisfied,
going right to left with the start value z
on the right.
0.1.0
Converts this collection to a map.
Converts this collection to a map. This method is unavailable unless
the elements are members of Tuple2[K, V].
The method is different from toMap
in the way that values for
duplicate keys will be collected into collection,
so all the values will be in the result map.
Example:
scala> val cm = List(1 -> "1", 2 -> "2", 1 -> "11").toCompleteMap cm: scala.collection.immutable.Map[Int,List[String]] = Map(2 -> List(2), 1 -> List(1, 11))
a map of type immutable.Map[K, That]
where That
is a collection of V
0.1.1
Creates a new immutable Map
with unique elements of this collection as keys and
count of duplicates ((as determined by ==
) (frequency) as values
Creates a new immutable Map
with unique elements of this collection as keys and
count of duplicates ((as determined by ==
) (frequency) as values
Example:
scala> val fm = List("a", "b", "c", "a", "b", "d").withFrequency fm: scala.collection.immutable.Map[String,Int] = Map(b -> 2, d -> 1, a -> 2, c -> 1)
a map of type immutable.Map[A, Int] where Int represents a frequency of key A in original collection
0.1.1