|
| Array () |
|
| Alloc::alloc (n)) |
|
| Array (size_t n, T const *const x) |
|
| Array (Array< T > const &a) |
|
| Array (const ArrayView< T > a) |
|
| Array (Array< T > &&a) |
|
| Array (std::vector< T > const &a) |
|
| Array (std::initializer_list< T > a) |
|
template<typename ForwardIterator > |
| Array (ForwardIterator i, ForwardIterator j) |
|
| ~Array () |
|
size_t | size () const |
| Return number of elements. More...
|
|
virtual size_t | resize (size_t n) |
| Resize array. More...
|
|
T & | operator[] (size_t i) |
| Element-wise access (non-const). More...
|
|
T const & | operator[] (size_t i) const |
| Element-wise access (const). More...
|
|
iterator | begin () |
|
const_iterator | begin () const |
|
iterator | end () |
|
const_iterator | end () const |
|
T & | front (int i=0) |
|
T const & | front (int i=0) const |
|
T & | back (int i=0) |
|
T const & | back (int i=0) const |
|
virtual void | push_back (T const &a) |
| Append an element to the end. More...
|
|
virtual T | pop_back () |
| Remove the last element from the array. More...
|
|
template<class InputIterator > |
void | append (InputIterator first, InputIterator last) |
| Append more items. More...
|
|
void | insert (iterator it, T x) |
| Insert item. More...
|
|
bool | empty () const |
| Check that size equals to zero. More...
|
|
Array< T > & | operator= (Array< T > const &b) |
|
Array< T > & | operator= (Array< T > &&b) |
|
|
virtual T * | data () |
| Data pointer. More...
|
|
virtual T const * | data () const |
|
| ArrayView () |
|
| ArrayView (size_t n, T *ptr) |
|
| ArrayView (ArrayView< T > const &a, size_t i=0, size_t n=0) |
|
| ArrayView (Array< T > const &a, size_t i=0, size_t n=0) |
|
| ArrayView (NumberArray< T > const &a, size_t i=0, size_t n=0) |
|
| ArrayView (const_iterator i, const_iterator j) |
|
| ArrayView (ArrayView< T > &&r) |
|
virtual | ~ArrayView () |
|
ArrayView< T > & | operator= (const ArrayView< T > v) |
| Assignment operator. More...
|
|
T & | operator[] (size_t i) |
| Element-wise access (non-const). More...
|
|
T const & | operator[] (size_t i) const |
| Element-wise access (const). More...
|
|
size_t | size () const |
| Length of the array (number of elements). More...
|
|
iterator | begin () |
|
const_iterator | begin () const |
|
iterator | end () |
|
const_iterator | end () const |
|
T & | front (int i=0) |
|
T const & | front (int i=0) const |
|
T & | back (int i=0) |
|
T const & | back (int i=0) const |
|
void | fill (T x) |
| Fill the array with a value. More...
|
|
bool | empty () const |
| Check whether the size is equal to zero. More...
|
|
template<class = typename std::enable_if<is_scalar<T>::value>> |
double | norm () const |
| Two-norm (defined only for scalar data type). More...
|
|
template<class T, class Alloc = PlainAllocator<T>>
class Array< T, Alloc >
Class Array is intended as a Hex's replacement for std::vector<T>. Properties:
- User specified allocator (given as the second template argument of the class). See PlainAllocator and AlignedAllocator for examples of such allocators. Allocator is expected to have two static methods: void* alloc(size_t) that returns a pointer to new memory chunk and void free() which deallocates the pointer.
- Basic iterator interface simillar to STL containers – methods begin(), end(), and thus also the ability to appear in the range-based for loops.
template<class T, class Alloc = PlainAllocator<T>>
virtual T Array< T, Alloc >::pop_back |
( |
| ) |
|
|
inlinevirtual |
The last element of the array will be ignored, which is achieved by decrementing array length. The memory will not be deallocated to save processor time. For this reason, if an array is "erased" by subsequent calls to pop_back, it will still occupy the same memory as before. The deallocation will take place only on resize.
Reimplemented in NumberArray< T, Alloc >.
template<class T, class Alloc = PlainAllocator<T>>
virtual void Array< T, Alloc >::push_back |
( |
T const & |
a | ) |
|
|
inlinevirtual |
The function will append the element "a" to the end of the array. This will require allocation of a longer array and copy of the original elements to the new array (using the rvalue reference). The function is declared as virtual so that it can be safely overridden in derived classes.
Reimplemented in NumberArray< T, Alloc >.
template<class T, class Alloc = PlainAllocator<T>>
virtual size_t Array< T, Alloc >::resize |
( |
size_t |
n | ) |
|
|
inlinevirtual |
The method will change the length of the array, most probably by reallocating the storage. The possible new elements will be initialized to T(0). The function is virtual, so that is can be safely overridden in the derived classes.
Reimplemented in NumberArray< T, Alloc >.