summaryrefslogtreecommitdiffstats
path: root/libs/utils
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2013-03-17 16:27:56 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2013-03-17 16:27:56 +0000
commit647a92aa69b7aa4ddf561e35e9f0780fcb799c38 (patch)
treeba9b789ad8532d0b0f24e8e5282f2fc8be731e60 /libs/utils
parent92509c779ef910288d2a4ba3256fb6f87acd1296 (diff)
parentdf608eb15d3b90d2e71e07baaa6de423c29769c8 (diff)
downloadframeworks_native-647a92aa69b7aa4ddf561e35e9f0780fcb799c38.zip
frameworks_native-647a92aa69b7aa4ddf561e35e9f0780fcb799c38.tar.gz
frameworks_native-647a92aa69b7aa4ddf561e35e9f0780fcb799c38.tar.bz2
am df608eb1: am ce7e2781: Merge "Add Vector::resize()" into jb-mr2-dev
* commit 'df608eb15d3b90d2e71e07baaa6de423c29769c8': Add Vector::resize()
Diffstat (limited to 'libs/utils')
-rw-r--r--libs/utils/VectorImpl.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/libs/utils/VectorImpl.cpp b/libs/utils/VectorImpl.cpp
index c3257bb..70f49de 100644
--- a/libs/utils/VectorImpl.cpp
+++ b/libs/utils/VectorImpl.cpp
@@ -343,6 +343,16 @@ ssize_t VectorImpl::setCapacity(size_t new_capacity)
return new_capacity;
}
+ssize_t VectorImpl::resize(size_t size) {
+ ssize_t result = NO_ERROR;
+ if (size > mCount) {
+ result = insertAt(mCount, size - mCount);
+ } else if (size < mCount) {
+ result = removeItemsAt(size, mCount - size);
+ }
+ return result < 0 ? result : size;
+}
+
void VectorImpl::release_storage()
{
if (mStorage) {