summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-04-25 15:28:17 -0700
committerAlex Ray <aray@google.com>2013-07-30 13:56:56 -0700
commitbc55d727f3c7a5c95cc7a458ea8309bcff29919b (patch)
treee9b039e2f7591c301080ad0b22eb1a1b132b4ade /include
parent8bb27951f592713bcb2c0e6605d89da665131637 (diff)
downloadsystem_core-bc55d727f3c7a5c95cc7a458ea8309bcff29919b.zip
system_core-bc55d727f3c7a5c95cc7a458ea8309bcff29919b.tar.gz
system_core-bc55d727f3c7a5c95cc7a458ea8309bcff29919b.tar.bz2
Add some basic STL compatibility to Vector<>
Change-Id: Iaf72623170ee415372c7989d7ba9ff627167449e
Diffstat (limited to 'include')
-rw-r--r--include/utils/Vector.h20
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;