STXXL  1.4-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stxxl::swap_vector< ValueType > Class Template Reference

Detailed Description

template<typename ValueType>
class stxxl::swap_vector< ValueType >

Vector that avoids copying of ValueType objects in push_back() (here: swap_back()) and resize() operations.

Values are swapped with default-constructed instances instead. Important: A template spezialization for std::swap(ValueType&,ValueType&) must be provided. Make shure the swap implementation is located above these lines.

Definition at line 34 of file swap_vector.h.

+ Inheritance diagram for stxxl::swap_vector< ValueType >:
+ Collaboration diagram for stxxl::swap_vector< ValueType >:

Public Types

typedef const value_typeconst_iterator
 
typedef const value_typeconst_reference
 
typedef value_typeiterator
 
typedef value_typereference
 
typedef size_t size_type
 
typedef ValueType value_type
 

Public Member Functions

 swap_vector ()
 Create an empty vector. More...
 
 swap_vector (size_type size)
 Create a vector with the spezified size. More...
 
 swap_vector (size_type size, size_type capacity)
 Create a vector with the spezified size and reserve (possibly more) space. More...
 
 ~swap_vector ()
 Delete the vector. More...
 
reference back ()
 Return reference to last element. More...
 
const_reference back () const
 Return reference to last element. More...
 
iterator begin ()
 Return mutable iterator to the first element. More...
 
const_iterator begin () const
 Return constant iterator to the first element. More...
 
size_type capacity () const
 Return the size of the underlaying array. More...
 
const_iterator cbegin () const
 Return constant iterator to the first element. More...
 
const_iterator cend () const
 Return constant iterator beyond the last element. More...
 
void clear ()
 Clear the vector. The capacity doesn't change. More...
 
iterator data ()
 Return iterator to the beginning of vector. More...
 
const_iterator data () const
 Return iterator to the beginning of vector. More...
 
bool empty () const
 Return the vector size. More...
 
iterator end ()
 Return mutable iterator beyond the last element. More...
 
const_iterator end () const
 Return constant iterator beyond the last element. More...
 
iterator erase (iterator position)
 Erase the element at the given position by swapping it to the and and then reducing the vector size. More...
 
iterator erase (iterator first, iterator last)
 Erase the elements at in the range [begin,last) by swapping them to the and and then reducing the vector size. More...
 
reference front ()
 Return reference to first element. More...
 
const_reference front () const
 Return constant reference to first element. More...
 
reference operator[] (size_type i)
 Return the i-th position of the vector. More...
 
const_reference operator[] (size_type i) const
 Return constant reference to the i-th position of the vector. More...
 
void reserve (size_type newsize)
 Resize the underlaying array to contain at least newsize items. More...
 
void resize (size_type newsize)
 Resize the vector to contain at least newsize items. More...
 
size_type size () const
 Return the vector size. More...
 
void swap (swap_vector &obj)
 Swap the vector with another one. More...
 
void swap_back (reference val)
 Create a new value_type object at the end of the vector and then swap it with val. More...
 

Protected Attributes

value_typem_array
 pointer to allocated memory area More...
 
size_type m_capacity
 size of allocated memory More...
 
size_type m_size
 size of vector More...
 

Additional Inherited Members

- Private Member Functions inherited from stxxl::noncopyable
 noncopyable ()
 

Member Typedef Documentation

template<typename ValueType>
typedef const value_type* stxxl::swap_vector< ValueType >::const_iterator

Definition at line 54 of file swap_vector.h.

template<typename ValueType>
typedef const value_type& stxxl::swap_vector< ValueType >::const_reference

Definition at line 56 of file swap_vector.h.

template<typename ValueType>
typedef value_type* stxxl::swap_vector< ValueType >::iterator

Definition at line 53 of file swap_vector.h.

template<typename ValueType>
typedef value_type& stxxl::swap_vector< ValueType >::reference

Definition at line 55 of file swap_vector.h.

template<typename ValueType>
typedef size_t stxxl::swap_vector< ValueType >::size_type

Definition at line 38 of file swap_vector.h.

template<typename ValueType>
typedef ValueType stxxl::swap_vector< ValueType >::value_type

Definition at line 37 of file swap_vector.h.

Constructor & Destructor Documentation

template<typename ValueType>
stxxl::swap_vector< ValueType >::swap_vector ( )
inline

Create an empty vector.

Definition at line 60 of file swap_vector.h.

template<typename ValueType>
stxxl::swap_vector< ValueType >::swap_vector ( size_type  size)
inline

Create a vector with the spezified size.

Definition at line 64 of file swap_vector.h.

template<typename ValueType>
stxxl::swap_vector< ValueType >::swap_vector ( size_type  size,
size_type  capacity 
)
inline

Create a vector with the spezified size and reserve (possibly more) space.

Definition at line 72 of file swap_vector.h.

template<typename ValueType>
stxxl::swap_vector< ValueType >::~swap_vector ( )
inline

Delete the vector.

Definition at line 87 of file swap_vector.h.

Member Function Documentation

template<typename ValueType>
reference stxxl::swap_vector< ValueType >::back ( )
inline

Return reference to last element.

Definition at line 171 of file swap_vector.h.

