Reference documentation for deal.II version 9.0.0
|
#include <deal.II/base/aligned_vector.h>
Public Types | |
typedef T | value_type |
Public Member Functions | |
AlignedVector () | |
AlignedVector (const size_type size, const T &init=T()) | |
~AlignedVector () | |
AlignedVector (const AlignedVector< T > &vec) | |
AlignedVector (AlignedVector< T > &&vec) noexcept | |
AlignedVector & | operator= (const AlignedVector< T > &vec) |
AlignedVector & | operator= (AlignedVector< T > &&vec) noexcept |
void | resize_fast (const size_type size) |
void | resize (const size_type size_in) |
void | resize (const size_type size_in, const T &init) |
void | reserve (const size_type size_alloc) |
void | clear () |
void | push_back (const T in_data) |
reference | back () |
const_reference | back () const |
template<typename ForwardIterator > | |
void | insert_back (ForwardIterator begin, ForwardIterator end) |
void | fill () |
void | fill (const T &element) |
void | swap (AlignedVector< T > &vec) |
bool | empty () const |
size_type | size () const |
size_type | capacity () const |
reference | operator[] (const size_type index) |
const_reference | operator[] (const size_type index) const |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
size_type | memory_consumption () const |
template<class Archive > | |
void | save (Archive &ar, const unsigned int version) const |
template<class Archive > | |
void | load (Archive &ar, const unsigned int version) |
Private Attributes | |
T * | _data |
T * | _end_data |
T * | _end_allocated |
Related Functions | |
(Note that these are not member functions.) | |
template<class T > | |
bool | operator== (const AlignedVector< T > &lhs, const AlignedVector< T > &rhs) |
template<class T > | |
bool | operator!= (const AlignedVector< T > &lhs, const AlignedVector< T > &rhs) |
This is a replacement class for std::vector to be used in combination with VectorizedArray and derived data types. It allocates memory aligned to addresses of a vectorized data type (in order to avoid segmentation faults when a variable of type VectorizedArray which the compiler assumes to be aligned to certain memory addresses does not actually follow these rules). This could also be achieved by proving std::vector with a user-defined allocator. On the other hand, writing an own small vector class lets us implement parallel copy and move operations with TBB, insert deal.II-style assertions, and cut some unnecessary functionality. Note that this vector is a bit more memory-consuming than std::vector because of alignment, so it is recommended to only use this vector on long vectors.
author
Katharina Kormann, Martin Kronbichler, 2011
Definition at line 60 of file aligned_vector.h.
typedef T AlignedVector< T >::value_type |
Declare standard types used in all containers. These types parallel those in the C++
standard libraries vector<...>
class.
Definition at line 67 of file aligned_vector.h.
AlignedVector< T >::AlignedVector | ( | ) |
Empty constructor. Sets the vector size to zero.
AlignedVector< T >::AlignedVector | ( | const size_type | size, |
const T & | init = T() |
||
) |
Set the vector size to the given size and initializes all elements with T().
AlignedVector< T >::~AlignedVector | ( | ) |
Destructor.
AlignedVector< T >::AlignedVector | ( | const AlignedVector< T > & | vec | ) |
Copy constructor.
|
noexcept |
Move constructor. Create a new aligned vector by stealing the contents of vec
.
AlignedVector& AlignedVector< T >::operator= | ( | const AlignedVector< T > & | vec | ) |
Assignment to the input vector vec
.
|
noexcept |
Move assignment operator.
void AlignedVector< T >::resize_fast | ( | const size_type | size | ) |
Change the size of the vector. It keeps old elements previously available but does not initialize the newly allocated memory, leaving it in an undefined state.
T
that define a default constructor, T()
. Otherwise, compilation will fail. void AlignedVector< T >::resize | ( | const size_type | size_in | ) |
Change the size of the vector. It keeps old elements previously available, and initializes each newly added element to a default-constructed object of type T
.
If the new vector size is shorter than the old one, the memory is not immediately released unless the new size is zero; however, the size of the current object is of course set to the requested value.
void AlignedVector< T >::resize | ( | const size_type | size_in, |
const T & | init | ||
) |
Change the size of the vector. It keeps old elements previously available, and initializes each newly added element with the provided initializer.
If the new vector size is shorter than the old one, the memory is not immediately released unless the new size is zero; however, the size of the current object is of course set to the requested value.
void AlignedVector< T >::reserve | ( | const size_type | size_alloc | ) |
Reserve memory space for size
elements. If the argument size
is set to zero, all previously allocated memory is released.
In order to avoid too frequent reallocation (which involves copy of the data), this function doubles the amount of memory occupied when the given size is larger than the previously allocated size.
void AlignedVector< T >::clear | ( | ) |
Releases all previously allocated memory and leaves the vector in a state equivalent to the state after the default constructor has been called.
void AlignedVector< T >::push_back | ( | const T | in_data | ) |
Inserts an element at the end of the vector, increasing the vector size by one. Note that the allocated size will double whenever the previous space is not enough to hold the new element.
reference AlignedVector< T >::back | ( | ) |
Return the last element of the vector (read and write access).
const_reference AlignedVector< T >::back | ( | ) | const |
Return the last element of the vector (read-only access).
void AlignedVector< T >::insert_back | ( | ForwardIterator | begin, |
ForwardIterator | end | ||
) |
Inserts several elements at the end of the vector given by a range of elements.
void AlignedVector< T >::fill | ( | ) |
Fills the vector with size() copies of a default constructed object.
void AlignedVector< T >::fill | ( | const T & | element | ) |
Fills the vector with size() copies of the given input.
void AlignedVector< T >::swap | ( | AlignedVector< T > & | vec | ) |
Swaps the given vector with the calling vector.
bool AlignedVector< T >::empty | ( | ) | const |
Return whether the vector is empty, i.e., its size is zero.
size_type AlignedVector< T >::size | ( | ) | const |
Return the size of the vector.
size_type AlignedVector< T >::capacity | ( | ) | const |
Return the capacity of the vector, i.e., the size this vector can hold without reallocation. Note that capacity() >= size().
reference AlignedVector< T >::operator[] | ( | const size_type | index | ) |
Read-write access to entry index
in the vector.
const_reference AlignedVector< T >::operator[] | ( | const size_type | index | ) | const |
Read-only access to entry index
in the vector.
iterator AlignedVector< T >::begin | ( | ) |
Return a read and write pointer to the beginning of the data array.
iterator AlignedVector< T >::end | ( | ) |
Return a read and write pointer to the end of the data array.
const_iterator AlignedVector< T >::begin | ( | ) | const |
Return a read-only pointer to the beginning of the data array.
const_iterator AlignedVector< T >::end | ( | ) | const |
Return a read-only pointer to the end of the data array.
size_type AlignedVector< T >::memory_consumption | ( | ) | const |
Return the memory consumption of the allocated memory in this class. If the underlying type T
allocates memory by itself, this memory is not counted.
void AlignedVector< T >::save | ( | Archive & | ar, |
const unsigned int | version | ||
) | const |
Write the data of this object to a stream for the purpose of serialization.
void AlignedVector< T >::load | ( | Archive & | ar, |
const unsigned int | version | ||
) |
Read the data of this object from a stream for the purpose of serialization.
|
related |
Relational operator == for AlignedVector
Definition at line 1118 of file aligned_vector.h.
|
related |
Relational operator != for AlignedVector
Definition at line 1139 of file aligned_vector.h.
|
private |
Pointer to actual class data.
Definition at line 306 of file aligned_vector.h.
|
private |
Pointer to the end of valid data fields.
Definition at line 311 of file aligned_vector.h.
|
private |
Pointer to the end of the allocated memory.
Definition at line 316 of file aligned_vector.h.