0.12.0
Freundlich's C++ toolkit
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions
fcppt::container::raw_vector< T, A > Class Template Reference

Detailed Description

template<typename T, typename A>
class fcppt::container::raw_vector< T, A >

A special vector class for pod types.

Template Parameters
TContainer's value_type. Has to be a POD type; see here for what this means.
AThe allocator.

See the module documentation for more information.

Public Types

typedef T value_type
 A type that represents the data type stored in a vector.
 
typedef A allocator_type
 A type that represents the allocator class for the vector object.
 
typedef A::size_type size_type
 A type that counts the number of elements in a vector.
 
typedef A::difference_type difference_type
 A type that provides the difference between the addresses of two elements in a vector.
 
typedef A::pointer pointer
 A type that provides a pointer to an element in a vector.
 
typedef A::const_pointer const_pointer
 A type that provides a pointer to a const element in a vector.
 
typedef A::reference reference
 A type that provides a reference to an element stored in a vector.
 
typedef A::const_reference const_reference
 A type that provides a reference to a const element stored in a vector for reading and performing const operations.
 
typedef pointer iterator
 A type that provides a random-access iterator that can read or modify any element in a vector.
 
typedef const_pointer const_iterator
 A type that provides a random-access iterator that can read a const element in a vector.
 
typedef std::reverse_iterator
< iterator
reverse_iterator
 A type that provides a random-access iterator that can read or modify any element in a reversed vector.
 
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
 A type that provides a random-access iterator that can read any const element in the vector.
 

Public Member Functions

iterator begin ()
 Returns a random-access iterator to the first element in the container.
 
const_iterator begin () const
 Returns a random-access iterator to the first element in the container.
 
iterator end ()
 Returns a random-access iterator that points just beyond the end of the vector.
 
const_iterator end () const
 Returns a random-access iterator that points just beyond the end of the vector.
 
reverse_iterator rbegin ()
 Returns an iterator to the first element in a reversed vector.
 
const_reverse_iterator rbegin () const
 Returns an iterator to the first element in a reversed vector.
 
reverse_iterator rend ()
 Returns an iterator to the end of a reversed vector.
 
const_reverse_iterator rend () const
 Returns an iterator to the end of a reversed vector.
 
const_iterator cbegin () const
 Returns a random-access const-iterator to the first element in the container.
 
const_iterator cend () const
 Returns a random-access const-iterator that points just beyond the end of the vector.
 
const_reverse_iterator crbegin () const
 Returns a const-iterator to the first element in a reversed vector.
 
const_reverse_iterator crend () const
 Returns an iterator to the end of a reversed vector.
 
reference operator[] (size_type)
 Returns a reference to the vector element at a specified position.
 
const_reference operator[] (size_type) const
 Returns a reference to the vector element at a specified position.
 
reference at (size_type)
 Returns a reference to the element at a specified location in the vector.
 
const_reference at (size_type) const
 Returns a reference to the element at a specified location in the vector.
 
reference front ()
 Returns a reference to the first element in a vector.
 
const_reference front () const
 Returns a reference to the first element in a vector.
 
reference back ()
 Returns a reference to the last element of the vector.
 
const_reference back () const
 Returns a reference to the last element of the vector.
 
pointer data ()
 Returns the pointer to the store.
 
const_pointer data () const
 Returns the pointer to the store.
 
pointer data_end ()
 Returns the pointer to the end of the store.
 
const_pointer data_end () const
 Returns the pointer to the end of the store.
 
 raw_vector (A const &a=A())
 Construct an empty vector using the specified allocator.
 
 raw_vector (size_type sz, A const &a=A())
 Constructs an uninitialized vector.
 
 raw_vector (size_type sz, T const &t, A const &a=A())
 Constructs an initialized vector.
 
template<typename In >
 raw_vector (In beg, In end, A const &a=A())
 Constructs a vector from an iterator range.
 
 raw_vector (raw_vector const &)
 
 ~raw_vector ()
 
raw_vectoroperator= (raw_vector const &)
 
template<typename In >
void assign (In beg, In end)
 Erases a vector and copies the specified elements to the empty vector.
 
void assign (size_type n, T const &value)
 Resizes a vector and copies the specified element to the new vector.
 
void push_back (T const &t)
 Add an element to the end of the vector.
 
void pop_back ()
 Deletes the element at the end of the vector.
 
