Scala Library Documentation
|
|
scala/Array.scala
]
final
class
Array[A](_length : Int)
extends
Seq[A]Array[T]
is Scala's representation
for Java's T[]
.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.
Indices start a
Note the indexing syntax |
def
|
deepEquals
(that : Any) : Boolean
Returns 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 |
def
|
deepMkString
(start : String, sep : String, end : String) : String
Returns a string representation of this array object. The resulting string
begins with the string
|
def
|
deepMkString
(sep : String) : 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 : String |
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
|
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. |
override def
|
slice
(from : Int, end : Int) : Array[A]
A sub-array of
len elements
starting at index from |
def
|
subArray (from : Int, end : Int) : Array[A] |
def
|
update
(i : Int, x : A) : Unit
Update the element at given index.
Indices start a
Note the indexing syntax |
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 Seq | |
size, isEmpty, concat, isDefinedAt, lastIndexOf, take, drop, takeWhile, dropWhile, reverse, contains, subseq, toArray |
Methods inherited from Collection | |
toString, stringPrefix |
Methods inherited from Iterable | |
foreach, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, mkString, mkString, addString, addString, copyToArray, projection, 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 |
Method Details |
def
length : Int
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)
.
i -
the indexArrayIndexOutOfBoundsException -
if i < 0
or length <= i
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)
.
i -
the indexx -
the value to be written at index i
ArrayIndexOutOfBoundsException -
if i < 0
or length <= i
len
elements
starting at index from
from -
The index of the first element of the sliceend -
The index of the element following the sliceIndexOutOfBoundsException -
if from < 0
or length < from + len
p
. The order of the elements is preserved.p -
the predicate used to filter the array.p
.f
to each
element of this array.f -
function to apply to each element.[f(a0), ..., f(an)]
if this array is [a0, ..., an]
.f
to each element of
this array, then concatenates the results.f -
the function to apply on each element.f(a0) ::: ... ::: f(an)
if this array is [a0, ..., an]
.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.Array({a0,b0}, ..., {amin(m,n),bmin(m,n)})
when
Array(a0, ..., am)
zip Array(b0, ..., bn)
is invoked.Array({a0,0}, {a1,1},...)
where ai
are the elements of this stream.
def
deepToString : 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]]"
start -
starting string.sep -
separator string.end -
ending string.deepToString()
)
are separated by the string sep
.sep -
separator string.
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
that -
the secondtrue
iff both arrays are deeply equal.
Scala Library Documentation
|
|