template<typename ValueType>
const_reference stxxl::swap_vector< ValueType >::back ( ) const
inline

Return reference to last element.

Definition at line 177 of file swap_vector.h.

template<typename ValueType>
iterator stxxl::swap_vector< ValueType >::begin ( )
inline

Return mutable iterator to the first element.

Definition at line 117 of file swap_vector.h.

template<typename ValueType>
const_iterator stxxl::swap_vector< ValueType >::begin ( ) const
inline

Return constant iterator to the first element.

Definition at line 122 of file swap_vector.h.

template<typename ValueType>
size_type stxxl::swap_vector< ValueType >::capacity ( ) const
inline

Return the size of the underlaying array.

Definition at line 102 of file swap_vector.h.

template<typename ValueType>
const_iterator stxxl::swap_vector< ValueType >::cbegin ( ) const
inline

Return constant iterator to the first element.

Definition at line 127 of file swap_vector.h.

template<typename ValueType>
const_iterator stxxl::swap_vector< ValueType >::cend ( ) const
inline

Return constant iterator beyond the last element.

Definition at line 142 of file swap_vector.h.

template<typename ValueType>
void stxxl::swap_vector< ValueType >::clear ( )
inline

Clear the vector. The capacity doesn't change.

Definition at line 224 of file swap_vector.h.

template<typename ValueType>
iterator stxxl::swap_vector< ValueType >::data ( )
inline

Return iterator to the beginning of vector.

Definition at line 107 of file swap_vector.h.

template<typename ValueType>
const_iterator stxxl::swap_vector< ValueType >::data ( ) const
inline

Return iterator to the beginning of vector.

Definition at line 112 of file swap_vector.h.

template<typename ValueType>
bool stxxl::swap_vector< ValueType >::empty ( ) const
inline

Return the vector size.

Definition at line 97 of file swap_vector.h.

template<typename ValueType>
iterator stxxl::swap_vector< ValueType >::end ( )
inline

Return mutable iterator beyond the last element.

Definition at line 132 of file swap_vector.h.

template<typename ValueType>
const_iterator stxxl::swap_vector< ValueType >::end ( ) const
inline

Return constant iterator beyond the last element.

Definition at line 137 of file swap_vector.h.

template<typename ValueType>
iterator stxxl::swap_vector< ValueType >::erase ( iterator  position)
inline

Erase the element at the given position by swapping it to the and and then reducing the vector size.

Definition at line 230 of file swap_vector.h.

template<typename ValueType>
iterator stxxl::swap_vector< ValueType >::erase ( iterator  first,
iterator  last 
)
inline

Erase the elements at in the range [begin,last) by swapping them to the and and then reducing the vector size.

Definition at line 236 of file swap_vector.h.

template<typename ValueType>
reference stxxl::swap_vector< ValueType >::front ( )
inline

Return reference to first element.

Definition at line 159 of file swap_vector.h.

template<typename ValueType>
const_reference stxxl::swap_vector< ValueType >::front ( ) const
inline

Return constant reference to first element.

Definition at line 165 of file swap_vector.h.

template<typename ValueType>
reference stxxl::swap_vector< ValueType >::operator[] ( size_type  i)
inline

Return the i-th position of the vector.

Definition at line 147 of file swap_vector.h.

template<typename ValueType>
const_reference stxxl::swap_vector< ValueType >::operator[] ( size_type  i) const
inline

Return constant reference to the i-th position of the vector.

Definition at line 153 of file swap_vector.h.

template<typename ValueType>
void stxxl::swap_vector< ValueType >::reserve ( size_type  newsize)
inline

Resize the underlaying array to contain at least newsize items.

Definition at line 183 of file swap_vector.h.

template<typename ValueType>
void stxxl::swap_vector< ValueType >::resize ( size_type  newsize)
inline

Resize the vector to contain at least newsize items.

Definition at line 206 of file swap_vector.h.

template<typename ValueType>
size_type stxxl::swap_vector< ValueType >::size ( ) const
inline

Return the vector size.

Definition at line 92 of file swap_vector.h.

template<typename ValueType>
void stxxl::swap_vector< ValueType >::swap ( swap_vector< ValueType > &  obj)
inline

Swap the vector with another one.

Definition at line 79 of file swap_vector.h.

template<typename ValueType>
void stxxl::swap_vector< ValueType >::swap_back ( reference  val)
inline

Create a new value_type object at the end of the vector and then swap it with val.

Definition at line 213 of file swap_vector.h.

Member Data Documentation

template<typename ValueType>
value_type* stxxl::swap_vector< ValueType >::m_array
protected

pointer to allocated memory area

Definition at line 48 of file swap_vector.h.

Referenced by stxxl::swap_vector< external_array_type >::swap().

template<typename ValueType>
size_type stxxl::swap_vector< ValueType >::m_capacity
protected

size of allocated memory

Definition at line 45 of file swap_vector.h.

Referenced by stxxl::swap_vector< external_array_type >::swap().

template<typename ValueType>
size_type stxxl::swap_vector< ValueType >::m_size
protected

size of vector

Definition at line 42 of file swap_vector.h.

Referenced by stxxl::swap_vector< external_array_type >::swap().


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