CppELib 1.7.0
Loading...
Searching...
No Matches
Container::PreallocatedVector< T > Class Template Reference

STL-like vector container using pre-allocated buffer. More...

#include <PreallocatedVector.h>

Public Types

typedef T value_type
 
typedef std::size_t size_type
 
typedef std::ptrdiff_t difference_type
 
typedef value_typeiterator
 
typedef const value_typeconst_iterator
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef value_typepointer
 
typedef const value_typeconst_pointer
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 

Public Member Functions

 PreallocatedVector ()
 Default constructor.
 
 PreallocatedVector (void *preallocated_buffer, size_type buffer_size)
 Constructor.
 
 ~PreallocatedVector ()
 Destructor.
 
void init (void *preallocated_buffer, size_type buffer_size)
 Initialize.
 
PreallocatedVectoroperator= (const PreallocatedVector &x)
 
size_type size () const
 
size_type max_size () const
 
size_type available_size () const
 
bool empty () const
 
bool full () const
 
void clear ()
 
reference operator[] (size_type idx)
 
const_reference operator[] (size_type idx) const
 
reference at (size_type idx)
 
const_reference at (size_type idx) const
 
pointer data ()
 
const_pointer data () 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
 
reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
void resize (size_type n, const T &data=T())
 
void push_back (const T &data)
 
void pop_back ()
 
void assign (size_type n, const T &data)
 
template<typename InputIterator >
void assign (InputIterator first, InputIterator last)
 
iterator insert (iterator pos, const T &data)
 
void insert (iterator pos, size_type n, const T &data)
 
template<typename InputIterator >
void insert (iterator pos, InputIterator first, InputIterator last)
 
iterator erase (iterator pos)
 
iterator erase (iterator first, iterator last)
 

Detailed Description

template<typename T>
class Container::PreallocatedVector< T >

STL-like vector container using pre-allocated buffer.

Template Parameters
TType of element

Almost all the method specification is similar as STL vector, but this container can not expand the capacity.

Over capacity addition of element throws the exception derived from std::exception. But if CPPELIB_NO_EXCEPTIONS macro is defined, aborted instead of the exception.

Member Typedef Documentation

◆ const_iterator

◆ const_pointer

◆ const_reference

◆ const_reverse_iterator

template<typename T >
typedef std::reverse_iterator<const_iterator> Container::PreallocatedVector< T >::const_reverse_iterator

◆ difference_type

template<typename T >
typedef std::ptrdiff_t Container::PreallocatedVector< T >::difference_type

◆ iterator

◆ pointer

◆ reference

◆ reverse_iterator

template<typename T >
typedef std::reverse_iterator<iterator> Container::PreallocatedVector< T >::reverse_iterator

◆ size_type

template<typename T >
typedef std::size_t Container::PreallocatedVector< T >::size_type

◆ value_type

template<typename T >
typedef T Container::PreallocatedVector< T >::value_type

Constructor & Destructor Documentation

◆ PreallocatedVector() [1/2]

template<typename T >
Container::PreallocatedVector< T >::PreallocatedVector ( )
inline

Default constructor.

Attention
If you use default constructor, you need to call init() before other method call.

◆ PreallocatedVector() [2/2]

template<typename T >
Container::PreallocatedVector< T >::PreallocatedVector ( void preallocated_buffer,
size_type  buffer_size 
)
inline

Constructor.

Parameters
preallocated_bufferPre-allocated buffer by caller
buffer_sizeNumber of bytes of preallocated_buffer
Attention
preallocated_buffer must be aligned on the boundary of type T.

◆ ~PreallocatedVector()

Destructor.

Note
All elements are erased, but pre-allocated buffer is not released.

Member Function Documentation

◆ assign() [1/2]

template<typename T >
template<typename InputIterator >
void Container::PreallocatedVector< T >::assign ( InputIterator  first,
InputIterator  last 
)
inline

◆ assign() [2/2]

template<typename T >
void Container::PreallocatedVector< T >::assign ( size_type  n,
const T data 
)
inline

◆ at() [1/2]

template<typename T >
reference Container::PreallocatedVector< T >::at ( size_type  idx)
inline

◆ at() [2/2]

