Scala Library
|
|
class
ArrayBuffer[A]
extends
Mutable[A] with
Buffer[A] with
ResizableArray[A]Buffer
class using an array to
represent the assembled sequence internally. Append, update and random
access take constant time (amortized time). Prepends and removes are
linear in the buffer size.Values and Variables inherited from ResizableArray | |
array |
Method Summary | |
override def
|
++
[B >: A](that : Iterable[B]) : ArrayBuffer[B]
Appends two iterable objects.
|
override def
|
++:
(iter : Iterable[A]) : Buffer[A]
Prepends a number of elements provided by an iterable object
via its
elements method. The identity of the
buffer is returned. |
override def
|
++=
(iter : Iterable[A]) : Unit
Appends a number of elements provided by an iterable object
via its
elements method. The identity of the
buffer is returned. |
override def
|
++=
(src : Array[A], start : Int, len : Int) : Unit
Appends a number of elements in an array
|
def
|
+:
(elem : A) : Buffer[A]
Prepends a single element to this buffer and return
the identity of the buffer. It takes time linear in
the buffer size.
|
def
|
+=
(elem : A) : Unit
Appends a single element to this buffer and returns
the identity of the buffer. It takes constant time.
|
override def
|
apply
(i : Int) : A
Returns the i-th element of this ArrayBuffer. It takes constant time.
|
def
|
clear
: Unit
Clears the buffer contents.
|
override def
|
clone
: Buffer[A]
Return a clone of this buffer.
|
override def
|
equals
(obj : Any) : Boolean
Checks if two buffers are structurally identical.
|
def
|
insertAll
(n : Int, iter : Iterable[A]) : Unit
Inserts new elements at the index
n . Opposed to method
update , this method will not replace an element with a
one. Instead, it will insert a new element at index n . |
def
|
remove
(n : Int) : A
Removes the element on a given index position. It takes time linear in
the buffer size.
|
protected override def
|
stringPrefix
: java.lang.String
Defines the prefix of the string representation.
|
def
|
update
(n : Int, newelem : A) : Unit
Replace element at index
n with the new element
newelem . It takes constant time. |
Methods inherited from ResizableArray | |
initialSize, size0, size0_=, length, reduceToSize, copyToArray, copyToBuffer, elements, ensureSize, swap, copy |
Methods inherited from Buffer | |
+, ++=, ++, ++, -=, append, appendAll, prepend, prependAll, insert, trimStart, trimEnd, <<, hashCode |
Methods inherited from Mutable | |
projection, readOnly, drop, take, slice, reverse |
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, map, flatMap, filter, slice, takeWhile, dropWhile, contains, subseq, toArray, toSeq, equalsWith, startsWith, startsWith, endsWith, indexOf, containsSlice |
Methods inherited from Collection | |
toString |
Methods inherited from Iterable | |
foreach, forall, exists, find, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, sameElements, toList, mkString, mkString, mkString, addString, addString, addString, hasDefiniteSize |
Methods inherited from PartialFunction | |
orElse, andThen |
Methods inherited from Function1 | |
compose |
Methods inherited from AnyRef | |
getClass, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
Methods inherited from Any | |
==, !=, isInstanceOf, asInstanceOf |
Method Details |
elem -
the element to append.elements
method. The identity of the
buffer is returned.iter -
the iterable object.override
def
++[B >: A](that : Iterable[B]) : ArrayBuffer[B]
src -
the arraystart -
the first element to appendlen -
the number of elements to appendelem -
the element to append.i -
the specified index.Predef.IndexOutOfBoundException -
if i
is out of bounds.elements
method. The identity of the
buffer is returned.iter -
the iterable object.n
. Opposed to method
update
, this method will not replace an element with a
one. Instead, it will insert a new element at index n
.n -
the index where a new element will be inserted.iter -
the iterable object providing all elements to insert.n
is out of bounds.n
with the new element
newelem
. It takes constant time.n -
the index of the element to replace.newelem -
the new element.n
is out of bounds.n -
the index which refers to the element to delete.n
is out of bounds.
def
clear : Unit
ArrayBuffer
with the same elements.protected override
def
stringPrefix : java.lang.String
Scala Library
|
|