diff options
author | Jesse Hall <jessehall@google.com> | 2013-03-17 16:27:56 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-03-17 16:27:56 +0000 |
commit | 647a92aa69b7aa4ddf561e35e9f0780fcb799c38 (patch) | |
tree | ba9b789ad8532d0b0f24e8e5282f2fc8be731e60 /libs/utils | |
parent | 92509c779ef910288d2a4ba3256fb6f87acd1296 (diff) | |
parent | df608eb15d3b90d2e71e07baaa6de423c29769c8 (diff) | |
download | frameworks_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.cpp | 10 |
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) { |