scala.collection.jcl

trait Buffer

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

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

Type Summary
protected final type SortedSelf
Method Summary
override def + (a : A) : Buffer[A]
adds "a" from the collection. Useful for chaining.
override def -= (a : A) : Unit
removes "a" from the collection.
def add (a : A) : Boolean
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.
final def compare (k0 : Int, k1 : Int) : Int
Indices are compared through subtraction.
override def elements : BufferIterator[Int, A]
The default implementation of a map over mutable iterable collections.
override def firstKey : Int
The first index of a buffer is 0.
override def isEmpty : Boolean
Returns true if length == 0
override def lastKey : Int
The last index of a buffer is its size - 1.
override def projection : Projection[A]
returns a projection 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, length : Int) : Unit
Removes N elements from index idx
def remove (idx : Int) : A
Removes the element at index idx
def replace (from : Int, length : Int, added : Seq[A]) : Unit
replaces
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 Collection
hasAll, addAll, ++, +=
Methods inherited from MutableSeq
apply, indexOf, length
Methods inherited from Ranged
from, until, range
Methods inherited from MutableIterable
has, remove, removeAll, --, -, retainOnly, retainAll, size0, clear
Methods inherited from Mutable
readOnly, drop, take, slice, reverse
Methods inherited from RandomAccessSeq
partition, patch, ++, toStream, safeIs
Methods inherited from Seq
lengthCompare, size, 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, 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
Class Summary
protected class DefaultBufferIterator extends DefaultSeqIterator with BufferIterator[Int, A]
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[A]
returns a projection that can be used to call non-strict filter, map, and flatMap methods that build projections of the collection.
Overrides
Mutable.projection, MutableSeq.projection, Collection.projection

override def elements : BufferIterator[Int, A]
The default implementation of a map over mutable iterable collections.
Overrides
MutableSeq.elements

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

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

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 remove(idx : Int, length : Int) : Unit
Removes N elements from index idx

def replace(from : Int, length : Int, added : Seq[A]) : Unit
replaces

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.
Overrides
Mutable.update

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[A]
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