diff options
author | Jesse Hall <jessehall@google.com> | 2013-03-11 10:16:48 -0700 |
---|---|---|
committer | Alex Ray <aray@google.com> | 2013-07-30 13:57:01 -0700 |
commit | b73559d86c9017166da28e1d59a884f13417426d (patch) | |
tree | 309b276f7c3d2f3488a7d083699adedfe0581127 /libs | |
parent | a729ab1e3be17ed20073f7c035df0433888164d6 (diff) | |
download | core-b73559d86c9017166da28e1d59a884f13417426d.tar.gz core-b73559d86c9017166da28e1d59a884f13417426d.tar.bz2 core-b73559d86c9017166da28e1d59a884f13417426d.zip |
Add Vector::resize()
Bug: 8384764
Change-Id: Icee83d389f3e555eba7d419b64c8d52a9aa21b8b
Diffstat (limited to 'libs')
-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 c3257bb3e..70f49deee 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) { |