scala

class Array

[source: scala/Array.scala]

final class Array[A](_length : Int)
extends Array0[A]
This class represents polymorphic arrays. Array[T] is Scala's representation for Java's T[].
Author
Martin Odersky
Version
1.0
Additional Constructor Summary
def this (dim1 : Int, dim2 : Int, dim3 : Int, dim4 : Int) : Array[A]
Multidimensional array creation
def this (dim1 : Int, dim2 : Int, dim3 : Int, dim4 : Int, dim5 : Int, dim6 : Int, dim7 : Int, dim8 : Int, dim9 : Int) : Array[A]
Multidimensional array creation
def this (dim1 : Int, dim2 : Int, dim3 : Int, dim4 : Int, dim5 : Int, dim6 : Int) : Array[A]
Multidimensional array creation
def this (dim1 : Int, dim2 : Int, dim3 : Int) : Array[A]
Multidimensional array creation
def this (dim1 : Int, dim2 : Int, dim3 : Int, dim4 : Int, dim5 : Int) : Array[A]
Multidimensional array creation
def this (dim1 : Int, dim2 : Int) : Array[A]
Multidimensional array creation
def this (dim1 : Int, dim2 : Int, dim3 : Int, dim4 : Int, dim5 : Int, dim6 : Int, dim7 : Int, dim8 : Int) : Array[A]
Multidimensional array creation
def this (dim1 : Int, dim2 : Int, dim3 : Int, dim4 : Int, dim5 : Int, dim6 : Int, dim7 : Int) : Array[A]
Multidimensional array creation
Method Summary
override def ++ [B >: A](that : Iterable[B]) : Array[B]
Returns an array consisting of all elements of this array followed by all elements of the argument iterable.
def apply (i : Int) : A
The element at given index.
def deepEquals (that : Any) : Boolean
def deepMkString (start : java.lang.String, sep : java.lang.String, end : java.lang.String) : java.lang.String
def deepMkString (sep : java.lang.String) : java.lang.String
Returns a string representation of this array object. The string representations of elements (w.r.t. the method deepToString()) are separated by the string sep.
def deepToString : java.lang.String
override def elements : Iterator[A]
An iterator returning the elements of this array, starting from 0.
override def filter (p : (A) => Boolean) : Array[A]
Returns an array consisting of all elements of this array that satisfy the predicate p. The order of the elements is preserved.
override def flatMap [B](f : (A) => Iterable[B]) : Array[B]
Applies the given function f to each element of this array, then concatenates the results.
def indices : Array[Int]
Returns an array that contains all indices of this array
def length : Int
The length of the array
override def map [B](f : (A) => B) : Array[B]
Returns the array resulting from applying the given function f to each element of this array.
def subArray (from : Int, end : Int) : Array[A]
override def update (i : Int, x : A) : Unit
def zip [B](that : Array[B]) : Array[(A, B)]
Returns an array formed from this array and the specified array that by associating each element of the former with the element at the same position in the latter. If one of the two arrays is longer than the other, its remaining elements are ignored.
def zipWithIndex : Array[(A, Int)]
Returns an array that pairs each element of this array with its index, counting from 0.
Methods inherited from Array0
projection, slice, take, drop, dropWhile, takeWhile, reverse, force
Methods inherited from Mutable
readOnly
Methods inherited from RandomAccessSeq
partition, patch, toStream, safeIs
Methods inherited from Seq
lengthCompare, size, isEmpty, concat, last, lastOption, first, firstOption, headOption, isDefinedAt, lastIndexOf, findIndexOf, indexOf, slice, contains, subseq, toArray, toSeq, equalsWith, startsWith, startsWith, endsWith, indexOf, containsSlice
Methods inherited from Collection
toString, stringPrefix
Methods inherited from Iterable
foreach, forall, exists, find, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, mkString, mkString, mkString, addString, addString, addString, copyToArray, hasDefiniteSize
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
compose
Methods inherited from AnyRef
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Additional Constructor Details
def this(dim1 : Int, dim2 : Int) : Array[A]
Multidimensional array creation

def this(dim1 : Int, dim2 : Int, dim3 : Int) : Array[A]
Multidimensional array creation

def this(dim1 : Int, dim2 : Int, dim3 : Int, dim4 : Int) : Array[A]
Multidimensional array creation

def this(dim1 : Int, dim2 : Int, dim3 : Int, dim4 : Int, dim5 : Int) : Array[A]
Multidimensional array creation

