The templated class unbounded_array<T, ALLOC>
implements a unbounded storage array using an allocator.
The unbounded array is similar to a std::vector
in that in can grow in size beyond any fixed bound.
However unbounded_array
is aimed at optimal performance. Therefore unbounded_array
does not model a
Sequence
like std::vector
does.
When resized unbounded_array
will reallocate it's storage even if the new size requirement is smaller. It is therefore inefficient to resize a unbounded_array
#include <boost/numeric/ublas/storage.hpp> int main () { using namespace boost::numeric::ublas; unbounded_array<double> a (3); for (unsigned i = 0; i < a.size (); ++ i) { a [i] = i; std::cout << a [i] << std::endl; } }
Defined in the header storage.hpp.
Parameter | Description | Default |
---|---|---|
T |
The type of object stored in the array. | |
ALLOC |
An STL Allocator | std::allocator |
None, except for those imposed by the requirements of Random Access Container.
None.
Member | Where defined | Description |
---|---|---|
value_type | Container | |
pointer | Container | Currently defined as value_type* |
const_pointer | Currently defined as value_type* | |
reference | Container | Currently defined as value_type& |
const_reference | Container | Currently defined as const value_type& |
size_type | Container | Currently defined as Alloc::size_type |
difference_type | Container | Currently defined as Alloc::difference_type |
iterator | Container | Currently defined as pointer |
const_iterator | Container | Currently defined as const_pointer |
revere_iterator | Container | Currently defined as std::reverse_iterator<iterator> |
const_revere_iterator | Container | Currently defined as std::reverse_iterator<const_iterator> |
allocator_type | Defined as ALLOC | |
explicit unbounded_array (ALLOC &a = ALLOC()) |
Storage | Creates an unbounded_array that holds at most zero elements, using a specified allocator. |
explicit unbounded_array (size_type size, ALLOC &a = ALLOC()) |
Storage | Creates a uninitialized unbounded_array that holds at most size elements, using a specified allocator. All the elements are constructed without an initializer. |
explicit unbounded_array (size_type size, const T& init, ALLOC& a = ALLOC()) |
Storage | Creates an initialized unbounded_array that holds at most size elements, using a specified allocator. All the elements are constructed from the init value. |
unbounded_array (const unbounded_array &a) |
Container | The copy constructor. |
~unbounded_array () |
Container | Deallocates the unbounded_array itself. |
void resize (size_type n , bool preserve = true) |
Storage | Reallocates an unbounded_array to hold at most n elements. When preserve == false the elements values after resize are undefined. |
void resize(size_type n, const T& t) |
Storage | Reallocates an unbounded_array to hold at most n elements.
|
size_type size () const |
Container | Returns the size of the unbounded_array . |
const_reference operator [] (size_type i) const |
Container | Returns a const reference of the i -th element. |
reference operator [] (size_type i) |
Container | Returns a reference of the i -th element. |
unbounded_array &operator = (const unbounded_array &a) |
Container | The assignment operator. |
unbounded_array &assign_temporary (unbounded_array &a) |
Assigns a temporary. May change the array a . |
|
void swap (unbounded_array &a) |
Container | Swaps the contents of the arrays. |
const_iterator begin () const |
Container | Returns a const_iterator pointing to the beginning
of the unbounded_array . |
const_iterator end () const |
Container | Returns a const_iterator pointing to the end of
the unbounded_array . |
iterator begin () |
Container | Returns a iterator pointing to the beginning of
the unbounded_array . |
iterator end () |
Container | Returns a iterator pointing to the end of the
unbounded_array . |
const_reverse_iterator rbegin () const |
Reversible Container | Returns a const_reverse_iterator pointing to the beginning of the reversed unbounded_array . |
const_reverse_iterator rend () const |
Reversible Container | Returns a const_reverse_iterator pointing to the end of the reversed unbounded_array . |
reverse_iterator rbegin () |
Reversible Container | Returns a reverse_iterator pointing to the beginning of the reversed unbounded_array . |
reverse_iterator rend () |
Reversible Container | Returns a reverse_iterator pointing to the end of the reversed unbounded_array . |