void clear ()
 Erases the elements of the vector.
 
size_type size () const
 Returns the number of elements in the vector.
 
bool empty () const
 Tests if the vector container is empty.
 
size_type max_size () const
 Returns the maximum length of the vector.
 
size_type capacity () const
 Returns the number of elements that the vector could contain without allocating more storage.
 
void swap (raw_vector &)
 Exchanges the elements of two vectors.
 
void resize_uninitialized (size_type sz)
 The same as resize but doesn't initialize the newly created elements (if any)
 
void resize (size_type sz, T const &value=T())
 Erases the elements of the vector.
 
void reserve (size_type sz)
 Reserves a minimum length of storage for a vector object.
 
allocator_type get_allocator () const
 Returns an object to the allocator class used by a vector.
 
iterator insert (iterator position, T const &t)
 Inserts an element into the vector at a specified position.
 
void insert (iterator position, size_type n, T const &t)
 Inserts copies of an element into the vector at a specified position.
 
template<typename In >
void insert (iterator position, In beg, In end)
 Inserts a range of elements into the vector at a specified position.
 
iterator erase (iterator position)
 Erases the element given by the iterator.
 
iterator erase (iterator first, iterator last)
 Erase a range of elements from the vector.
 
void shrink_to_fit ()
 Tries to shrink capacity() to fit size()
 
void free_memory ()
 Destroy this vector completely, it will then have empty storage Equivalent to resize(0); shrink_to_fit();
 

Member Typedef Documentation

template<typename T, typename A>
typedef A fcppt::container::raw_vector< T, A >::allocator_type

A type that represents the allocator class for the vector object.

template<typename T, typename A>
typedef const_pointer fcppt::container::raw_vector< T, A >::const_iterator

A type that provides a random-access iterator that can read a const element in a vector.

template<typename T, typename A>
typedef A::const_pointer fcppt::container::raw_vector< T, A >::const_pointer

A type that provides a pointer to a const element in a vector.

template<typename T, typename A>
typedef A::const_reference fcppt::container::raw_vector< T, A >::const_reference

A type that provides a reference to a const element stored in a vector for reading and performing const operations.

template<typename T, typename A>
typedef std::reverse_iterator<const_iterator> fcppt::container::raw_vector< T, A >::const_reverse_iterator

A type that provides a random-access iterator that can read any const element in the vector.

template<typename T, typename A>
typedef A::difference_type fcppt::container::raw_vector< T, A >::difference_type

A type that provides the difference between the addresses of two elements in a vector.

template<typename T, typename A>
typedef pointer fcppt::container::raw_vector< T, A >::iterator

A type that provides a random-access iterator that can read or modify any element in a vector.

template<typename T, typename A>
typedef A::pointer fcppt::container::raw_vector< T, A >::pointer

A type that provides a pointer to an element in a vector.

template<typename T, typename A>
typedef A::reference fcppt::container::raw_vector< T, A >::reference

A type that provides a reference to an element stored in a vector.

template<typename T, typename A>
typedef std::reverse_iterator<iterator> fcppt::container::raw_vector< T, A >::reverse_iterator

A type that provides a random-access iterator that can read or modify any element in a reversed vector.

template<typename T, typename A>
typedef A::size_type fcppt::container::raw_vector< T, A >::size_type

A type that counts the number of elements in a vector.

template<typename T, typename A>
typedef T fcppt::container::raw_vector< T, A >::value_type

A type that represents the data type stored in a vector.

Constructor & Destructor Documentation

template<typename T , typename A>
fcppt::container::raw_vector< T, A >::raw_vector ( A const &  a = A())
explicit

Construct an empty vector using the specified allocator.

Parameters
aThe allocator
template<typename T , typename A>
fcppt::container::raw_vector< T, A >::raw_vector ( size_type  sz,
A const &  a = A() 
)
explicit

Constructs an uninitialized vector.

Parameters
szThe initial size of the vector
aThe allocator All of the elements will have indeterminate values and must be written before being read.
template<typename T, typename A>
fcppt::container::raw_vector< T, A >::raw_vector ( size_type  sz,
T const &  t,
A const &  a = A() 
)

Constructs an initialized vector.

Parameters
szThe initial size of the vector
tThe value to assign to all elements in the vector
aThe allocator
template<typename T , typename A>
template<typename In >
fcppt::container::raw_vector< T, A >::raw_vector ( In  beg,
In  end,
A const &  a = A() 
)

