A generic internal vector. More...
#include <tpie/internal_vector.h>
Inherits tpie::internal_stack_vector_base< T, internal_vector< T > >.
Public Types | |
typedef internal_stack_vector_base< T, internal_vector< T > > | parent_t |
typedef array< T >::iterator | iterator |
typedef array< T >::const_iterator | const_iterator |
typedef T | value_type |
Public Member Functions | |
internal_vector (size_t size=0) | |
Construct structure with given capacity. More... | |
T & | operator[] (size_t s) |
Element access. No range checking is done. More... | |
const T & | operator[] (size_t s) const |
Element access. No range checking is done. More... | |
T & | front () |
Get the first item pushed. Requires !empty (). More... | |
const T & | front () const |
Get the first item pushed. Requires !empty (). More... | |
T & | back () |
Get the last item pushed. Requires !empty (). More... | |
const T & | back () const |
Get the last item pushed. Requires !empty (). More... | |
T & | push_back (const T &val) |
Add an element to the end of the vector. More... | |
T & | push_back () |
If an item was previously popped from this point in the structure, push it to the structure again; otherwise, push the default value. More... | |
void | pop_back () |
Remove the last element from the vector. More... | |
iterator | begin () |
Get an iterator to the beginning of the structure. More... | |
const_iterator | begin () const |
Get an iterator to the beginning of the structure. More... | |
iterator | end () |
Get an iterator to the end of the structure. More... | |
const_iterator | end () const |
Get an iterator to the end of the structure. More... | |
void | resize (size_t size=0) |
Change the capacity of the structure and clear all elements. More... | |
bool | empty () const |
Check if no elements are currently pushed to the structure. More... | |
size_t | size () const |
Return the number of elements in the data structure. More... | |
void | clear () |
Clear the data structure of all elements. More... | |
Static Public Member Functions | |
static double | memory_coefficient () |
Return the memory coefficient of the structure. More... | |
static double | memory_overhead () |
Return the memory overhead of the structure. More... | |
static stream_size_type | memory_usage (stream_size_type size) |
Return the number of bytes required to create a data structure supporting a given number of elements. More... | |
static memory_size_type | memory_fits (memory_size_type memory) |
Return the maximum number of elements that can be contained in in the structure when it is allowed to fill a given number of bytes. More... | |
Protected Attributes | |
array< T > | m_elements |
Element storage. More... | |
size_t | m_size |
Number of elements pushed to the structure. More... | |
A generic internal vector.
T | The type of items stored in the structure. |
Definition at line 37 of file internal_vector.h.
|
inline |
Construct structure with given capacity.
If a zero capacity is given (the default), no elements may be pushed to the structure until the structure is resize
d to a different capacity.
size | Capacity of the structure. |
Definition at line 49 of file internal_vector.h.
|
inline |
Get the last item pushed. Requires !empty
().
Definition at line 74 of file internal_vector.h.
References tpie::internal_stack_vector_base< T, internal_vector< T > >::m_elements, and tpie::internal_stack_vector_base< T, internal_vector< T > >::m_size.
Referenced by tpie::internal_vector< T >::push_back().
|
inline |
Get the last item pushed. Requires !empty
().
Definition at line 79 of file internal_vector.h.
References tpie::internal_stack_vector_base< T, internal_vector< T > >::m_elements, and tpie::internal_stack_vector_base< T, internal_vector< T > >::m_size.
|
inline |
Get an iterator to the beginning of the structure.
Definition at line 113 of file internal_vector.h.
References tpie::array< T, Allocator >::begin(), and tpie::internal_stack_vector_base< T, internal_vector< T > >::m_elements.
|
inline |
Get an iterator to the beginning of the structure.
Definition at line 118 of file internal_vector.h.
References tpie::array< T, Allocator >::begin(), and tpie::internal_stack_vector_base< T, internal_vector< T > >::m_elements.
|
inlineinherited |
Clear the data structure of all elements.
Definition at line 91 of file internal_stack_vector_base.h.
|
inlineinherited |
Check if no elements are currently pushed to the structure.
Definition at line 81 of file internal_stack_vector_base.h.
|
inline |
Get an iterator to the end of the structure.
Definition at line 123 of file internal_vector.h.
References tpie::array< T, Allocator >::find(), tpie::internal_stack_vector_base< T, internal_vector< T > >::m_elements, and tpie::internal_stack_vector_base< T, internal_vector< T > >::m_size.
|
inline |
Get an iterator to the end of the structure.
Definition at line 128 of file internal_vector.h.
References tpie::array< T, Allocator >::find(), tpie::internal_stack_vector_base< T, internal_vector< T > >::m_elements, and tpie::internal_stack_vector_base< T, internal_vector< T > >::m_size.
|
inline |
Get the first item pushed. Requires !empty
().
Definition at line 64 of file internal_vector.h.
References tpie::internal_stack_vector_base< T, internal_vector< T > >::m_elements.
|
inline |
Get the first item pushed. Requires !empty
().
Definition at line 69 of file internal_vector.h.
References tpie::internal_stack_vector_base< T, internal_vector< T > >::m_elements.
|
inlinestaticinherited |
Return the memory coefficient of the structure.
Allocating a structure with n elements will use at most bytes. This does not include memory overhead incurred if the structure is allocated using new.
Definition at line 51 of file internal_stack_vector_base.h.
|
inlinestaticinherited |
Return the maximum number of elements that can be contained in in the structure when it is allowed to fill a given number of bytes.
memory | The number of bytes the structure is allowed to occupy |
|
inlinestaticinherited |
Return the memory overhead of the structure.
Definition at line 56 of file internal_stack_vector_base.h.
|
inlinestaticinherited |
Return the number of bytes required to create a data structure supporting a given number of elements.
size | The number of elements to support |
|
inline |
Element access. No range checking is done.
Definition at line 54 of file internal_vector.h.
References tpie::internal_stack_vector_base< T, internal_vector< T > >::m_elements.
|
inline |
Element access. No range checking is done.
Definition at line 59 of file internal_vector.h.
References tpie::internal_stack_vector_base< T, internal_vector< T > >::m_elements.
|
inline |
Remove the last element from the vector.
Iterators are invalidated by this call.
Definition at line 108 of file internal_vector.h.
References tpie::internal_stack_vector_base< T, internal_vector< T > >::m_size.
|
inline |
Add an element to the end of the vector.
If size() is equal to the capacity (set in the constructor or in resize()), effects are undefined. resize() is not called implicitly.
Iterators are invalidated by this call.
val | The element to add. |
Definition at line 90 of file internal_vector.h.
References tpie::internal_vector< T >::back(), tpie::internal_stack_vector_base< T, internal_vector< T > >::m_elements, and tpie::internal_stack_vector_base< T, internal_vector< T > >::m_size.
|
inline |
If an item was previously popped from this point in the structure, push it to the structure again; otherwise, push the default value.
Iterators are invalidated by this call.
val | The element to add. |
Definition at line 101 of file internal_vector.h.
References tpie::internal_vector< T >::back(), and tpie::internal_stack_vector_base< T, internal_vector< T > >::m_size.
|
inlineinherited |
Change the capacity of the structure and clear all elements.
size | New capacity of the structure. |
Definition at line 76 of file internal_stack_vector_base.h.
|
inlineinherited |
Return the number of elements in the data structure.
Definition at line 86 of file internal_stack_vector_base.h.
|
protectedinherited |
Element storage.
Definition at line 41 of file internal_stack_vector_base.h.
Referenced by tpie::internal_vector< T >::back(), tpie::internal_vector< T >::begin(), tpie::internal_vector< T >::end(), tpie::internal_vector< T >::front(), tpie::internal_vector< T >::operator[](), and tpie::internal_vector< T >::push_back().
|
protectedinherited |
Number of elements pushed to the structure.
Definition at line 44 of file internal_stack_vector_base.h.
Referenced by tpie::internal_vector< T >::back(), tpie::internal_vector< T >::end(), tpie::internal_vector< T >::pop_back(), and tpie::internal_vector< T >::push_back().