Skip to content

Commit

Permalink
Return the vector itself for trim and resize method in PrimitiveVector.
Browse files Browse the repository at this point in the history
  • Loading branch information
rxin committed Nov 18, 2013
1 parent c30979c commit 16a2286
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ class PrimitiveVector[@specialized(Long, Int, Double) V: ClassManifest](initialS

def size: Int = _numElements

/** Get the underlying array backing this vector. */
/** Gets the underlying array backing this vector. */
def array: Array[V] = _array

/** Trims this vector so that the capacity is equal to the size. */
def trim(): Unit = resize(size)
def trim(): PrimitiveVector[V] = resize(size)

/** Resizes the array, dropping elements if the total length decreases. */
def resize(newLength: Int) {
def resize(newLength: Int): PrimitiveVector[V] = {
val newArray = new Array[V](newLength)
_array.copyToArray(newArray)
_array = newArray
this
}
}

0 comments on commit 16a2286

Please sign in to comment.