template<typename T >
const_reference Container::PreallocatedVector< T >::at ( size_type  idx) const
inline

◆ available_size()

template<typename T >
size_type Container::PreallocatedVector< T >::available_size ( ) const
inline

◆ back() [1/2]

template<typename T >
reference Container::PreallocatedVector< T >::back ( )
inline

◆ back() [2/2]

template<typename T >
const_reference Container::PreallocatedVector< T >::back ( ) const
inline

◆ begin() [1/2]

template<typename T >
iterator Container::PreallocatedVector< T >::begin ( )
inline

◆ begin() [2/2]

template<typename T >
const_iterator Container::PreallocatedVector< T >::begin ( ) const
inline

◆ clear()

template<typename T >
void Container::PreallocatedVector< T >::clear ( )
inline

◆ data() [1/2]

template<typename T >
pointer Container::PreallocatedVector< T >::data ( )
inline

◆ data() [2/2]

template<typename T >
const_pointer Container::PreallocatedVector< T >::data ( ) const
inline

◆ empty()

template<typename T >
bool Container::PreallocatedVector< T >::empty ( ) const
inline

◆ end() [1/2]

template<typename T >
iterator Container::PreallocatedVector< T >::end ( )
inline

◆ end() [2/2]

template<typename T >
const_iterator Container::PreallocatedVector< T >::end ( ) const
inline

◆ erase() [1/2]

template<typename T >
iterator Container::PreallocatedVector< T >::erase ( iterator  first,
iterator  last 
)
inline

◆ erase() [2/2]

template<typename T >
iterator Container::PreallocatedVector< T >::erase ( iterator  pos)
inline

◆ front() [1/2]

template<typename T >
reference Container::PreallocatedVector< T >::front ( )
inline

◆ front() [2/2]

template<typename T >
const_reference Container::PreallocatedVector< T >::front ( ) const
inline

◆ full()

template<typename T >
bool Container::PreallocatedVector< T >::full ( ) const
inline

◆ init()

template<typename T >
void Container::PreallocatedVector< T >::init ( void preallocated_buffer,
size_type  buffer_size 
)
inline

Initialize.

Parameters
preallocated_bufferPre-allocated buffer by caller
buffer_sizeNumber of bytes of preallocated_buffer
Attention
preallocated_buffer must be aligned on the boundary of type T.
If you use default constructor, you need to call init() before other method call.
Note
Pre-allocated buffer can be set only one time.

◆ insert() [1/3]

template<typename T >
iterator Container::PreallocatedVector< T >::insert ( iterator  pos,
const T data 
)
inline

◆ insert() [2/3]

template<typename T >
template<typename InputIterator >
void Container::PreallocatedVector< T >::insert ( iterator  pos,
InputIterator  first,
InputIterator  last 
)
inline

◆ insert() [3/3]

template<typename T >
void Container::PreallocatedVector< T >::insert ( iterator  pos,
size_type  n,
const T data 
)
inline

◆ max_size()

template<typename T >
size_type Container::PreallocatedVector< T >::max_size ( ) const
inline

◆ operator=()

◆ operator[]() [1/2]

◆ operator[]() [2/2]

◆ pop_back()

template<typename T >
void Container::PreallocatedVector< T >::pop_back ( )
inline

◆ push_back()

template<typename T >
void Container::PreallocatedVector< T >::push_back ( const T data)
inline

◆ rbegin() [1/2]

template<typename T >
reverse_iterator Container::PreallocatedVector< T >::rbegin ( )
inline

◆ rbegin() [2/2]

template<typename T >
const_reverse_iterator Container::PreallocatedVector< T >::rbegin ( ) const
inline

◆ rend() [1/2]

template<typename T >
reverse_iterator Container::PreallocatedVector< T >::rend ( )
inline

◆ rend() [2/2]

template<typename T >
const_reverse_iterator Container::PreallocatedVector< T >::rend ( ) const
inline

◆ resize()

template<typename T >
void Container::PreallocatedVector< T >::resize ( size_type  n,
const T data = T() 
)
inline

◆ size()

template<typename T >
size_type Container::PreallocatedVector< T >::size ( ) const
inline

The documentation for this class was generated from the following file: