Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df608eb1 authored by Jesse Hall's avatar Jesse Hall Committed by Android Git Automerger
Browse files

am ce7e2781: Merge "Add Vector::resize()" into jb-mr2-dev

* commit 'ce7e2781':
  Add Vector::resize()
parents df6c6e97 ce7e2781
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -80,6 +80,12 @@ public:
    //! sets the capacity. capacity can never be reduced less than size()
    //! sets the capacity. capacity can never be reduced less than size()
    inline  ssize_t         setCapacity(size_t size)    { return VectorImpl::setCapacity(size); }
    inline  ssize_t         setCapacity(size_t size)    { return VectorImpl::setCapacity(size); }


    /*!
     * set the size of the vector. items are appended with the default
     * constructor, or removed from the end as needed.
     */
    inline  ssize_t         resize(size_t size)         { return VectorImpl::resize(size); }

    /*!
    /*!
     * C-style array access
     * C-style array access
     */
     */
+1 −0
Original line number Original line Diff line number Diff line
@@ -64,6 +64,7 @@ public:
    inline  bool            isEmpty() const     { return mCount == 0; }
    inline  bool            isEmpty() const     { return mCount == 0; }
            size_t          capacity() const;
            size_t          capacity() const;
            ssize_t         setCapacity(size_t size);
            ssize_t         setCapacity(size_t size);
            ssize_t         resize(size_t size);


            /*! append/insert another vector or array */
            /*! append/insert another vector or array */
            ssize_t         insertVectorAt(const VectorImpl& vector, size_t index);
            ssize_t         insertVectorAt(const VectorImpl& vector, size_t index);
+10 −0
Original line number Original line Diff line number Diff line
@@ -343,6 +343,16 @@ ssize_t VectorImpl::setCapacity(size_t new_capacity)
    return 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()
void VectorImpl::release_storage()
{
{
    if (mStorage) {
    if (mStorage) {