Scala Library
|
|
final
class
ListBuffer[A]
extends
Buffer[A] with
GenericTraversableTemplate[A, ListBuffer] with
BufferLike[A, ListBuffer[A]] with
Builder[A, List[A]] with
SeqForwarder[A]Method Summary | |
def
|
+=
(x : A) : ListBuffer[A]
Appends a single element to this buffer. This operation takes constant time.
|
def
|
+=:
(x : A) : ListBuffer[A]
Prepends a single element to this buffer. This operation takes constant
time.
|
override def
|
-=
(elem : A) : ListBuffer[A]
Remove a single element from this buffer. May take time linear in the
buffer size.
|
override def
|
apply
(n : Int) : A
Return element at index `n`
|
def
|
clear
: Unit
Clears the buffer contents.
|
override def
|
clone
: ListBuffer[A]
Returns a clone of this buffer.
|
override def
|
companion
: GenericCompanion[ListBuffer]
The factory companion object that builds instances of class CC
|
override def
|
equals
(that : Any) : Boolean
The equality method defined in `AnyRef`.
|
def
|
insertAll
(n : Int, seq : Traversable[A]) : Unit
Inserts new elements at the index
n . Opposed to method
update , this method will not replace an element with a new
one. Instead, it will insert a new element at index n . |
override def
|
iterator
: Iterator[A]
Creates a new iterator over all elements contained in this
iterable object.
|
override def
|
length
: Int
The current length of the buffer
|
def
|
prependToList
(xs : List[A]) : List[A]
Prepends the elements of this buffer to a given list
|
override def
|
readOnly
: List[A]
expose the underlying list but do not mark it as exported
|
override def
|
remove
(n : Int, count : Int) : Unit
Removes a given number of elements on a given index position. May take
time linear in the buffer size.
|
def
|
remove
(n : Int) : A
Removes the element on a given index position. May take time linear in
the buffer size
|
def
|
result
: List[A]
Returns collection resulting from this builder. The buffer's contents
are undefined afterwards.
|
override def
|
stringPrefix
: java.lang.String
Defines the prefix of the string representation.
|
override def
|
toList
: List[A]
Converts this buffer to a list. Takes constant time. The buffer is
copied lazily, the first time it is mutated.
|
protected def
|
underlying
: Seq[A]
The iterable object to which calls are forwarded
|
def
|
update
(n : Int, x : A) : Unit
Replaces element at index
n with the new element
newelem . Takes time linear in the buffer size. (except the
first element, which is updated in constant time). |
Methods inherited from SeqForwarder | |
isDefinedAt, lengthCompare, segmentLength, prefixLength, indexWhere, indexOf, reverseIterator, startsWith, endsWith, indexOfSeq, contains, indices |
Methods inherited from IterableForwarder | |
sameElements |
Methods inherited from TraversableForwarder | |
isEmpty, nonEmpty, hasDefiniteSize, foreach, forall, exists, count, find, foldLeft, foldRight, reduceLeft, reduceRight, reduceLeftOption, reduceRightOption, copyToBuffer, copyToArray, toArray, toSeq, toStream, mkString, addString, head, last, lastOption |
Methods inherited from Builder | |
sizeHint, mapResult |
Methods inherited from BufferLike | |
+:, ++=:, ++:, ++=:, ++:, append, appendAll, prepend, prependAll, prependAll, insert, trimStart, trimEnd, <<, ++=, +, +, ++, ++, -, -, --, -- |
Methods inherited from Shrinkable | |
-=, --=, --= |
Methods inherited from Growable | |
+=, ++=, ++= |
Methods inherited from SeqLike | |
thisCollection, toCollection, size, indexWhere, findIndexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexWhere, lastIndexWhere, reverse, reverseMap, reversedElements, startsWith, indexOfSeq, lastIndexOfSeq, lastIndexOfSeq, union, diff, intersect, removeDuplicates, patch, updated, +:, :+, padTo, sortWith, sortWith, sortBy, view, view, hashCode, toString, findLastIndexOf, equalsWith, containsSlice, projection |
Methods inherited from PartialFunction | |
orElse, andThen |
Methods inherited from Function1 | |
compose |
Methods inherited from IterableLike | |
elements, toIterable, take, slice, takeWhile, takeRight, dropRight, zip, zipAll, zipWithIndex, canEqual, first, firstOption |
Methods inherited from GenericTraversableTemplate | |
newBuilder, genericBuilder, unzip, flatten, transpose |
Methods inherited from TraversableLike | |
repr, ++, ++, map, flatMap, filter, filterNot, partialMap, remove, partition, groupBy, /:, :\, sum, product, min, max, headOption, tail, init, drop, dropWhile, span, splitAt, copyToArray, toIndexedSeq, toSet, mkString, mkString, addString, addString, withFilter |
Methods inherited from AnyRef | |
getClass, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
Methods inherited from Any | |
==, !=, isInstanceOf, asInstanceOf |
Method Details |
override
def
companion : GenericCompanion[ListBuffer]
override
def
length : Int
IndexOutofBoundsException -
if the index is not validn
with the new element
newelem
. Takes time linear in the buffer size. (except the
first element, which is updated in constant time).n -
the index of the element to replace.x -
the new element.n
is out of bounds.
def
+=(x : A) : ListBuffer[A]
x -
the element to append.
def
clear : Unit
def
+=:(x : A) : ListBuffer[A]
x -
the element to prepend.
def
insertAll(n : Int, seq : Traversable[A]) : Unit
n
. Opposed to method
update
, this method will not replace an element with a new
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 -
the index which refers to the first element to remove.count -
the number of elements to remove.xs -
the list to which elements are prependedn -
the index which refers to the element to delete.n
.n
n
is out of bounds.override
def
-=(elem : A) : ListBuffer[A]
x -
the element to remove.override
def
clone : ListBuffer[A]
ListBuffer
with the same elements.override
def
stringPrefix : java.lang.String
Scala Library
|
|