diff options
author | Mathias Agopian <mathias@google.com> | 2011-04-25 15:29:40 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-04-25 15:29:40 -0700 |
commit | 46baa14f27eb08b55434bf6e9cf9bcc9c9dbc17f (patch) | |
tree | 2dbe24b112e75c15b8194c14ff8f99f65b9089ea /include | |
parent | 7ada57f8baa14740a2484e5f04a78e63a872d8a8 (diff) | |
parent | 589b64a64be16d04d35113bc7f2644e200cb4a3e (diff) | |
download | frameworks_base-46baa14f27eb08b55434bf6e9cf9bcc9c9dbc17f.zip frameworks_base-46baa14f27eb08b55434bf6e9cf9bcc9c9dbc17f.tar.gz frameworks_base-46baa14f27eb08b55434bf6e9cf9bcc9c9dbc17f.tar.bz2 |
Merge "Add some basic STL compatibility to Vector<>"
Diffstat (limited to 'include')
-rw-r--r-- | include/utils/Vector.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/utils/Vector.h b/include/utils/Vector.h index 6fd307f..90477b7 100644 --- a/include/utils/Vector.h +++ b/include/utils/Vector.h @@ -165,6 +165,26 @@ public: // for debugging only inline size_t getItemSize() const { return itemSize(); } + + /* + * these inlines add some level of compatibility with STL. eventually + * we should probably turn things around. + */ + typedef TYPE* iterator; + typedef TYPE const* const_iterator; + + inline iterator begin() { return editArray(); } + inline iterator end() { return editArray() + size(); } + inline const_iterator begin() const { return array(); } + inline const_iterator end() const { return array() + size(); } + inline void reserve(size_t n) { setCapacity(n); } + inline bool empty() const{ return isEmpty(); } + inline void push_back(const TYPE& item) { insertAt(size(), item); } + inline void push_front(const TYPE& item) { insertAt(0, item); } + inline iterator erase(iterator pos) { + return begin() + removeItemsAt(pos-array()); + } + protected: virtual void do_construct(void* storage, size_t num) const; virtual void do_destroy(void* storage, size_t num) const; |