aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorReynold Xin <rxin@apache.org>2013-11-17 17:52:02 -0800
committerReynold Xin <rxin@apache.org>2013-11-17 17:52:02 -0800
commit16a2286d6d0e692e0d2e2d568a3c72c053f5047a (patch)
treee928d2b70cc35ab0c0bd96c6cfd733fdfbe53c69 /core
parentc30979c7d6009936853e731bfde38ec9d04ea347 (diff)
downloadspark-16a2286d6d0e692e0d2e2d568a3c72c053f5047a.tar.gz
spark-16a2286d6d0e692e0d2e2d568a3c72c053f5047a.tar.bz2
spark-16a2286d6d0e692e0d2e2d568a3c72c053f5047a.zip
Return the vector itself for trim and resize method in PrimitiveVector.
Diffstat (limited to 'core')
-rw-r--r--core/src/main/scala/org/apache/spark/util/collection/PrimitiveVector.scala7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/src/main/scala/org/apache/spark/util/collection/PrimitiveVector.scala b/core/src/main/scala/org/apache/spark/util/collection/PrimitiveVector.scala
index 54a5569b3d..b4fcc9229b 100644
--- a/core/src/main/scala/org/apache/spark/util/collection/PrimitiveVector.scala
+++ b/core/src/main/scala/org/apache/spark/util/collection/PrimitiveVector.scala
@@ -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
}
}