Packages

final class ArrayOps[A] extends AnyVal

Equivalent of scala.collection.js.ArrayOps for js.Array.

Annotations
@inline()
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ArrayOps
  2. AnyVal
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new ArrayOps(xs: Array[A])

Value Members

  1. final def !=(arg0: scala.Any): Boolean
    Definition Classes
    Any
  2. final def ##: Int
    Definition Classes
    Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from ArrayOps[A] toany2stringadd[ArrayOps[A]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. final def ++[B >: A](ys: Array[_ <: B]): Array[B]
    Annotations
    @inline()
  5. final def ++[B >: A](ys: collection.IterableOnce[B]): Array[B]
    Annotations
    @inline()
  6. final def ++:[B >: A](prefix: Array[_ <: B]): Array[B]
    Annotations
    @inline()
  7. final def ++:[B >: A](prefix: collection.IterableOnce[B]): Array[B]
    Annotations
    @inline()
  8. final def ++=(ys: collection.IterableOnce[A]): Array[A]

    Alias for addAll

    Alias for addAll

    Annotations
    @inline()
  9. final def ++=:(elems: collection.IterableOnce[A]): Array[A]

    Alias for prependAll

    Alias for prependAll

    Annotations
    @inline()
  10. final def +:[B >: A](x: B): Array[B]
    Annotations
    @inline()
  11. final def +=(elem: A): Array[A]

    Alias for addOne

    Alias for addOne

    Annotations
    @inline()
  12. final def +=:(elem: A): Array[A]

    Alias for prepend

    Alias for prepend

    Annotations
    @inline()
  13. final def --=(ys: collection.IterableOnce[A]): Array[A]

    Alias for subtractAll

    Alias for subtractAll

    Annotations
    @inline()
  14. final def -=(elem: A): Array[A]

    Alias for subtractOne

    Alias for subtractOne

    Annotations
    @inline()
  15. def ->[B](y: B): (ArrayOps[A], B)
    Implicit
    This member is added by an implicit conversion from ArrayOps[A] toArrowAssoc[ArrayOps[A]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  16. final def :+[B >: A](x: B): Array[B]
    Annotations
    @inline()
  17. final def :++[B >: A](suffix: Array[_ <: B]): Array[B]
    Annotations
    @inline()
  18. final def :++[B >: A](suffix: collection.IterableOnce[B]): Array[B]
    Annotations
    @inline()
  19. final def ==(arg0: scala.Any): Boolean
    Definition Classes
    Any
  20. def addAll(ys: collection.IterableOnce[A]): Array[A]

    Adds all elements produced by an IterableOnce to this array.

    Adds all elements produced by an IterableOnce to this array.

    returns

    the array itself.

  21. def addOne(elem: A): Array[A]

    Appends a single element to this array.

    Appends a single element to this array.

    elem

    the element to add.

    returns

    the array itself

    Annotations
    @inline()
  22. final def append(elem: A): Array[A]

    Appends the given element to this array.

    Appends the given element to this array.

    elem

    the element to append.

    Annotations
    @inline()
  23. final def appendAll(ys: collection.IterableOnce[A]): Array[A]

    Appends the elements contained in an iterable object to this array.

    Appends the elements contained in an iterable object to this array.

    Annotations
    @inline()
  24. def appended[B >: A](x: B): Array[B]

    A copy of this array with an element appended.

  25. def appendedAll[B >: A](suffix: Array[_ <: B]): Array[B]

    A copy of this array with all elements of an array appended.

  26. def appendedAll[B >: A](suffix: collection.IterableOnce[B]): Array[B]

    A copy of this array with all elements of a collection appended.

  27. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  28. def clear(): Unit

    Clears the array's contents.

    Clears the array's contents.

    After this operation, the array is empty.

    Annotations
    @inline()
  29. def collect[B](pf: PartialFunction[A, B]): Array[B]

    Builds a new array by applying a partial function to all elements of this array on which the function is defined.

    Builds a new array by applying a partial function to all elements of this array on which the function is defined.

    B

    the element type of the returned array.

    pf

    the partial function which filters and maps the array.

    returns

    a new array resulting from applying the given partial function pf to each element on which it is defined and collecting the results. The order of the elements is preserved.

  30. def collectFirst[B](f: PartialFunction[A, B]): Option[B]

    Finds the first element of the array for which the given partial function is defined, and applies the partial function to it.

  31. def combinations(n: Int): collection.Iterator[Array[A]]

    Iterates over combinations.

  32. def contains(elem: A): Boolean

    Tests whether this array contains a given value as an element.

    Tests whether this array contains a given value as an element.

    elem

    the element to test.

    returns

    true if this array has an element that is equal (as determined by ==) to elem, false otherwise.

  33. def copyToArray[B >: A](xs: scala.Array[B], start: Int, len: Int): Int

    Copy elements of this array to a Scala array.

    Copy elements of this array to a Scala array.

    Fills the given array xs starting at index start with at most len values. Copying will stop once either all the elements of this array have been copied, or the end of the array is reached, or len elements have been copied.

    B

    the type of the elements of the array.

    xs

    the array to fill.

    start

    the starting index within the destination array.

    len

    the maximal number of elements to copy.

  34. def copyToArray[B >: A](xs: scala.Array[B], start: Int): Int

    Copy elements of this array to a Scala array.

    Copy elements of this array to a Scala array.

    Fills the given array xs starting at index start. Copying will stop once either all the elements of this array have been copied, or the end of the array is reached.

    B

    the type of the elements of the array.

    xs

    the array to fill.

    start

    the starting index within the destination array.

  35. def copyToArray[B >: A](xs: scala.Array[B]): Int

    Copy elements of this array to a Scala array.

    Copy elements of this array to a Scala array.

    Fills the given array xs starting at index 0. Copying will stop once either all the elements of this array have been copied, or the end of the array is reached.

    B

    the type of the elements of the array.

    xs

    the array to fill.

  36. def count(p: (A) => Boolean): Int

    Counts the number of elements in this array which satisfy a predicate.

  37. def diff[B >: A](that: Seq[B]): Array[A]

    Computes the multiset difference between this array and another sequence.

    Computes the multiset difference between this array and another sequence.

    that

    the sequence of elements to remove

    returns

    a new array which contains all elements of this array except some of occurrences of elements that also appear in that. If an element value x appears n times in that, then the first n occurrences of x will not form part of the result, but any following occurrences will.

  38. def distinct: Array[A]

    Selects all the elements of this array ignoring the duplicates.

    Selects all the elements of this array ignoring the duplicates.

    returns

    a new array consisting of all the elements of this array without duplicates.

  39. def distinctBy[B](f: (A) => B): Array[A]

    Selects all the elements of this array ignoring the duplicates as determined by == after applying the transforming function f.

    Selects all the elements of this array ignoring the duplicates as determined by == after applying the transforming function f.

    B

    the type of the elements after being transformed by f

    f

    The transforming function whose result is used to determine the uniqueness of each element

    returns

    a new array consisting of all the elements of this array without duplicates.

  40. def drop(n: Int): Array[A]

    The rest of the array without its n first elements.

    The rest of the array without its n first elements.

    Annotations
    @inline()
  41. def dropInPlace(n: Int): Array[A]
  42. def dropRight(n: Int): Array[A]

    The rest of the array without its n last elements.

  43. def dropRightInPlace(n: Int): Array[A]
    Annotations
    @inline()
  44. def dropWhile(p: (A) => Boolean): Array[A]

    Drops the longest prefix of elements that satisfy a predicate.

    Drops the longest prefix of elements that satisfy a predicate.

    p

    The predicate used to test elements.

    returns

    the longest suffix of this array whose first element does not satisfy the predicate p.

  45. def dropWhileInPlace(p: (A) => Boolean): Array[A]
  46. def endsWith[B >: A](that: collection.Iterable[B]): Boolean

    Tests whether this array ends with the given sequence.

    Tests whether this array ends with the given sequence.

    that

    the sequence to test

    returns

    true if this array has that as a suffix, false otherwise.

  47. def endsWith[B >: A](that: Array[B]): Boolean

    Tests whether this array ends with the given array.

    Tests whether this array ends with the given array.

    that

    the array to test

    returns

    true if this array has that as a suffix, false otherwise.

  48. def ensuring(cond: (ArrayOps[A]) => Boolean, msg: => scala.Any): ArrayOps[A]
    Implicit
    This member is added by an implicit conversion from ArrayOps[A] toEnsuring[ArrayOps[A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  49. def ensuring(cond: (ArrayOps[A]) => Boolean): ArrayOps[A]
    Implicit
    This member is added by an implicit conversion from ArrayOps[A] toEnsuring[ArrayOps[A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  50. def ensuring(cond: Boolean, msg: => scala.Any): ArrayOps[A]
    Implicit
    This member is added by an implicit conversion from ArrayOps[A] toEnsuring[ArrayOps[A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  51. def ensuring(cond: Boolean): ArrayOps[A]
    Implicit
    This member is added by an implicit conversion from ArrayOps[A] toEnsuring[ArrayOps[A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  52. def exists(f: (A) => Boolean): Boolean

    Tests whether a predicate holds for at least one element of this array.

    Tests whether a predicate holds for at least one element of this array.

    returns

    true if the given predicate p is satisfied by at least one element of this array, otherwise false

  53. def filter(p: (A) => Boolean): Array[A]

    Selects all elements of this array which satisfy a predicate.

    Selects all elements of this array which satisfy a predicate.

    p

    the predicate used to test elements.

    returns

    a new array consisting of all elements of this array that satisfy the given predicate p.

  54. def filterInPlace(p: (A) => Boolean): Array[A]
  55. def filterNot(p: (A) => Boolean): Array[A]

    Selects all elements of this array which do not satisfy a predicate.

    Selects all elements of this array which do not satisfy a predicate.

    returns

    a new array consisting of all elements of this array that do not satisfy the given predicate pred.

  56. def find(f: (A) => Boolean): Option[A]

    Finds the first element of the array satisfying a predicate, if any.

    Finds the first element of the array satisfying a predicate, if any.

    returns

    an option value containing the first element in the array that satisfies p, or None if none exists.

  57. def flatMap[BS, B](f: (A) => BS)(implicit asIterable: (BS) => collection.Iterable[B]): Array[B]
  58. def flatMap[B](f: (A) => collection.IterableOnce[B]): Array[B]

    Builds a new array by applying a function to all elements of this array and using the elements of the resulting collections.

    Builds a new array by applying a function to all elements of this array and using the elements of the resulting collections.

    B

    the element type of the returned array.

    f

    the function to apply to each element.

    returns

    a new array resulting from applying the given collection-valued function f to each element of this array and concatenating the results.

  59. def flatMapInPlace(f: (A) => collection.IterableOnce[A]): Array[A]
  60. def flatten[B](implicit asIterable: (A) => collection.Iterable[B]): Array[B]

    Flattens a two-dimensional array by concatenating all its rows into a single array.

    Flattens a two-dimensional array by concatenating all its rows into a single array.

    B

    Type of row elements.

    asIterable

    A function that converts elements of this array to rows - Iterables of type B.

    returns

    An array obtained by concatenating rows of this array.

  61. def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1

    Folds the elements of this array using the specified associative binary operator.

    Folds the elements of this array using the specified associative binary operator.

    A1

    a type parameter for the binary operator, a supertype of A.

    z

    a neutral element for the fold operation; may be added to the result an arbitrary number of times, and must not change the result (e.g., Nil for list concatenation, 0 for addition, or 1 for multiplication).

    op

    a binary operator that must be associative.

    returns

    the result of applying the fold operator op between all the elements, or z if this array is empty.

  62. def foldLeft[B](z: B)(op: (B, A) => B): B

    Applies a binary operator to a start value and all elements of this array, going left to right.

    Applies a binary operator to a start value and all elements of this array, going left to right.

    B

    the result type of the binary operator.

    z

    the start value.

    op

    the binary operator.

    returns

    the result of inserting op between consecutive elements of this array, going left to right with the start value z on the left:

    op(...op(z, x_1), x_2, ..., x_n)

    where x1, ..., xn are the elements of this array. Returns z if this array is empty.

  63. def foldRight[B](z: B)(op: (A, B) => B): B

    Applies a binary operator to all elements of this array and a start value, going right to left.

    Applies a binary operator to all elements of this array and a start value, going right to left.

    B

    the result type of the binary operator.

    z

    the start value.

    op

    the binary operator.

    returns

    the result of inserting op between consecutive elements of this array, going right to left with the start value z on the right:

    op(x_1, op(x_2, ... op(x_n, z)...))

    where x1, ..., xn are the elements of this array. Returns z if this array is empty.

  64. def forall(f: (A) => Boolean): Boolean

    Tests whether a predicate holds for all elements of this array.

    Tests whether a predicate holds for all elements of this array.

    returns

    true if this array is empty or the given predicate p holds for all elements of this array, otherwise false.

  65. def foreach[U](f: (A) => U): Unit

    Apply f to each element for its side effects.

    Apply f to each element for its side effects.

    Note: [U] parameter needed to help scalac's type inference.

  66. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from ArrayOps[A] toStringFormat[ArrayOps[A]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  67. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  68. def groupBy[K](f: (A) => K): Map[K, Array[A]]

    Partitions this array into a map of arrays according to some discriminator function.

    Partitions this array into a map of arrays according to some discriminator function.

    K

    the type of keys returned by the discriminator function.

    f

    the discriminator function.

    returns

    A map from keys to arrays such that the following invariant holds:

    (xs groupBy f)(k) = xs filter (x => f(x) == k)

    That is, every key k is bound to an array of those elements x for which f(x) equals k.

  69. def groupMap[K, B](key: (A) => K)(f: (A) => B): Map[K, Array[B]]

    Partitions this array into a map of arrays according to a discriminator function key.

    Partitions this array into a map of arrays according to a discriminator function key.

    Each element in a group is transformed into a value of type B using the value function.

    It is equivalent to groupBy(key).mapValues(_.map(f)), but more efficient.

    case class User(name: String, age: Int)
    
    def namesByAge(users: js.Array[User]): Map[Int, js.Array[String]] =
      users.groupMap(_.age)(_.name)
    K

    the type of keys returned by the discriminator function

    B

    the type of values returned by the transformation function

    key

    the discriminator function

    f

    the element transformation function

  70. def grouped(size: Int): collection.Iterator[Array[A]]

    Partitions elements in fixed size arrays.

    Partitions elements in fixed size arrays.

    size

    the number of elements per group

    returns

    An iterator producing arrays of size size, except the last will be less than size size if the elements don't divide evenly.

    Annotations
    @inline()
    See also

    scala.collection.Iterator, method grouped

  71. def head: A

    Selects the first element of this array.

    Selects the first element of this array.

    returns

    the first element of this array.

    Exceptions thrown

    NoSuchElementException if the array is empty.

  72. def headOption: Option[A]

    Optionally selects the first element.

    Optionally selects the first element.

    returns

    the first element of this array if it is nonempty, None if it is empty.

  73. def indexOf(elem: A, from: Int = 0): Int

    Finds the index of the first occurrence of some value in this array after or at some start index.

    Finds the index of the first occurrence of some value in this array after or at some start index.

    elem

    the element value to search for.

    from

    the start index

    returns

    the index >= from of the first element of this array that is equal (as determined by ==) to elem, or -1, if none exists.

  74. def indexWhere(f: (A) => Boolean, from: Int = 0): Int

    Finds the index of the first element satisfying some predicate after or at some start index.

    Finds the index of the first element satisfying some predicate after or at some start index.

    from

    the start index

    returns

    the index >= from of the first element of this array that satisfies the predicate p, or -1, if none exists.

  75. def indices: Range

    Produces the range of all indices of this sequence.

    Produces the range of all indices of this sequence.

    returns

    a Range value from 0 to one less than the length of this array.

    Annotations
    @inline()
  76. def init: Array[A]

    The initial part of the array without its last element.

  77. def inits: collection.Iterator[Array[A]]

    Iterates over the inits of this array.

    Iterates over the inits of this array.

    The first value will be this array and the final one will be an empty array, with the intervening values the results of successive applications of init.

    returns

    an iterator over all the inits of this array

  78. def insert(idx: Int, elem: A): Unit

    Inserts a new element at a given index into this array.

    Inserts a new element at a given index into this array.

    idx

    the index where the new elements is inserted.

    elem

    the element to insert.

    Exceptions thrown

    IndexOutOfBoundsException if the index idx is not in the valid range 0 <= idx <= length.

  79. def insertAll(idx: Int, elems: collection.IterableOnce[A]): Unit

    Inserts new elements at the index idx.

    Inserts new elements at the index idx.

    As opposed to the method update, this method will not replace an element with a new one. Instead, it will insert a new element at index idx.

    idx

    the index where a new element will be inserted.

    elems

    the iterable object providing all elements to insert.

    Exceptions thrown

    IndexOutOfBoundsException if idx is out of bounds.

  80. def intersect[B >: A](that: Seq[B]): Array[A]

    Computes the multiset intersection between this array and another sequence.

    Computes the multiset intersection between this array and another sequence.

    that

    the sequence of elements to intersect with.

    returns

    a new array which contains all elements of this array which also appear in that. If an element value x appears n times in that, then the first n occurrences of x will be retained in the result, but any following occurrences will be omitted.

  81. def isEmpty: Boolean

    Tests whether the array is empty.

    Tests whether the array is empty.

    returns

    true if the array contains no elements, false otherwise.

    Annotations
    @inline()
  82. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  83. def iterator: collection.Iterator[A]
    Annotations
    @inline()
  84. def knownSize: Int

    The size of this array.

    The size of this array.

    returns

    the number of elements in this array.

    Annotations
    @inline()
  85. def last: A

    Selects the last element of this array.

    Selects the last element of this array.

    returns

    the last element of this array.

    Exceptions thrown

    NoSuchElementException if the array is empty.

  86. def lastIndexOf(elem: A, end: Int = xs.length - 1): Int

    Finds the index of the last occurrence of some value in this array before or at a given end index.

    Finds the index of the last occurrence of some value in this array before or at a given end index.

    elem

    the element value to search for.

    end

    the end index.

    returns

    the index <= end of the last element of this array that is equal (as determined by ==) to elem, or -1, if none exists.

  87. def lastIndexWhere(p: (A) => Boolean, end: Int = xs.length - 1): Int

    Finds the index of the last element satisfying some predicate before or at given end index.

    Finds the index of the last element satisfying some predicate before or at given end index.

    p

    the predicate used to test elements.

    returns

    the index <= end of the last element of this array that satisfies the predicate p, or -1, if none exists.

  88. def lastOption: Option[A]

    Optionally selects the last element.

    Optionally selects the last element.

    returns

    the last element of this array$ if it is nonempty, None if it is empty.

  89. def lengthCompare(len: Int): Int

    Compares the length of this array to a test value.

    Compares the length of this array to a test value.

    len

    the test value that gets compared with the length.

    returns

    A value x where

    x <  0       if this.length <  len
    x == 0       if this.length == len
    x >  0       if this.length >  len
    Annotations
    @inline()
  90. def lengthIs: Int

    Method mirroring SeqOps.lengthIs for consistency, except it returns an Int because length is known and comparison is constant-time.

    Method mirroring SeqOps.lengthIs for consistency, except it returns an Int because length is known and comparison is constant-time.

    These operations are equivalent to lengthCompare(Int), and allow the following more readable usages:

    this.lengthIs < len     // this.lengthCompare(len) < 0
    this.lengthIs <= len    // this.lengthCompare(len) <= 0
    this.lengthIs == len    // this.lengthCompare(len) == 0
    this.lengthIs != len    // this.lengthCompare(len) != 0
    this.lengthIs >= len    // this.lengthCompare(len) >= 0
    this.lengthIs > len     // this.lengthCompare(len) > 0
  91. def map[B](f: (A) => B): Array[B]

    Builds a new array by applying a function to all elements of this array.

    Builds a new array by applying a function to all elements of this array.

    B

    the element type of the returned array.

    f

    the function to apply to each element.

    returns

    a new aray resulting from applying the given function f to each element of this array and collecting the results.

  92. def mapInPlace(f: (A) => A): Array[A]
  93. def nonEmpty: Boolean

    Tests whether the array is not empty.

    Tests whether the array is not empty.

    returns

    true if the array contains at least one element, false otherwise.

    Annotations
    @inline()
  94. def padTo[B >: A](len: Int, elem: B): Array[B]

    A copy of this array with an element value appended until a given target length is reached.

    A copy of this array with an element value appended until a given target length is reached.

    B

    the element type of the returned array.

    len

    the target length

    elem

    the padding value

    returns

    a new array consisting of all elements of this array followed by the minimal number of occurrences of elem so that the resulting collection has a length of at least len.

  95. def padToInPlace(len: Int, elem: A): Array[A]
  96. def partition(p: (A) => Boolean): (Array[A], Array[A])

    A pair of, first, all elements that satisfy predicate p and, second, all elements that do not.

  97. def partitionMap[A1, A2](f: (A) => Either[A1, A2]): (Array[A1], Array[A2])

    Applies a function f to each element of the array and returns a pair of arrays: the first one made of those values returned by f that were wrapped in scala.util.Left, and the second one made of those wrapped in scala.util.Right.

    Applies a function f to each element of the array and returns a pair of arrays: the first one made of those values returned by f that were wrapped in scala.util.Left, and the second one made of those wrapped in scala.util.Right.

    Example:

    val xs = js.Array(1, "one", 2, "two", 3, "three").partitionMap {
      case i: Int    => Left(i)
      case s: String => Right(s)
    }
    // xs == (js.Array(1, 2, 3),
    //        js.Array("one", "two", "three"))
    A1

    the element type of the first resulting collection

    A2

    the element type of the second resulting collection

    f

    the 'split function' mapping the elements of this array to an scala.util.Either

    returns

    a pair of arrays: the first one made of those values returned by f that were wrapped in scala.util.Left, and the second one made of those wrapped in scala.util.Right.

  98. def patch[B >: A](from: Int, other: collection.IterableOnce[B], replaced: Int): Array[B]

    Returns a copy of this array with patched values.

    Returns a copy of this array with patched values.

    Patching at negative indices is the same as patching starting at 0. Patching at indices at or larger than the length of the original array appends the patch to the end. If more values are replaced than actually exist, the excess is ignored.

    from

    The start index from which to patch

    other

    The patch values

    replaced

    The number of values in the original array that are replaced by the patch.

  99. def patchInPlace(from: Int, patch: collection.IterableOnce[A], replaced: Int): Array[A]
    Annotations
    @noinline()
  100. def permutations: collection.Iterator[Array[A]]

    Iterates over distinct permutations.

  101. def prepend(elem: A): Array[A]

    Prepends a single element at the front of this array.

    Prepends a single element at the front of this array.

    elem

    the element to add.

    returns

    the array itself

    Annotations
    @inline()
  102. def prependAll(elems: collection.IterableOnce[A]): Array[A]
    Annotations
    @inline()
  103. def prepended[B >: A](x: B): Array[B]

    A copy of this array with an element prepended.

  104. def prependedAll[B >: A](prefix: Array[_ <: B]): Array[B]

    A copy of this array with all elements of an array prepended.

  105. def prependedAll[B >: A](prefix: collection.IterableOnce[B]): Array[B]

    A copy of this array with all elements of a collection prepended.

  106. def remove(idx: Int, count: Int): Unit

    Removes consecutive elements starting at a given index position.

    Removes consecutive elements starting at a given index position.

    idx

    the index which refers to the first element to remove.

    count

    the number of elements to remove.

    Exceptions thrown

    IllegalArgumentException if count < 0.

    IndexOutOfBoundsException if the index idx is not in the valid range 0 <= idx <= length - count (with count > 0).

  107. def remove(idx: Int): A

    Removes the element at a given index position.

    Removes the element at a given index position.

    idx

    the index which refers to the element to delete.

    returns

    the element that was formerly at index idx.

    Exceptions thrown

    IndexOutOfBoundsException if idx is out of bounds.

  108. def reverse: Array[A]

    Returns a new array with the elements in reversed order.

  109. def reverseIterator: collection.Iterator[A]

    An iterator yielding elements in reversed order.

    An iterator yielding elements in reversed order.

    Note: xs.reverseIterator is the same as xs.reverse.iterator but implemented more efficiently.

    returns

    an iterator yielding the elements of this array in reversed order

  110. def scan[B >: A](z: B)(op: (B, B) => B): Array[B]

    Computes a prefix scan of the elements of the array.

    Computes a prefix scan of the elements of the array.

    Note: The neutral element z may be applied more than once.

    B

    element type of the resulting array

    z

    neutral element for the operator op

    op

    the associative operator for the scan

    returns

    a new array containing the prefix scan of the elements in this array

  111. def scanLeft[B](z: B)(op: (B, A) => B): Array[B]

    Produces an array containing cumulative results of applying the binary operator going left to right.

    Produces an array containing cumulative results of applying the binary operator going left to right.

    B

    the result type of the binary operator.

    z

    the start value.

    op

    the binary operator.

    returns

    array with intermediate values. Example:

    js.Array(1, 2, 3, 4).scanLeft(0)(_ + _) == js.Array(0, 1, 3, 6, 10)
  112. def scanRight[B](z: B)(op: (A, B) => B): Array[B]

    Produces an array containing cumulative results of applying the binary operator going right to left.

    Produces an array containing cumulative results of applying the binary operator going right to left.

    B

    the result type of the binary operator.

    z

    the start value.

    op

    the binary operator.

    returns

    array with intermediate values. Example:

    js.Array(4, 3, 2, 1).scanRight(0)(_ + _) == js.Array(10, 6, 3, 1, 0)
  113. def size: Int

    The size of this array.

    The size of this array.

    returns

    the number of elements in this array.

    Annotations
    @inline()
  114. def sizeCompare(otherSize: Int): Int

    Compares the size of this array to a test value.

    Compares the size of this array to a test value.

    otherSize

    the test value that gets compared with the size.

    returns

    A value x where

    x <  0       if this.size <  otherSize
    x == 0       if this.size == otherSize
    x >  0       if this.size >  otherSize
    Annotations
    @inline()
  115. def sizeIs: Int

    Method mirroring IterableOps.sizeIs for consistency, except it returns an Int because size is known and comparison is constant-time.

    Method mirroring IterableOps.sizeIs for consistency, except it returns an Int because size is known and comparison is constant-time.

    These operations are equivalent to sizeCompare(Int), and allow the following more readable usages:

    this.sizeIs < size     // this.sizeCompare(size) < 0
    this.sizeIs <= size    // this.sizeCompare(size) <= 0
    this.sizeIs == size    // this.sizeCompare(size) == 0
    this.sizeIs != size    // this.sizeCompare(size) != 0
    this.sizeIs >= size    // this.sizeCompare(size) >= 0
    this.sizeIs > size     // this.sizeCompare(size) > 0
  116. def slice(from: Int, until: Int): Array[A]

    Selects an interval of elements.

    Selects an interval of elements.

    The returned array is made up of all elements x which satisfy the invariant:

    from <= indexOf(x) < until
    from

    the lowest index to include from this array.

    until

    the lowest index to EXCLUDE from this array.

    returns

    an array containing the elements greater than or equal to index from extending up to (but not including) index until of this array.

    Annotations
    @inline()
  117. def sliceInPlace(start: Int, end: Int): Array[A]
  118. def sliding(size: Int, step: Int = 1): collection.Iterator[Array[A]]

    Groups elements in fixed size blocks by passing a "sliding window" over them (as opposed to partitioning them, as is done in grouped).

    Groups elements in fixed size blocks by passing a "sliding window" over them (as opposed to partitioning them, as is done in grouped).

    size

    the number of elements per group

    step

    the distance between the first elements of successive groups

    returns

    An iterator producing arrays of size size, except the last element (which may be the only element) will be truncated if there are fewer than size elements remaining to be grouped.

    See also

    scala.collection.Iterator, method sliding

  119. def sortBy[B](f: (A) => B)(implicit ord: Ordering[B]): Array[A]

    Sorts this array according to the Ordering which results from transforming an implicitly given Ordering with a transformation function.

    Sorts this array according to the Ordering which results from transforming an implicitly given Ordering with a transformation function.

    B

    the target type of the transformation f, and the type where the ordering ord is defined.

    f

    the transformation function mapping elements to some other domain B.

    ord

    the ordering assumed on domain B.

    returns

    an array consisting of the elements of this array sorted according to the ordering where x < y if ord.lt(f(x), f(y)).

    See also

    scala.math.Ordering

  120. def sortWith(lt: (A, A) => Boolean): Array[A]

    Sorts this array according to a comparison function.

    Sorts this array according to a comparison function.

    The sort is stable. That is, elements that are equal (as determined by lt) appear in the same order in the sorted sequence as in the original.

    lt

    the comparison function which tests whether its first argument precedes its second argument in the desired ordering.

    returns

    an array consisting of the elements of this array sorted according to the comparison function lt.

  121. def sorted[B >: A](implicit ord: Ordering[B]): Array[A]

    Sorts this array according to an Ordering.

    Sorts this array according to an Ordering.

    The sort is stable. That is, elements that are equal (as determined by lt) appear in the same order in the sorted sequence as in the original.

    ord

    the ordering to be used to compare elements.

    returns

    an array consisting of the elements of this array sorted according to the ordering ord.

    See also

    scala.math.Ordering

  122. def span(p: (A) => Boolean): (Array[A], Array[A])

    Splits this array into a prefix/suffix pair according to a predicate.

    Splits this array into a prefix/suffix pair according to a predicate.

    Note: c.span(p) is equivalent to (but more efficient than) (c.takeWhile(p), c.dropWhile(p)), provided the evaluation of the predicate p does not cause any side-effects.

    p

    the test predicate

    returns

    a pair consisting of the longest prefix of this array whose chars all satisfy p, and the rest of this array.

  123. def splitAt(n: Int): (Array[A], Array[A])

    Splits this array into two at a given position.

    Splits this array into two at a given position.

    Note: c.splitAt(n) is equivalent to (c.take(n), c.drop(n)).

    n

    the position at which to split.

    returns

    a pair of arrays consisting of the first n elements of this array, and the other elements.

  124. def startsWith[B >: A](that: collection.IterableOnce[B], offset: Int = 0): Boolean

    Tests whether this array contains the given sequence at a given index.

    Tests whether this array contains the given sequence at a given index.

    that

    the sequence to test

    offset

    the index where the sequence is searched.

    returns

    true if the sequence that is contained in this array at index offset, otherwise false.

  125. def startsWith[B >: A](that: Array[B], offset: Int): Boolean

    Tests whether this array contains the given array at a given index.

    Tests whether this array contains the given array at a given index.

    that

    the array to test

    offset

    the index where the array is searched.

    returns

    true if the array that is contained in this array at index offset, otherwise false.

  126. def startsWith[B >: A](that: Array[B]): Boolean

    Tests whether this array starts with the given array.

    Tests whether this array starts with the given array.

    Annotations
    @inline()
  127. def subtractAll(ys: collection.IterableOnce[A]): Array[A]

    Removes all elements produced by an iterator from this array.

    Removes all elements produced by an iterator from this array.

    returns

    the array itself

    Annotations
    @inline()
  128. def subtractOne(elem: A): Array[A]

    Removes a single element from this array.

    Removes a single element from this array.

    elem

    the element to remove.

    returns

    the array itself

  129. def tail: Array[A]

    The rest of the array without its first element.

  130. def tails: collection.Iterator[Array[A]]

    Iterates over the tails of this array.

    Iterates over the tails of this array.

    The first value will be this array and the final one will be an empty array, with the intervening values the results of successive applications of tail.

    returns

    an iterator over all the tails of this array

  131. def take(n: Int): Array[A]

    An array containing the first n elements of this array.

    An array containing the first n elements of this array.

    Annotations
    @inline()
  132. def takeInPlace(n: Int): Array[A]
  133. def takeRight(n: Int): Array[A]

    An array containing the last n elements of this array.

  134. def takeRightInPlace(n: Int): Array[A]
  135. def takeWhile(p: (A) => Boolean): Array[A]

    Takes the longest prefix of elements that satisfy a predicate.

    Takes the longest prefix of elements that satisfy a predicate.

    p

    The predicate used to test elements.

    returns

    the longest prefix of this array whose elements all satisfy the predicate p.

  136. def takeWhileInPlace(p: (A) => Boolean): Array[A]
  137. def toArray[B >: A](implicit arg0: ClassTag[B]): scala.Array[B]

    Create a copy of this array as a Scala array.

  138. def toIndexedSeq: collection.immutable.IndexedSeq[A]
    Annotations
    @inline()
  139. final def toSeq: collection.immutable.Seq[A]
    Annotations
    @inline()
  140. def toString(): String
    Definition Classes
    Any
  141. def transpose[B](implicit asArray: (A) => Array[B]): Array[Array[B]]

    Transposes a two dimensional array.

    Transposes a two dimensional array.

    B

    Type of row elements.

    asArray

    A function that converts elements of this array to rows - arrays of type B.

    returns

    An array obtained by replacing elements of this arrays with rows the represent.

  142. def trimEnd(n: Int): Unit

    Removes the last n elements of this array.

    Removes the last n elements of this array.

    n

    the number of elements to remove from the end of this array.

  143. def trimStart(n: Int): Unit

    Removes the first n elements of this array.

    Removes the first n elements of this array.

    n

    the number of elements to remove from the beginning of this array.

  144. def unzip[A1, A2](implicit asPair: (A) => (A1, A2)): (Array[A1], Array[A2])

    Converts an array of pairs into an array of first elements and an array of second elements.

    Converts an array of pairs into an array of first elements and an array of second elements.

    A1

    the type of the first half of the element pairs

    A2

    the type of the second half of the element pairs

    asPair

    an implicit conversion which asserts that the element type of this array is a pair.

    returns

    a pair of Arrays, containing, respectively, the first and second half of each element pair of this array.

  145. def unzip3[A1, A2, A3](implicit asTriple: (A) => (A1, A2, A3)): (Array[A1], Array[A2], Array[A3])

    Converts an array of triples into three arrays, one containing the elements from each position of the triple.

    Converts an array of triples into three arrays, one containing the elements from each position of the triple.

    A1

    the type of the first of three elements in the triple

    A2

    the type of the second of three elements in the triple

    A3

    the type of the third of three elements in the triple

    asTriple

    an implicit conversion which asserts that the element type of this array is a triple.

    returns

    a triple of Arrays, containing, respectively, the first, second, and third elements from each element triple of this array.

  146. def updated[B >: A](index: Int, elem: B): Array[B]

    A copy of this array with one single replaced element.

    A copy of this array with one single replaced element.

    index

    the position of the replacement

    elem

    the replacing element

    returns

    a new array which is a copy of this array with the element at position index replaced by elem.

    Exceptions thrown

    IndexOutOfBoundsException if index does not satisfy 0 <= index < length.

  147. def view: IndexedSeqView[A]
    Annotations
    @inline()
  148. def withFilter(p: (A) => Boolean): WithFilter[A]

    Creates a non-strict filter of this array.

    Creates a non-strict filter of this array.

    Note: the difference between c.filter(p) and c.withFilter(p) is that the former creates a new array, whereas the latter only restricts the domain of subsequent map, flatMap, foreach, and withFilter operations.

    p

    the predicate used to test elements.

    returns

    an object of class js.ArrayOps.WithFilter, which supports map, flatMap, foreach, and withFilter operations. All these operations apply to those elements of this array which satisfy the predicate p.

  149. def zip[B](that: collection.IterableOnce[B]): Array[(A, B)]

    Returns an array formed from this array and another iterable collection by combining corresponding elements in pairs.

    Returns an array formed from this array and another iterable collection by combining corresponding elements in pairs.

    If one of the two collections is longer than the other, its remaining elements are ignored.

    B

    the type of the second half of the returned pairs

    that

    The iterable providing the second half of each result pair

    returns

    a new array containing pairs consisting of corresponding elements of this array and that. The length of the returned array is the minimum of the lengths of this array and that.

  150. def zipAll[A1 >: A, B](that: collection.Iterable[B], thisElem: A1, thatElem: B): Array[(A1, B)]

    Returns an array formed from this array and another iterable collection by combining corresponding elements in pairs.

    Returns an array formed from this array and another iterable collection by combining corresponding elements in pairs.

    If one of the two collections is shorter than the other, placeholder elements are used to extend the shorter collection to the length of the longer.

    that

    the iterable providing the second half of each result pair

    thisElem

    the element to be used to fill up the result if this array is shorter than that.

    thatElem

    the element to be used to fill up the result if that is shorter than this array.

    returns

    a new array containing pairs consisting of corresponding elements of this array and that. The length of the returned array is the maximum of the lengths of this array and that. If this array is shorter than that, thisElem values are used to pad the result. If that is shorter than this array, thatElem values are used to pad the result.

  151. def zipWithIndex: Array[(A, Int)]

    Zips this array with its indices.

    Zips this array with its indices.

    returns

    A new array containing pairs consisting of all elements of this array paired with their index. Indices start at 0.

Deprecated Value Members

  1. final def +=(elem1: A, elem2: A, elems: A*): Array[A]

    Adds two or more elements to this array.

    Adds two or more elements to this array.

    elem1

    the first element to add.

    elem2

    the second element to add.

    elems

    the remaining elements to add.

    returns

    the array itself

    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.13.0) Use ++= (addAll) instead of varargs +=

  2. def -=(elem1: A, elem2: A, elems: A*): Array[A]

    Removes two or more elements from this array.

    Removes two or more elements from this array.

    elem1

    the first element to remove.

    elem2

    the second element to remove.

    elems

    the remaining elements to remove.

    returns

    the array itself

    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use --= (subtractAll) instead of varargs -=

  3. final def append(elems: A*): Array[A]
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.13.0) Use appendAll instead

  4. final def prepend(elems: A*): Array[A]
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.13.0) Use prependAll instead

  5. def [B](y: B): (ArrayOps[A], B)
    Implicit
    This member is added by an implicit conversion from ArrayOps[A] toArrowAssoc[ArrayOps[A]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use -> instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

Inherited from AnyVal

Inherited from scala.Any

Inherited by implicit conversion any2stringadd fromArrayOps[A] to any2stringadd[ArrayOps[A]]

Inherited by implicit conversion StringFormat fromArrayOps[A] to StringFormat[ArrayOps[A]]

Inherited by implicit conversion Ensuring fromArrayOps[A] to Ensuring[ArrayOps[A]]

Inherited by implicit conversion ArrowAssoc fromArrayOps[A] to ArrowAssoc[ArrayOps[A]]

Ungrouped