scala.collection.mutable

trait ResizableArray

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

trait ResizableArray[A]
extends IndexedSeq[A] with GenericTraversableTemplate[A, ResizableArray] with IndexedSeqLike[A, ResizableArray[A]]
This class is used internally to implement data structures that are based on resizable arrays.
Author
Matthias Zenger, Burak Emir
Martin Odersky
Version
2.8
Since
1
Direct Known Subclasses:
ArrayBuffer, PriorityQueue

Value Summary
protected var array : Array[AnyRef]
protected var size0 : Int
Method Summary
def apply (idx : Int) : A
Returns the elements at position `idx`
override def companion : GenericCompanion[ResizableArray]
The factory companion object that builds instances of class CC
protected def copy (m : Int, n : Int, len : Int) : Unit
Move parts of the array.
override def copyToArray [B >: A](xs : Array[B], start : Int, len : Int) : Unit
Fills the given array xs with at most `len` elements of this traversable starting at position `start`. Copying will stop once either the end of the current traversable is reached or `len` elements have been copied or the end of the array is reached.
protected def ensureSize (n : Int) : Unit
ensure that the internal array has at n cells
override def foreach [U](f : (A) => U) : Unit
Apply a function f to all elements of this iterable object.
protected def initialSize : Int
def length : Int
Returns the length of this resizable array.
def reduceToSize (sz : Int) : Unit
remove elements of this array at indices after sz
protected def swap (a : Int, b : Int) : Unit
Swap two elements of this array.
def update (idx : Int, elem : A) : Unit
Methods inherited from IndexedSeqLike
thisCollection, toCollection, view, view
Methods inherited from IndexedSeqLike
iterator, isEmpty, forall, exists, find, foldLeft, foldRight, reduceLeft, reduceRight, zip, zipWithIndex, slice, head, tail, last, init, take, drop, takeRight, dropRight, splitAt, takeWhile, dropWhile, span, sameElements, lengthCompare, segmentLength, indexWhere, lastIndexWhere, reverse, reverseIterator, startsWith, endsWith
Methods inherited from SeqLike
size, isDefinedAt, prefixLength, indexWhere, findIndexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexWhere, reverseMap, reversedElements, startsWith, indexOfSeq, indexOfSeq, lastIndexOfSeq, lastIndexOfSeq, contains, union, diff, intersect, removeDuplicates, patch, updated, +:, :+, padTo, sortWith, sortWith, sortBy, toSeq, indices, hashCode, equals, toString, findLastIndexOf, equalsWith, containsSlice, projection
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
compose
Methods inherited from IterableLike
elements, toIterable, zipAll, toStream, canEqual, first, firstOption
Methods inherited from GenericTraversableTemplate
newBuilder, genericBuilder, unzip, flatten, transpose
Methods inherited from TraversableLike
repr, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterNot, partialMap, remove, partition, groupBy, count, /:, :\, reduceLeftOption, reduceRightOption, sum, product, min, max, headOption, lastOption, copyToBuffer, copyToArray, toArray, toList, toIndexedSeq, toSet, mkString, mkString, mkString, addString, addString, addString, stringPrefix, withFilter
Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
protected var array : Array[AnyRef]

protected var size0 : Int

Method Details
override def companion : GenericCompanion[ResizableArray]
The factory companion object that builds instances of class CC
Overrides
IndexedSeq.companion, GenericTraversableTemplate.companion

protected def initialSize : Int

def length : Int
Returns the length of this resizable array.

def apply(idx : Int) : A
Returns the elements at position `idx`

def update(idx : Int, elem : A) : Unit
Overrides
IndexedSeqLike.update

override def foreach[U](f : (A) => U) : Unit
Apply a function f to all elements of this iterable object.
Parameters
f - A function that is applied for its side-effect to every element. The result (of arbitrary type U) of function `f` is discarded.
Notes
This method underlies the implementation of most other bulk operations. Implementing `foreach` with `iterator` is often suboptimal. So `foreach` should be overridden in concrete collection classes if a more efficient implementation is available.
Overrides
GenericTraversableTemplate.foreach

override def copyToArray[B >: A](xs : Array[B], start : Int, len : Int) : Unit
Fills the given array xs with at most `len` elements of this traversable starting at position `start`. Copying will stop once either the end of the current traversable is reached or `len` elements have been copied or the end of the array is reached.
Parameters
xs - the array to fill.
start - starting index.
len - number of elements to copy

def reduceToSize(sz : Int) : Unit
remove elements of this array at indices after sz

protected def ensureSize(n : Int) : Unit
ensure that the internal array has at n cells

protected def swap(a : Int, b : Int) : Unit
Swap two elements of this array.

protected def copy(m : Int, n : Int, len : Int) : Unit
Move parts of the array.