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

Commit e60e1fd2 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

Add some basic STL compatibility to Vector<>

Change-Id: Iaf72623170ee415372c7989d7ba9ff627167449e
parent 9adbcb82
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -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;