def this(dim1 : Int, dim2 : Int, dim3 : Int, dim4 : Int, dim5 : Int, dim6 : Int) : Array[A]
Multidimensional array creation

def this(dim1 : Int, dim2 : Int, dim3 : Int, dim4 : Int, dim5 : Int, dim6 : Int, dim7 : Int) : Array[A]
Multidimensional array creation

def this(dim1 : Int, dim2 : Int, dim3 : Int, dim4 : Int, dim5 : Int, dim6 : Int, dim7 : Int, dim8 : Int) : Array[A]
Multidimensional array creation

def this(dim1 : Int, dim2 : Int, dim3 : Int, dim4 : Int, dim5 : Int, dim6 : Int, dim7 : Int, dim8 : Int, dim9 : Int) : Array[A]
Multidimensional array creation

Method Details
def length : Int
The length of the array

def apply(i : Int) : A
The element at given index.

Indices start a 0; xs.apply(0) is the first element of array xs.

Note the indexing syntax xs(i) is a shorthand for xs.apply(i).

Parameters
i - the index
Throws
ArrayIndexOutOfBoundsException - if i < 0 or length <= i

override def update(i : Int, x : A) : Unit

Update the element at given index.

Indices start a 0; xs.apply(0) is the first element of array xs.

Note the indexing syntax xs(i) = x is a shorthand for xs.update(i, x).

Parameters
i - the index
x - the value to be written at index i
Throws
ArrayIndexOutOfBoundsException - if i < 0 or length <= i

override def elements : Iterator[A]
An iterator returning the elements of this array, starting from 0.

def subArray(from : Int, end : Int) : Array[A]
Deprecated
use slice(from,end).force instead

override def filter(p : (A) => Boolean) : Array[A]
Returns an array consisting of all elements of this array that satisfy the predicate p. The order of the elements is preserved.
Parameters
p - the predicate used to filter the array.
Returns
the elements of this array satisfying p.

override def ++[B >: A](that : Iterable[B]) : Array[B]
Returns an array consisting of all elements of this array followed by all elements of the argument iterable.

override def map[B](f : (A) => B) : Array[B]
Returns the array resulting from applying the given function f to each element of this array.
Parameters
f - function to apply to each element.
Returns
[f(a0), ..., f(an)] if this array is [a0, ..., an].

override def flatMap[B](f : (A) => Iterable[B]) : Array[B]
Applies the given function f to each element of this array, then concatenates the results.
Parameters
f - the function to apply on each element.
Returns
f(a0) ::: ... ::: f(an) if this array is [a0, ..., an].

def zip[B](that : Array[B]) : Array[(A, B)]
Returns an array formed from this array and the specified array that by associating each element of the former with the element at the same position in the latter. If one of the two arrays is longer than the other, its remaining elements are ignored.
Returns
Array({a0,b0}, ..., {amin(m,n),bmin(m,n)}) when Array(a0, ..., am) zip Array(b0, ..., bn) is invoked.

def zipWithIndex : Array[(A, Int)]
Returns an array that pairs each element of this array with its index, counting from 0.
Returns
the array Array({a0,0}, {a1,1},...) where ai are the elements of this stream.

def indices : Array[Int]
Returns an array that contains all indices of this array

def deepToString : java.lang.String
Returns
a deep string representation of this array.

def deepMkString(start : java.lang.String, sep : java.lang.String, end : java.lang.String) : java.lang.String

Returns a string representation of this array object. The resulting string begins with the string start and is finished by the string end. Inside, the string representations of elements (w.r.t. the method deepToString()) are separated by the string sep. For example:

Array(Array(1, 2), Array(3)).deepMkString("[", "; ", "]") = "[[1; 2]; [3]]"

Parameters
start - starting string.
sep - separator string.
end - ending string.
Returns
a string representation of this array object.

def deepMkString(sep : java.lang.String) : java.lang.String
Returns a string representation of this array object. The string representations of elements (w.r.t. the method deepToString()) are separated by the string sep.
Parameters
sep - separator string.
Returns
a string representation of this array object.

def deepEquals(that : Any) : Boolean

Returns true if the two specified arrays are deeply equal to one another.

Two array references are considered deeply equal if both are null, or if they refer to arrays that contain the same number of elements and all corresponding pairs of elements in the two arrays are deeply equal.

See also method deepEquals in the Java class java.utils.Arrays

Parameters
that - the second
Returns
true iff both arrays are deeply equal.