Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without heap allocation).
More...
|
void | assign (size_type n, const T &val) |
|
template<typename InputIterator > |
void | assign (InputIterator first, InputIterator last) |
|
| prevector () |
|
| prevector (size_type n) |
|
| prevector (size_type n, const T &val=T()) |
|
template<typename InputIterator > |
| prevector (InputIterator first, InputIterator last) |
|
| prevector (const prevector< N, T, Size, Diff > &other) |
|
| prevector (prevector< N, T, Size, Diff > &&other) |
|
prevector & | operator= (const prevector< N, T, Size, Diff > &other) |
|
prevector & | operator= (prevector< N, T, Size, Diff > &&other) |
|
size_type | size () const |
|
bool | empty () const |
|
iterator | begin () |
|
const_iterator | begin () const |
|
iterator | end () |
|
const_iterator | end () const |
|
reverse_iterator | rbegin () |
|
const_reverse_iterator | rbegin () const |
|
reverse_iterator | rend () |
|
const_reverse_iterator | rend () const |
|
size_t | capacity () const |
|
T & | operator[] (size_type pos) |
|
const T & | operator[] (size_type pos) const |
|
void | resize (size_type new_size) |
|
void | reserve (size_type new_capacity) |
|
void | shrink_to_fit () |
|
void | clear () |
|
iterator | insert (iterator pos, const T &value) |
|
void | insert (iterator pos, size_type count, const T &value) |
|
template<typename InputIterator > |
void | insert (iterator pos, InputIterator first, InputIterator last) |
|
iterator | erase (iterator pos) |
|
iterator | erase (iterator first, iterator last) |
|
void | push_back (const T &value) |
|
void | pop_back () |
|
T & | front () |
|
const T & | front () const |
|
T & | back () |
|
const T & | back () const |
|
void | swap (prevector< N, T, Size, Diff > &other) |
|
| ~prevector () |
|
bool | operator== (const prevector< N, T, Size, Diff > &other) const |
|
bool | operator!= (const prevector< N, T, Size, Diff > &other) const |
|
bool | operator< (const prevector< N, T, Size, Diff > &other) const |
|
size_t | allocated_memory () const |
|
value_type * | data () |
|
const value_type * | data () const |
|
template<unsigned int N, typename T, typename Size = uint32_t, typename Diff = int32_t>
class prevector< N, T, Size, Diff >
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without heap allocation).
The types Size and Diff are used to store element counts, and can be any unsigned + signed type.
Storage layout is either:
- Direct allocation:
- Size _size: the number of used elements (between 0 and N)
- T direct[N]: an array of N elements of type T (only the first _size are initialized).
- Indirect allocation:
- Size _size: the number of used elements plus N + 1
- Size capacity: the number of allocated elements
- T* indirect: a pointer to an array of capacity elements of type T (only the first _size are initialized).
The data type T must be movable by memmove/realloc(). Once we switch to C++, move constructors can be used instead.
Definition at line 36 of file prevector.h.