Bounded Array Storage

Bounded Array<T,N,Alloc>

Description

The templated class bounded_array<T, N, ALLOC> implements a bounded storage array. The bounded array is similar to a C++ array type in that its maximum size is bounded by N and is allocated on the stack instead of the heap. Similarly a bounded_array requires no secondary storage and ALLOC is only used to specifysize_type and difference_type.

When resized bounded_array uses the same storage with the same bound!. It is therefore efficient to resize a bounded_array

Example

#include <boost/numeric/ublas/storage.hpp>

int main () {
    using namespace boost::numeric::ublas;
    bounded_array<double, 3> a (3);
    for (unsigned i = 0; i < a.size (); ++ i) {
        a [i] = i;
        std::cout << a [i] << std::endl;
    }
}

Definition

Defined in the header storage.hpp.

Template parameters

Parameter Description Default
T The type of object stored in the array.
N The allocation size of the array.
ALLOC An STL Allocator std::allocator

Model of

Random Access Container.

Type requirements

None, except for those imposed by the requirements of Random Access Container.

Public base classes

None.

Members

Editor's notes:
Member Where defined Description
value_typeContainer
pointerContainerCurrently defined as value_type*
const_pointerCurrently defined as value_type*
referenceContainerCurrently defined as value_type&
const_referenceContainerCurrently defined as const value_type&
size_typeContainerCurrently defined as Alloc::size_type
difference_typeContainerCurrently defined as Alloc::difference_type
iteratorContainerCurrently defined as pointer
const_iteratorContainerCurrently defined as const_pointer
revere_iteratorContainerCurrently defined as std::reverse_iterator<iterator>
const_revere_iteratorContainerCurrently defined as std::reverse_iterator<const_iterator>
bounded_array () Creates a bounded_array that holds at most ZERO elements.
explicit bounded_array (size_type size, const T& = init) Storage Creates an initialized bounded_array that holds at most size elements. All the elements are constructed from the init value.
bounded_array (size_type size) Storage Creates an uninitialized bounded_array that holds at most size elements. All the elements are default constructed.
bounded_array (size_type size, const T& init) Storage Creates an bounded_array that holds at most size elements. All the elements are copy-constructed from init.
bounded_array (const bounded_array &c) Container The copy constructor.
~bounded_array () Container Deallocates the bounded_array itself.
void resize (size_type size) Storage Reallocates a bounded_array to hold at most size elements.
void resize (size_type size, const T& t) Storage Reallocates a bounded_array to hold at most size elements.
size_type size () const Container Returns the size of the bounded_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.
bounded_array &operator = (const bounded_array &a) Container The assignment operator.
bounded_array &assign_temporary (bounded_array &a) Assigns a temporary. May change the array a.
void swap (bounded_array &a) Container Swaps the contents of the arrays.
const_iterator begin () const Container Returns a const_iterator pointing to the beginning of the bounded_array.
const_iterator end () const Container Returns a const_iterator pointing to the end of the bounded_array.
iterator begin () Container Returns a iterator pointing to the beginning of the bounded_array.
iterator end () Container Returns a iterator pointing to the end of the bounded_array.
const_reverse_iterator rbegin () const Reversible Container Returns a const_reverse_iterator pointing to the beginning of the reversed bounded_array.
const_reverse_iterator rend () const Reversible Container Returns a const_reverse_iterator pointing to the end of the reversed bounded_array.
reverse_iterator rbegin () Reversible Container Returns a reverse_iterator pointing to the beginning of the reversed bounded_array.
reverse_iterator rend () Reversible Container Returns a reverse_iterator pointing to the end of the reversed bounded_array.