A copy of this array with an element appended.
A copy of this array with an element appended.
AttributesA copy of this array with all elements of a collection appended.
A copy of this array with all elements of a collection appended.
AttributesA copy of this array with all elements of an array appended.
A copy of this array with all elements of an array appended.
AttributesBuilds 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.
Type parametersthe element type of the returned array.
the partial function which filters and maps the array.
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.
Finds the first element of the array for which the given partial function is defined, and applies the partial function to it.
Finds the first element of the array for which the given partial function is defined, and applies the partial function to it.
AttributesIterates over combinations of elements.
Iterates over combinations of elements.
A combination of length n
is a sequence of n
elements selected in order of their first index in this sequence.
For example, "xyx"
has two combinations of length 2. The x
is selected first: "xx"
, "xy"
. The sequence "yx"
is not returned as a combination because it is subsumed by "xy"
.
If there is more than one way to generate the same combination, only one will be returned.
For example, the result "xy"
arbitrarily selected one of the x
elements.
As a further illustration, "xyxx"
has three different ways to generate "xy"
because there are three elements x
to choose from. Moreover, there are three unordered pairs "xx"
but only one is returned.
It is not specified which of these equal combinations is returned. It is an implementation detail that should not be relied on. For example, the combination "xx"
does not necessarily contain the first x
in this sequence. This behavior is observable if the elements compare equal but are not identical.
As a consequence, "xyx".combinations(3).next()
is "xxy"
: the combination does not reflect the order of the original sequence, but the order in which elements were selected, by "first index"; the order of each x
element is also arbitrary.
An Iterator which traverses the n-element combinations of this array
Array('a', 'b', 'b', 'b', 'c').combinations(2).map(runtime.ScalaRunTime.stringOf).foreach(println)
// Array(a, b)
// Array(a, c)
// Array(b, b)
// Array(b, c)
Array('b', 'a', 'b').combinations(2).map(runtime.ScalaRunTime.stringOf).foreach(println)
// Array(b, b)
// Array(b, a)
Tests whether this array contains a given value as an element.
Tests whether this array contains a given value as an element.
Value parametersthe element to test.
true
if this array has an element that is equal (as determined by ==
) to elem
, false
otherwise.
Copy elements of this array to another array.
Copy elements of this array to another 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.
the type of the elements of the array.
the array to fill.
Copy elements of this array to another array.
Copy elements of this array to another 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.
the type of the elements of the array.
the starting index within the destination array.
the array to fill.
Copy elements of this array to another array.
Copy elements of this array to another 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.
the type of the elements of the array.
the maximal number of elements to copy.
the starting index within the destination array.
the array to fill.
Counts the number of elements in this array which satisfy a predicate
Counts the number of elements in this array which satisfy a predicate
AttributesComputes the multiset difference between this array and another sequence.
Computes the multiset difference between this array and another sequence.
Value parametersthe sequence of elements to remove
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.
Selects all the elements of this array ignoring the duplicates.
Selects all the elements of this array ignoring the duplicates.
Attributesa new array consisting of all the elements of this array without duplicates.
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
.
the type of the elements after being transformed by f
The transforming function whose result is used to determine the uniqueness of each element
a new array consisting of all the elements of this array without duplicates.
The rest of the array without its n
first elements.
The rest of the array without its n
first elements.
The rest of the array without its n
last elements.
The rest of the array without its n
last elements.
Drops longest prefix of elements that satisfy a predicate.
Drops longest prefix of elements that satisfy a predicate.
Value parametersThe predicate used to test elements.
the longest suffix of this array whose first element does not satisfy the predicate p
.
Tests whether this array ends with the given array.
Tests whether this array ends with the given array.
Value parametersthe array to test
true
if this array has that
as a suffix, false
otherwise.
Tests whether this array ends with the given sequence.
Tests whether this array ends with the given sequence.
Value parametersthe sequence to test
true
if this array has that
as a suffix, false
otherwise.
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.
Value parametersthe predicate used to test elements.
true
if the given predicate p
is satisfied by at least one element of this array, otherwise false
Selects all elements of this array which satisfy a predicate.
Selects all elements of this array which satisfy a predicate.
Value parametersthe predicate used to test elements.
a new array consisting of all elements of this array that satisfy the given predicate p
.
Selects all elements of this array which do not satisfy a predicate.
Selects all elements of this array which do not satisfy a predicate.
Value parametersthe predicate used to test elements.
a new array consisting of all elements of this array that do not satisfy the given predicate p
.
Finds the first element of the array satisfying a predicate, if any.
Finds the first element of the array satisfying a predicate, if any.
Value parametersthe predicate used to test elements.
an option value containing the first element in the array that satisfies p
, or None
if none exists.
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.
Type parametersthe element type of the returned array.
the function to apply to each element.
a new array resulting from applying the given collection-valued function f
to each element of this array and concatenating the results.
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.
Type parametersType of row elements.
A function that converts elements of this array to rows - Iterables of type B
.
An array obtained by concatenating rows of this array.
Folds the elements of this array using the specified associative binary operator.
Folds the elements of this array using the specified associative binary operator.
Type parametersa type parameter for the binary operator, a supertype of A
.
a binary operator that must be associative.
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).
the result of applying the fold operator op
between all the elements, or z
if this array is empty.
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.
Type parametersthe result type of the binary operator.
the binary operator.
the start value.
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.
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.
Type parametersthe result type of the binary operator.
the binary operator.
the start value.
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.
Tests whether a predicate holds for all elements of this array.
Tests whether a predicate holds for all elements of this array.
Value parametersthe predicate used to test elements.
true
if this array is empty or the given predicate p
holds for all elements of this array, otherwise false
.
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.
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.
Type parametersthe type of keys returned by the discriminator function.
the discriminator function.
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
.
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: Array[User]): Map[Int, Array[String]] =
users.groupMap(_.age)(_.name)
Type parameters
the type of values returned by the transformation function
the type of keys returned by the discriminator function
the element transformation function
the discriminator function
Partitions elements in fixed size arrays.
Partitions elements in fixed size arrays.
Value parametersthe number of elements per group
An iterator producing arrays of size size
, except the last will be less than size size
if the elements don't divide evenly.
Selects the first element of this array.
Selects the first element of this array.
Attributesthe first element of this array.
Optionally selects the first element.
Optionally selects the first element.
Attributesthe first element of this array if it is nonempty, None
if it is empty.
Finds index of first occurrence of some value in this array after or at some start index.
Finds index of first occurrence of some value in this array after or at some start index.
Value parametersthe element value to search for.
the start index
the index >= from
of the first element of this array that is equal (as determined by ==
) to elem
, or -1
, if none exists.
Finds index of the first element satisfying some predicate after or at some start index.
Finds index of the first element satisfying some predicate after or at some start index.
Value parametersthe start index
the predicate used to test elements.
the index >= from
of the first element of this array that satisfies the predicate p
, or -1
, if none exists.
Produces the range of all indices of this sequence.
Produces the range of all indices of this sequence.
Attributesa Range
value from 0
to one less than the length of this array.
The initial part of the array without its last element.
The initial part of the array without its last element.
AttributesIterates 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
.
an iterator over all the inits of this array
Computes the multiset intersection between this array and another sequence.
Computes the multiset intersection between this array and another sequence.
Value parametersthe sequence of elements to intersect with.
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.
Tests whether the array is empty.
Tests whether the array is empty.
Attributestrue
if the array contains no elements, false
otherwise.
The size of this array.
The size of this array.
Attributesthe number of elements in this array.
Selects the last element.
Selects the last element.
AttributesThe last element of this array.
Finds index of last occurrence of some value in this array before or at a given end index.
Finds index of last occurrence of some value in this array before or at a given end index.
Value parametersthe element value to search for.
the end index.
the index <= end
of the last element of this array that is equal (as determined by ==
) to elem
, or -1
, if none exists.
Finds index of last element satisfying some predicate before or at given end index.
Finds index of last element satisfying some predicate before or at given end index.
Value parametersthe predicate used to test elements.
the index <= end
of the last element of this array that satisfies the predicate p
, or -1
, if none exists.
Optionally selects the last element.
Optionally selects the last element.
Attributesthe last element of this array$ if it is nonempty, None
if it is empty.
Analogous to zip
except that the elements in each collection are not consumed until a strict operation is invoked on the returned LazyZip2
decorator.
Analogous to zip
except that the elements in each collection are not consumed until a strict operation is invoked on the returned LazyZip2
decorator.
Calls to lazyZip
can be chained to support higher arities (up to 4) without incurring the expense of constructing and deconstructing intermediary tuples.
val xs = List(1, 2, 3)
val res = (xs lazyZip xs lazyZip xs lazyZip xs).map((a, b, c, d) => a + b + c + d)
// res == List(4, 8, 12)
Type parameters
the type of the second element in each eventual pair
the iterable providing the second element of each eventual pair
a decorator LazyZip2
that allows strict operations to be performed on the lazily evaluated pairs or chained calls to lazyZip
. Implicit conversion to Iterable[(A, B)]
is also supported.
Compares the length of this array to a test value.
Compares the length of this array to a test value.
Value parametersthe test value that gets compared with the length.
A value x
where
x < 0 if this.length < len
x == 0 if this.length == len
x > 0 if this.length > len
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
Attributes
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.
Type parametersthe element type of the returned array.
the function to apply to each element.
a new array resulting from applying the given function f
to each element of this array and collecting the results.
Tests whether the array is not empty.
Tests whether the array is not empty.
Attributestrue
if the array contains at least one element, false
otherwise.
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.
Type parametersthe element type of the returned array.
the padding value
the target length
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
.
A pair of, first, all elements that satisfy predicate p
and, second, all elements that do not.
A pair of, first, all elements that satisfy predicate p
and, second, all elements that do not.
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 = Array(1, "one", 2, "two", 3, "three") partitionMap {
case i: Int => Left(i)
case s: String => Right(s)
}
// xs == (Array(1, 2, 3),
// Array(one, two, three))
Type parameters
the element type of the first resulting collection
the element type of the second resulting collection
the 'split function' mapping the elements of this array to an scala.util.Either
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.
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.
Value parametersThe start index from which to patch
The patch values
The number of values in the original array that are replaced by the patch.
Iterates over distinct permutations of elements.
Iterates over distinct permutations of elements.
AttributesAn Iterator which traverses the distinct permutations of this array.
Array('a', 'b', 'b').permutations.map(runtime.ScalaRunTime.stringOf).foreach(println)
// Array(a, b, b)
// Array(b, a, b)
// Array(b, b, a)
A copy of this array with an element prepended.
A copy of this array with an element prepended.
AttributesA copy of this array with all elements of a collection prepended.
A copy of this array with all elements of a collection prepended.
AttributesA copy of this array with all elements of an array prepended.
A copy of this array with all elements of an array prepended.
AttributesReturns a new array with the elements in reversed order.
Returns a new array with the elements in reversed order.
AttributesAn 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.
an iterator yielding the elements of this array in reversed order
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.
element type of the resulting array
the associative operator for the scan
neutral element for the operator op
a new array containing the prefix scan of the elements in this array
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.
Type parametersthe result type of the binary operator.
the binary operator.
the start value.
array with intermediate values. Example:
Array(1, 2, 3, 4).scanLeft(0)(_ + _) == Array(0, 1, 3, 6, 10)
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.
Type parametersthe result type of the binary operator.
the binary operator.
the start value.
array with intermediate values. Example:
Array(4, 3, 2, 1).scanRight(0)(_ + _) == Array(10, 6, 3, 1, 0)
The size of this array.
The size of this array.
Attributesthe number of elements in this array.
Compares the size of this array to a test value.
Compares the size of this array to a test value.
Value parametersthe test value that gets compared with the size.
A value x
where
x < 0 if this.size < otherSize
x == 0 if this.size == otherSize
x > 0 if this.size > otherSize
Method mirroring SeqOps.sizeIs for consistency, except it returns an Int
because size
is known and comparison is constant-time.
Method mirroring SeqOps.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
Attributes
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
Value parameters
the lowest index to include from this array.
the lowest index to EXCLUDE from this array.
an array containing the elements greater than or equal to index from
extending up to (but not including) index until
of this array.
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.)
Value parametersthe number of elements per group
the distance between the first elements of successive groups
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.
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.
Type parametersthe target type of the transformation f
, and the type where the ordering ord
is defined.
the transformation function mapping elements to some other domain B
.
the ordering assumed on domain B
.
an array consisting of the elements of this array sorted according to the ordering where x < y
if ord.lt(f(x), f(y))
.
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.
the comparison function which tests whether its first argument precedes its second argument in the desired ordering.
an array consisting of the elements of this array sorted according to the comparison function lt
.
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.
the ordering to be used to compare elements.
an array consisting of the elements of this array sorted according to the ordering ord
.
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.
the test predicate
a pair consisting of the longest prefix of this array whose elements all satisfy p
, and the rest of this array.
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)
.
the position at which to split.
a pair of arrays consisting of the first n
elements of this array, and the other elements.
Tests whether this array starts with the given array.
Tests whether this array starts with the given array.
AttributesTests whether this array contains the given array at a given index.
Tests whether this array contains the given array at a given index.
Value parametersthe index where the array is searched.
the array to test
true
if the array that
is contained in this array at index offset
, otherwise false
.
Tests whether this array contains the given sequence at a given index.
Tests whether this array contains the given sequence at a given index.
Value parametersthe index where the sequence is searched.
the sequence to test
true
if the sequence that
is contained in this array at index offset
, otherwise false
.
The rest of the array without its first element.
The rest of the array without its first element.
AttributesIterates 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
.
an iterator over all the tails of this array
An array containing the first n
elements of this array.
An array containing the first n
elements of this array.
An array containing the last n
elements of this array.
An array containing the last n
elements of this array.
Takes longest prefix of elements that satisfy a predicate.
Takes longest prefix of elements that satisfy a predicate.
Value parametersThe predicate used to test elements.
the longest prefix of this array whose elements all satisfy the predicate p
.
Create a copy of this array with the specified element type.
Create a copy of this array with the specified element type.
AttributesTransposes a two dimensional array.
Transposes a two dimensional array.
Type parametersType of row elements.
A function that converts elements of this array to rows - arrays of type B
.
An array obtained by replacing elements of this arrays with rows the represent.
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.
Type parametersthe type of the first half of the element pairs
the type of the second half of the element pairs
an implicit conversion which asserts that the element type of this Array is a pair.
a class tag for A1
type parameter that is required to create an instance of Array[A1]
a class tag for A2
type parameter that is required to create an instance of Array[A2]
a pair of Arrays, containing, respectively, the first and second half of each element pair of this Array.
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.
Type parametersthe type of the first of three elements in the triple
the type of the second of three elements in the triple
the type of the third of three elements in the triple
an implicit conversion which asserts that the element type of this Array is a triple.
a class tag for T1 type parameter that is required to create an instance of Array[T1]
a class tag for T2 type parameter that is required to create an instance of Array[T2]
a class tag for T3 type parameter that is required to create an instance of Array[T3]
a triple of Arrays, containing, respectively, the first, second, and third elements from each element triple of this Array.
A copy of this array with one single replaced element.
A copy of this array with one single replaced element.
Value parametersthe replacing element
the position of the replacement
a new array which is a copy of this array with the element at position index
replaced by elem
.
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.
the predicate used to test elements.
an object of class 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
.
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.
Type parametersthe type of the second half of the returned pairs
The iterable providing the second half of each result pair
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
.
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.
Value parametersthe iterable providing the second half of each result pair
the element to be used to fill up the result if that
is shorter than this array.
the element to be used to fill up the result if this array is shorter than that
.
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.
Zips this array with its indices.
Zips this array with its indices.
AttributesA new array containing pairs consisting of all elements of this array paired with their index. Indices start at 0
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4