Constructs a vector from an iterator range.

Template Parameters
InA forward iterator type
Parameters
begThe begining of the iterator range
endOne past the end of the iterator range
aThe allocator
template<typename T, typename A>
fcppt::container::raw_vector< T, A >::raw_vector ( raw_vector< T, A > const &  _other)
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::~raw_vector ( )

Member Function Documentation

template<typename T , typename A >
template<typename In >
void fcppt::container::raw_vector< T, A >::assign ( In  beg,
In  end 
)

Erases a vector and copies the specified elements to the empty vector.

Template Parameters
InA forward iterator type
Parameters
begThe begining of the iterator range
endOne past the end of the iterator range
template<typename T, typename A >
void fcppt::container::raw_vector< T, A >::assign ( size_type  n,
T const &  value 
)

Resizes a vector and copies the specified element to the new vector.

Parameters
nThe vector's new size
valueThe value to assign to all the elements
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::reference fcppt::container::raw_vector< T, A >::at ( size_type  _index)

Returns a reference to the element at a specified location in the vector.

Exceptions
fcppt::container::out_of_range
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_reference fcppt::container::raw_vector< T, A >::at ( size_type  _index) const

Returns a reference to the element at a specified location in the vector.

Exceptions
fcppt::container::out_of_range
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::reference fcppt::container::raw_vector< T, A >::back ( )

Returns a reference to the last element of the vector.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_reference fcppt::container::raw_vector< T, A >::back ( ) const

Returns a reference to the last element of the vector.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::iterator fcppt::container::raw_vector< T, A >::begin ( )

Returns a random-access iterator to the first element in the container.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_iterator fcppt::container::raw_vector< T, A >::begin ( ) const

Returns a random-access iterator to the first element in the container.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::size_type fcppt::container::raw_vector< T, A >::capacity ( ) const

Returns the number of elements that the vector could contain without allocating more storage.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_iterator fcppt::container::raw_vector< T, A >::cbegin ( ) const

Returns a random-access const-iterator to the first element in the container.

