scala.collection.mutable

trait BufferLike

[source: scala/collection/mutable/BufferLike.scala]

@cloneable

trait BufferLike[A, +This <: BufferLike[A, This] with Buffer[A]]
extends Growable[A] with Shrinkable[A] with Scriptable[A] with Addable[A, This] with Subtractable[A, This] with Cloneable[This] with SeqLike[A, This]
Buffers are used to create sequences of elements incrementally by appending, prepending, or inserting new elements. It is also possible to access and modify elements in a random access fashion via the index of the element in the current sequence.
Author
Matthias Zenger
Martin Odersky
Version
2.8
Since
2.8
Direct Known Subclasses:
ArrayBuffer, Buffer, ListBuffer

Method Summary
override def + (elem1 : A, elem2 : A, elems : A*) : This
Adds two or more elements to this collection and returns the collection itself.
override def + (elem : A) : This
Adds a single element to this collection and returns the collection itself.
override def ++ (iter : Traversable[A]) : This
Adds a number of elements provided by a traversable object and returns either the collection itself.
override def ++ (iter : Iterator[A]) : This
Adds a number of elements provided by an iterator and returns the collection itself.
final def ++: (iter : Traversable[A]) : This
final def ++: (iter : Iterator[A]) : This
def ++= (src : Array[A], start : Int, len : Int) : Unit
Adds a number of elements in an array
def ++=: (iter : Traversable[A]) : This
Prepends a number of elements provided by an iterable object via its iterator method. The identity of the buffer is returned.(repr /: elems) (_ plus _)
def ++=: (iter : Iterator[A]) : This
Prepends a number of elements provided by an iterator The identity of the buffer is returned.
final def +: (elem : A) : This
abstract def += (elem : A) : This
Append a single element to this buffer.
abstract def +=: (elem : A) : This
Prepend a single element to this buffer and return the identity of the buffer.
override def - (elem : A) : This
Removes a single element from this collection and returns the collection itself.
override def - (elem1 : A, elem2 : A, elems : A*) : This
Removes two or more elements from this collection and returns the collection itself.
override def -- (iter : Iterator[A]) : This
Removes a number of elements provided by an iterator and returns the collection itself.
override def -- (iter : Traversable[A]) : This
Removes a number of elements provided by a Traversable object and returns the collection itself.
def -= (x : A) : This
Removes a single element from this buffer, at its first occurrence. If the buffer does not contain that element, it is unchanged.
def << (cmd : Message[A]) : Unit
Send a message to this scriptable object.
def append (elems : A*) : Unit
Appends elements to this buffer.
def appendAll (iter : Traversable[A]) : Unit
Appends a number of elements provided by an iterable object via its iterator method.
abstract def apply (n : Int) : A
Return element at index `n`
abstract def clear : Unit
Clears the buffer contents.
def insert (n : Int, elems : 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 the new elements at index n.
abstract def insertAll (n : Int, iter : Traversable[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.
abstract def length : Int
Return number of elements in the buffer
def prepend (elems : A*) : Unit
Prepend given elements to this list.
def prependAll (iter : Iterator[A]) : Unit
Prepends a number of elements provided by an iterable object via its iterator method. The identity of the buffer is returned.
def prependAll (iter : Traversable[A]) : Unit
Prepends a number of elements provided by an iterable object via its iterator method. The identity of the buffer is returned.
def readOnly : Seq[A]
def remove (n : Int, count : Int) : Unit
Removes a number of elements from a given index position.
abstract def remove (n : Int) : A
Removes the element on a given index position.
override def stringPrefix : java.lang.String
Defines the prefix of the string representation.
def trimEnd (n : Int) : Unit
Removes the last n elements.
def trimStart (n : Int) : Unit
Removes the first n elements.
abstract def update (n : Int, newelem : A) : Unit
Replace element at index n with the new element newelem.
Methods inherited from SeqLike
thisCollection, toCollection, lengthCompare, size, isDefinedAt, segmentLength, prefixLength, indexWhere, indexWhere, findIndexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexWhere, lastIndexWhere, reverse, reverseMap, reverseIterator, reversedElements, startsWith, startsWith, endsWith, indexOfSeq, indexOfSeq, lastIndexOfSeq, lastIndexOfSeq, contains, union, diff, intersect, removeDuplicates, patch, updated, +:, :+, padTo, sortWith, sortWith, sortBy, toSeq, indices, view, view, hashCode, equals, toString, findLastIndexOf, equalsWith, containsSlice, projection
Methods inherited from IterableLike
iterator (abstract), elements, foreach, forall, exists, find, isEmpty, foldRight, reduceRight, toIterable, head, take, slice, takeWhile, takeRight, dropRight, copyToArray, zip, zipAll, zipWithIndex, sameElements, toStream, canEqual, first, firstOption
Methods inherited from TraversableLike
newBuilder (abstract), repr, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterNot, partialMap, remove, partition, groupBy, count, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, sum, product, min, max, headOption, tail, last, lastOption, init, drop, dropWhile, span, splitAt, copyToBuffer, copyToArray, toArray, toList, toIndexedSeq, toSet, mkString, mkString, mkString, addString, addString, addString, withFilter
Methods inherited from Cloneable
clone
Methods inherited from Shrinkable
-=, --=, --=
Methods inherited from Growable
+=, ++=, ++=
Methods inherited from AnyRef
getClass, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
abstract def apply(n : Int) : A
Return element at index `n`
Throws
IndexOutofBoundsException - if the index is not valid
Overrides
SeqLike.apply

abstract def update(n : Int, newelem : A) : Unit
Replace element at index n with the new element newelem.
Parameters
n - the index of the element to replace.
newelem - the new element.
Throws
IndexOutofBoundsException - if the index is not valid

abstract def length : Int
Return number of elements in the buffer
Overrides
SeqLike.length

abstract def +=(elem : A) : This
Append a single element to this buffer.
Parameters
elem - the element to append.
Overrides
Growable.+=

abstract def clear : Unit
Clears the buffer contents.
Overrides
Growable.clear

abstract def +=:(elem : A) : This
Prepend a single element to this buffer and return the identity of the buffer.
Parameters
elem - the element to prepend.

@deprecated("use `+=:' instead")

final def +:(elem : A) : This

abstract def insertAll(n : Int, iter : Traversable[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.
Parameters
n - the index where a new element will be inserted.
iter - the iterable object providing all elements to insert.
Throws
IndexOutofBoundsException - if the index is not valid

abstract def remove(n : Int) : A
Removes the element on a given index position.
Parameters
n - the index which refers to the element to delete.
Returns
the previous element

def remove(n : Int, count : Int) : Unit
Removes a number of elements from a given index position.
Parameters
n - the index which refers to the element to delete.
count - the number of elements to delete
Throws
IndexOutofBoundsException - if the index is not valid

def -=(x : A) : This
Removes a single element from this buffer, at its first occurrence. If the buffer does not contain that element, it is unchanged.
Parameters
x - the element to remove.
Overrides
Shrinkable.-=

def ++=:(iter : Traversable[A]) : This
Prepends a number of elements provided by an iterable object via its iterator method. The identity of the buffer is returned.(repr /: elems) (_ plus _)
Parameters
iter - the iterable object.

@deprecated("use ++=: instead")

final def ++:(iter : Traversable[A]) : This

def ++=:(iter : Iterator[A]) : This
Prepends a number of elements provided by an iterator The identity of the buffer is returned.
Parameters
iter - the iterator
Returns
the updated buffer.

@deprecated("use ++=: instead")

final def ++:(iter : Iterator[A]) : This

def append(elems : A*) : Unit
Appends elements to this buffer.
Parameters
elems - the elements to append.

def appendAll(iter : Traversable[A]) : Unit
Appends a number of elements provided by an iterable object via its iterator method.
Parameters
iter - the iterable object.

def prepend(elems : A*) : Unit
Prepend given elements to this list.
Parameters
elem - the element to prepend.

def prependAll(iter : Traversable[A]) : Unit
Prepends a number of elements provided by an iterable object via its iterator method. The identity of the buffer is returned.
Parameters
iter - the iterable object.

def prependAll(iter : Iterator[A]) : Unit
Prepends a number of elements provided by an iterable object via its iterator method. The identity of the buffer is returned.
Parameters
iter - the iterable object.

def insert(n : Int, elems : 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 the new elements at index n.
Parameters
n - the index where a new element will be inserted.
elems - the new elements to insert.

def trimStart(n : Int) : Unit
Removes the first n elements.
Parameters
n - the number of elements to remove from the beginning of this buffer.

def trimEnd(n : Int) : Unit
Removes the last n elements.
Parameters
n - the number of elements to remove from the end of this buffer.

def <<(cmd : Message[A]) : Unit
Send a message to this scriptable object.
Parameters
cmd - the message to send.
Overrides
Scriptable.<<

override def stringPrefix : java.lang.String
Defines the prefix of the string representation.

@deprecated("replace by: <code>buf ++= src.view(start, end)</code>")

def ++=(src : Array[A], start : Int, len : Int) : Unit
Adds a number of elements in an array
Parameters
src - the array
start - the first element to append
len - the number of elements to append

@deprecated("Use += instead if you intend to add by side effect to an existing collection.\012".+("Use `clone() ++=' if you intend to create a new collection."))

override def +(elem : A) : This
Adds a single element to this collection and returns the collection itself.
Parameters
elem - the element to add.
Overrides
Addable.+

@deprecated("Use += instead if you intend to add by side effect to an existing collection.\012".+("Use `clone() ++=' if you intend to create a new collection."))

override def +(elem1 : A, elem2 : A, elems : A*) : This
Adds two or more elements to this collection and returns the collection itself.
Parameters
elem1 - the first element to add.
elem2 - the second element to add.
elems - the remaining elements to add.
Overrides
Addable.+

@deprecated("Use ++= instead if you intend to add by side effect to an existing collection.\012".+("Use `clone() ++=` if you intend to create a new collection."))

override def ++(iter : Traversable[A]) : This
Adds a number of elements provided by a traversable object and returns either the collection itself.
Parameters
iter - the iterable object.
Overrides
Addable.++

@deprecated("Use ++= instead if you intend to add by side effect to an existing collection.\012".+("Use `clone() ++=` if you intend to create a new collection."))

override def ++(iter : Iterator[A]) : This
Adds a number of elements provided by an iterator and returns the collection itself.
Parameters
iter - the iterator
Overrides
Addable.++

@deprecated("Use -= instead if you intend to remove by side effect from an existing collection.\012".+("Use `clone() -=` if you intend to create a new collection."))

override def -(elem : A) : This
Removes a single element from this collection and returns the collection itself.
Parameters
elem - the element to remove.
Overrides
Subtractable.-

@deprecated("Use -= instead if you intend to remove by side effect from an existing collection.\012".+("Use `clone() -=` if you intend to create a new collection."))

override def -(elem1 : A, elem2 : A, elems : A*) : This
Removes two or more elements from this collection and returns the collection itself.
Parameters
elem1 - the first element to remove.
elem2 - the second element to remove.
elems - the remaining elements to remove.
Overrides
Subtractable.-

@deprecated("Use --= instead if you intend to remove by side effect from an existing collection.\012".+("Use `clone() --=` if you intend to create a new collection."))

override def --(iter : Traversable[A]) : This
Removes a number of elements provided by a Traversable object and returns the collection itself.
Parameters
iter - the Traversable object.
Overrides
Subtractable.--

@deprecated("Use --= instead if you intend to remove by side effect from an existing collection.\012".+("Use `clone() --=` if you intend to create a new collection."))

override def --(iter : Iterator[A]) : This
Removes a number of elements provided by an iterator and returns the collection itself.
Parameters
iter - the iterator
Overrides
Subtractable.--

def readOnly : Seq[A]