ArrayExtensions

ostrat.ArrayExtensions
final class ArrayExtensions[A](val thisArray: Array[A]) extends AnyVal

Extension methods for Array[A] class

Attributes

Graph
Supertypes
class AnyVal
trait Matchable
class Any

Members list

Value members

Concrete methods

def applyOpt(index: Int): Option[A]

Returns Some of the indexed value if the value exists else returns None.

Returns Some of the indexed value if the value exists else returns None.

Attributes

def headElse(ifEmpty: => A): A

This method and "fHead" removes the need for headOption in the majority of cases.

This method and "fHead" removes the need for headOption in the majority of cases.

Attributes

def headElseMap[B](ifEmpty: => B, fNonEmpty: A => B): B

This method and "fHead" removes the need for headOption in the majority of cases.

This method and "fHead" removes the need for headOption in the majority of cases.

Attributes

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

foreach loop with counter

foreach loop with counter

Attributes

def ifEmpty[B](vEmpty: => B, vNonEmpty: => B): B
def initSafe(using ClassTag[A]): Array[A]

Safe version of init, that returns an empty Array on an empty Array

Safe version of init, that returns an empty Array on an empty Array

Attributes

def lastElse(ifEmpty: => A): A

Returns the last element or the parameter if empty.

Returns the last element or the parameter if empty.

Attributes

def lastElseMap[B](ifEmpty: => B, fNonEmpty: A => B): B

Returns the passed value if empty or applies function to last lement.

Returns the passed value if empty or applies function to last lement.

Attributes

def mapArr[B, ArrB <: Arr[B]](f: A => B)(implicit ev: BuilderArrMap[B, ArrB]): ArrB

maps to this Array to an Arr of B. if this Array is null the Arr will have length 0.

maps to this Array to an Arr of B. if this Array is null the Arr will have length 0.

Attributes

def removeAt(i: Int)(using ctA: ClassTag[A]): Array[A]

Extension method. Removes element at given index and returns a new Array.

Extension method. Removes element at given index and returns a new Array.

Attributes

def tailIForeach(f: (A, Int) => Unit): Unit
def toRArr(implicit ct: ClassTag[A]): RArr[A]

Extension method to convert to RArr. If this Array is null the RArr will have length 0.

Extension method to convert to RArr. If this Array is null the RArr will have length 0.

Attributes

def toStr: String
def toStrsCommaFold(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 thisArray: Array[A]