IterableExtensions

ostrat.IterableExtensions
final class IterableExtensions[A](val thisIter: Iterable[A]) extends AnyVal

Extension methods for Iterable[A].

Attributes

Graph
Supertypes
class AnyVal
trait Matchable
class Any

Members list

Value members

Concrete methods

def fLast[B](ifEmpty: => B, fNonEmpty: A => B): B
def flatMapArr[BB <: Arr[_]](f: A => BB)(implicit ev: BuilderArrFlat[BB]): BB

flatMaps to a Arr of B.

flatMaps to a Arr of B.

Attributes

def flatMapPairArr[B1, ArrB1 <: Arr[B1], B2, BB <: PairArrFinalA1[B1, ArrB1, B2, _]](f1: A => ArrB1, f2: A => B2)(implicit build: BuilderArrPairFlat[B1, ArrB1, B2, BB]): BB

FlatMaps to an Arr of B1, but maps to a single element of B2. The elements of the Arr[B1] are paired with copies of B2. These are logically flattened to a PairArrFinalA1[B1, B2].

FlatMaps to an Arr of B1, but maps to a single element of B2. The elements of the Arr[B1] are paired with copies of B2. These are logically flattened to a PairArrFinalA1[B1, B2].

Attributes

def foldWithPrevious[B](initPrevious: A, initAcc: B)(f: (B, A, A) => B): B
def headOnly[B](ifEmpty: => B, fNonEmpty: A => B): B

This method and "fHead" removes the need for headOption in the majority of case. Use fHead when are interested in the tail value

This method and "fHead" removes the need for headOption in the majority of case. Use fHead when are interested in the tail value

Attributes

def headOrElse(vEmpty: A): A
def headToStringElse(elseString: => String): String

If the collection is nonEmpty, return head of list convert to string or return the defualt string.

If the collection is nonEmpty, return head of list convert to string or return the defualt string.

Attributes

def iFlatMap[B, BB <: Arr[B]](f: (Int, A) => BB)(implicit build: BuilderArrMap[B, BB]): BB

flatMaps over a traversable (collection / sequence) with a counter

flatMaps over a traversable (collection / sequence) with a counter

Attributes

def iFlatMap[B, BB <: Arr[B]](count: Int)(f: (Int, A) => BB)(implicit build: BuilderArrMap[B, BB]): BB

flatMaps over a traversable (collection / sequence) with a counter

flatMaps over a traversable (collection / sequence) with a counter

Attributes

def iForall(f: (Int, A) => Boolean): Boolean
def iForeach(f: (Int, A) => Unit): Unit

Index with foreach. Performs a side effecting function on the index and each element of this sequence. It takes a function as a parameter. The function may return Unit. If it does return a non Unit value it is discarded. The [U] type parameter is there just to avoid warnings about discarded values and can be ignored by method users. The method has 2 versions / name overloads. The default start for the index is 0 if just the function parameter is passed. The second version name overload takes an Int for the first parameter list, to set the start value of the index. Note the function signature follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods' (accumulator, element) => B signature.

Index with foreach. Performs a side effecting function on the index and each element of this sequence. It takes a function as a parameter. The function may return Unit. If it does return a non Unit value it is discarded. The [U] type parameter is there just to avoid warnings about discarded values and can be ignored by method users. The method has 2 versions / name overloads. The default start for the index is 0 if just the function parameter is passed. The second version name overload takes an Int for the first parameter list, to set the start value of the index. Note the function signature follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods' (accumulator, element) => B signature.

Attributes

def iForeach(initialIndex: Int)(f: (Int, A) => Unit): Unit

Index with foreach. Performs a side effecting function on the index and each element of this sequence. It takes a function as a parameter. The function may return Unit. If it does return a non Unit value it is discarded. The [U] type parameter is there just to avoid warnings about discarded values and can be ignored by method users. The method has 2 versions / name overloads. The default start for the index is 0 if just the function parameter is passed. The second version name overload takes an Int for the first parameter list, to set the start value of the index. Note the function signature follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods' (accumulator, element) => B signature.

Index with foreach. Performs a side effecting function on the index and each element of this sequence. It takes a function as a parameter. The function may return Unit. If it does return a non Unit value it is discarded. The [U] type parameter is there just to avoid warnings about discarded values and can be ignored by method users. The method has 2 versions / name overloads. The default start for the index is 0 if just the function parameter is passed. The second version name overload takes an Int for the first parameter list, to set the start value of the index. Note the function signature follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods' (accumulator, element) => B signature.

Attributes

def iMap[B, BB <: Arr[B]](f: (Int, A) => B)(implicit build: BuilderArrMap[B, BB]): BB

Specialised index with map to an immutable ArrBase of B. Note the function signature follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods' (accumulator, element) => B signature.

Specialised index with map to an immutable ArrBase of B. Note the function signature follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods' (accumulator, element) => B signature.

Attributes

def iMap[B, BB <: Arr[B]](count: Int)(f: (A, Int) => B)(implicit build: BuilderArrMap[B, BB]): BB

Specialised index with map to an immutable ArrBase of B. Note the function signature follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods' (accumulator, element) => B signature.

Specialised index with map to an immutable ArrBase of B. Note the function signature follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods' (accumulator, element) => B signature.

Attributes

def ifEmpty[B](vEmpty: => B, vNonEmpty: => B): B
def ifHead(f: A => Boolean): Boolean

Checks condition against head. Returns false if the collection is empty.

Checks condition against head. Returns false if the collection is empty.

Attributes

def iterHead[B](ifEmpty: => B, fNonEmpty: (A, Iterable[A]) => B): B
def mapArr[B, BB <: Arr[B]](f: A => B)(implicit ev: BuilderArrMap[B, BB]): BB

maps to a Arr of B.

maps to a Arr of B.

Attributes

def mapPairArr[B1, ArrB1 <: Arr[B1], B2, B <: PairFinalA1Elem[B1, B2], ArrB <: PairArrFinalA1[B1, ArrB1, B2, B]](f1: A => B1, f2: A => B2)(implicit build: BuilderArrPairMap[B1, ArrB1, B2, B, ArrB]): ArrB

Maps to a PairArrFinalA1 of B1 and B2.

Maps to a PairArrFinalA1 of B1 and B2.

Attributes

def sumBy(f: A => Int): Int
def toArr[AA <: Arr[A]](implicit builder: BuilderArrMap[A, AA]): AA

Converts to Arr of A. Most commonly an RArr. Prefer the mapArr method where appropriate which combines the conversion with a map operation.

Converts to Arr of A. Most commonly an RArr. Prefer the mapArr method where appropriate which combines the conversion with a map operation.

Attributes

def toStrFold2[B](secondAcc: B)(f: (B, A) => (String, B)): String
def toStrsCommaFold(fToStr: A => String): String
def toStrsCommaNoSpaceFold(fToStr: A => String): String
def toStrsCommaParenth(fToStr: A => String): String
def toStrsFold(seperator: String, f: A => String): String
def toStrsSemiFold(fToStr: A => String): String
def toStrsSemiParenth(fToStr: A => String): String

Concrete fields

val thisIter: Iterable[A]