Note
This function is not found in (C++03's) std::vector
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_iterator fcppt::container::raw_vector< T, A >::cend ( ) const

Returns a random-access const-iterator that points just beyond the end of the vector.

Note
This function is not found in (C++03's) std::vector
template<typename T , typename A >
void fcppt::container::raw_vector< T, A >::clear ( )

Erases the elements of the vector.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_reverse_iterator fcppt::container::raw_vector< T, A >::crbegin ( ) const

Returns a const-iterator to the first element in a reversed vector.

Note
This function is not found in (C++03's) std::vector
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_reverse_iterator fcppt::container::raw_vector< T, A >::crend ( ) const

Returns an iterator to the end of a reversed vector.

Note
This function is not found in (C++03's) std::vector
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::pointer fcppt::container::raw_vector< T, A >::data ( )

Returns the pointer to the store.

May return 0 if the vector is empty.

Note
This function is not found in (C++03's) std::vector
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_pointer fcppt::container::raw_vector< T, A >::data ( ) const

Returns the pointer to the store.

May return 0 if the vector is empty.

Note
This function is not found in (C++03's) std::vector
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::pointer fcppt::container::raw_vector< T, A >::data_end ( )

Returns the pointer to the end of the store.

Equal to data() + size().

Note
This function is not found in (C++03's) std::vector
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_pointer fcppt::container::raw_vector< T, A >::data_end ( ) const

Returns the pointer to the end of the store.

Equal to data() + size().

Note
This function is not found in (C++03's) std::vector
template<typename T , typename A >
bool fcppt::container::raw_vector< T, A >::empty ( ) const

Tests if the vector container is empty.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::iterator fcppt::container::raw_vector< T, A >::end ( )

Returns a random-access iterator that points just beyond the end of the vector.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_iterator fcppt::container::raw_vector< T, A >::end ( ) const

Returns a random-access iterator that points just beyond the end of the vector.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::iterator fcppt::container::raw_vector< T, A >::erase ( iterator  position)

Erases the element given by the iterator.

Parameters
positionThe iterator to the element to delete
Returns
An iterator pointing to the element next to the deleted one
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::iterator fcppt::container::raw_vector< T, A >::erase ( iterator  first,
iterator  last 
)

Erase a range of elements from the vector.

Parameters
firstThe begining of the iterator range
lastOne past the end of the iterator range
Returns
An iterator pointing to the element previously located at position end
template<typename T , typename A >
void fcppt::container::raw_vector< T, A >::free_memory ( )

Destroy this vector completely, it will then have empty storage Equivalent to resize(0); shrink_to_fit();

Note
This function is not found in (C++03's) std::vector
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::reference fcppt::container::raw_vector< T, A >::front ( )

Returns a reference to the first element in a vector.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_reference fcppt::container::raw_vector< T, A >::front ( ) const

Returns a reference to the first element in a vector.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::allocator_type fcppt::container::raw_vector< T, A >::get_allocator ( ) const

Returns an object to the allocator class used by a vector.

template<typename T, typename A >
fcppt::container::raw_vector< T, A >::iterator fcppt::container::raw_vector< T, A >::insert ( iterator  position,
T const &  t 
)

Inserts an element into the vector at a specified position.

Parameters
positionAn iterator to the element after the new element
tThe new element
template<typename T, typename A >
void fcppt::container::raw_vector< T, A >::insert ( iterator  position,
size_type  n,
T const &  t 
)

Inserts copies of an element into the vector at a specified position.

Parameters
positionAn iterator to the element after the new elements
nHow many copies to insert
tThe new element
template<typename T , typename A >
template<typename In >
void fcppt::container::raw_vector< T, A >::insert ( iterator  position,
In  beg,
In  end 
)

Inserts a range of elements into the vector at a specified position.

Template Parameters
InA forward iterator type
Parameters
positionAn iterator to the element after the new elements
begThe begining of the iterator range
endOne past the end of the iterator range
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::size_type fcppt::container::raw_vector< T, A >::max_size ( ) const

Returns the maximum length of the vector.

template<typename T , typename A >
fcppt::container::raw_vector< T, A > & fcppt::container::raw_vector< T, A >::operator= ( raw_vector< T, A > const &  _other)
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::reference fcppt::container::raw_vector< T, A >::operator[] ( size_type  _index)

Returns a reference to the vector element at a specified position.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_reference fcppt::container::raw_vector< T, A >::operator[] ( size_type  _index) const

Returns a reference to the vector element at a specified position.

template<typename T , typename A >
void fcppt::container::raw_vector< T, A >::pop_back ( )

Deletes the element at the end of the vector.

template<typename T, typename A >
void fcppt::container::raw_vector< T, A >::push_back ( T const &  t)

Add an element to the end of the vector.

Parameters
tThe element to add
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::reverse_iterator fcppt::container::raw_vector< T, A >::rbegin ( )

Returns an iterator to the first element in a reversed vector.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_reverse_iterator fcppt::container::raw_vector< T, A >::rbegin ( ) const

Returns an iterator to the first element in a reversed vector.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::reverse_iterator fcppt::container::raw_vector< T, A >::rend ( )

Returns an iterator to the end of a reversed vector.

template<typename T , typename A >
fcppt::container::raw_vector< T, A >::const_reverse_iterator fcppt::container::raw_vector< T, A >::rend ( ) const

Returns an iterator to the end of a reversed vector.

template<typename T , typename A >
void fcppt::container::raw_vector< T, A >::reserve ( size_type  sz)

Reserves a minimum length of storage for a vector object.

Parameters
szThe new (storage) size
template<typename T, typename A >
void fcppt::container::raw_vector< T, A >::resize ( size_type  sz,
T const &  value = T() 
)

Erases the elements of the vector.

Parameters
szThe new size
valueThe value to assign to the new elements (if any)
template<typename T , typename A >
void fcppt::container::raw_vector< T, A >::resize_uninitialized ( size_type  sz)

The same as resize but doesn't initialize the newly created elements (if any)

Note
This function is not found in (C++03's) std::vector
template<typename T , typename A >
void fcppt::container::raw_vector< T, A >::shrink_to_fit ( )

Tries to shrink capacity() to fit size()

Note
This function is not found in (C++03's) std::vector
template<typename T , typename A >
fcppt::container::raw_vector< T, A >::size_type fcppt::container::raw_vector< T, A >::size ( ) const

Returns the number of elements in the vector.

template<typename T , typename A >
void fcppt::container::raw_vector< T, A >::swap ( raw_vector< T, A > &  _other)

Exchanges the elements of two vectors.