scala.collection.jcl

trait Buffer

[source: scala/collection/jcl/Buffer.scala]

trait Buffer[A]
extends MutableSeq[A] with Collection[A] with Ranged[Int, A]
A mutable sequence that supports element insertion and update.
Author
Sean McDirmid
Direct Known Subclasses:
Buffer.Range, BufferWrapper

Type Summary
protected final type SortedSelf
Method Summary
override def + (a : A) : Buffer
adds "a" from the collection. Useful for chaining.
override def -= (a : A) : Unit
removes "a" from the collection.
def add (idx : Int, a : A) : Unit
Inserts "a" into this buffer just before the element at index "idx."
def add (a : A) : Boolean
def addAll (idx : Int, that : Iterable[A]) : Unit
Inserts all elements of that into this buffer just before the element at index idx.
final def compare (k0 : Int, k1 : Int) : Int
Indices are compared through subtraction.
override abstract def elements : BufferIterator[Int, A]
Creates a new iterator over all elements contained in this object.
override def first : Int
The first index of a buffer is 0.
override def isEmpty : Boolean
Returns true if length == 0
override def last : Int
The last index of a buffer is its size - 1.
override def projection : Projection
returns a facade that can be used to call non-strict filter, map, and flatMap methods that build projections of the collection.
override def rangeImpl (from : Option[Int], until : Option[Int]) : Buffer[A]
Creates a ranged projection of this collection. Any mutations in the ranged projection will update this collection and vice versa. Note: keys are not garuanteed to be consistent between this collection and the projection. This is the case for buffers where indexing is relative to the projection.
def remove (idx : Int) : A
Removes the element at index "idx"
def set (idx : Int, a : A) : A
Replaces the element at index "idx" with "a."
override def transform (f : (A) => A) : Boolean
Transforms each element of the collection in-place according to f.
def update (idx : Int, a : A) : Unit
Equivalent to set except the replaced element is not returned.
Methods inherited from Ranged
from, until, range
Methods inherited from Collection
hasAll, addAll, ++, +=
Methods inherited from MutableSeq
apply, indexOf, length
Methods inherited from Seq
size, concat, ++, isDefinedAt, lastIndexOf, map, flatMap, filter, take, drop, takeWhile, dropWhile, reverse, contains, slice, subseq, toArray
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
toString, compose
Methods inherited from MutableIterable
has, remove, removeAll, --, -, retain, retainAll, size0, clear
Methods inherited from Collection
stringPrefix
Methods inherited from Iterable
foreach, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, mkString, mkString, addString, addString, copyToArray, hasDefiniteSize
Methods inherited from AnyRef
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Class Summary
trait MutableSeqProjection extends Projection
trait Projection extends MutableSeqProjection with Projection
protected class Range (val from : Option[Int], val until : Option[Int]) extends Buffer[A]
Type Details
protected final type SortedSelf

Method Details
override def projection : Projection
returns a facade that can be used to call non-strict filter, map, and flatMap methods that build projections of the collection.
Overrides
MutableSeq.projection, Collection.projection

override abstract def elements : BufferIterator[Int, A]
Creates a new iterator over all elements contained in this object.
Returns
the new iterator
Overrides
MutableSeq.elements

override def first : Int
The first index of a buffer is 0.
Overrides
Ranged.first

override def last : Int
The last index of a buffer is its size - 1.
Overrides
Ranged.last

final def compare(k0 : Int, k1 : Int) : Int
Indices are compared through subtraction.
Overrides
Ranged.compare

def remove(idx : Int) : A
Removes the element at index "idx"

def set(idx : Int, a : A) : A
Replaces the element at index "idx" with "a."
Returns
s the element replaced.

def update(idx : Int, a : A) : Unit
Equivalent to set except the replaced element is not returned.

def add(a : A) : Boolean
Returns
s always true.
Overrides
Collection.add

def add(idx : Int, a : A) : Unit
Inserts "a" into this buffer just before the element at index "idx."

def addAll(idx : Int, that : Iterable[A]) : Unit
Inserts all elements of that into this buffer just before the element at index idx.
Parameters
idx - ..
that - ..

override def transform(f : (A) => A) : Boolean
Transforms each element of the collection in-place according to f.
Parameters
f -
Returns
true if the collection is actually updated.
Overrides
Collection.transform

override def +(a : A) : Buffer
adds "a" from the collection. Useful for chaining.
Overrides
Collection.+

override def -=(a : A) : Unit
removes "a" from the collection.
Overrides
Collection.-=

override def isEmpty : Boolean
Returns true if length == 0
Overrides
MutableSeq.isEmpty

override def rangeImpl(from : Option[Int], until : Option[Int]) : Buffer[A]
Creates a ranged projection of this collection. Any mutations in the ranged projection will update this collection and vice versa. Note: keys are not garuanteed to be consistent between this collection and the projection. This is the case for buffers where indexing is relative to the projection.
Parameters
from - The lower-bound (inclusive) of the ranged projection. None if there is no lower bound.
until - The upper-bound (exclusive) of the ranged projection. None if there is no upper bound.
Overrides
Ranged.rangeImpl