Fixed size container with a few bells and whistles. More...
#include <array_no_mem_check.hpp>
Public Types | |
typedef const Type * | const_iterator |
typedef const Type & | const_reference |
typedef std::reverse_iterator< const_iterator > | const_reverse_iterator |
typedef std::ptrdiff_t | difference_type |
typedef blueprints::ArrayFactory< value_type, Size > | Factory |
Generates blueprints for this class. More... | |
typedef formatters::ArrayFormatter< Type, Size > | Formatter |
Formatter for this class. More... | |
typedef Type * | iterator |
typedef Type & | reference |
typedef std::reverse_iterator< iterator > | reverse_iterator |
typedef std::size_t | size_type |
typedef Type | value_type |
Public Member Functions | |
Array () | |
template<typename T > | |
Array (const blueprints::ArrayBluePrint< T > &blueprint) | |
Blueprint constructor. More... | |
reference | at (size_type i) |
const_reference | at (size_type i) const |
reference | back () |
const_reference | back () const |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
reference | front () |
const_reference | front () const |
containers::BoundedListInitialiser< Type, Type *, Size > | operator<< (const Type &value) |
reference | operator[] (size_type i) |
const_reference | operator[] (size_type i) const |
reverse_iterator | rbegin () |
const_reverse_iterator | rbegin () const |
reverse_iterator | rend () |
const_reverse_iterator | rend () const |
Stencil< Array< Type, Size > > | stencil (const unsigned int &start_index, const unsigned int &n) |
Open a window (stencil) onto the array. More... | |
virtual | ~Array () |
Public Member Functions inherited from ecl::blueprints::ArrayFactory< Type, Size > | |
virtual | ~ArrayFactory () |
Static Public Member Functions | |
static size_type | size () |
Static Public Member Functions inherited from ecl::blueprints::ArrayFactory< Type, Size > | |
static ConstantArray< Type, Size > | Constant (const Type &value) |
Private Attributes | |
value_type | elements [Size] |
Friends | |
template<typename OutputStream , typename ElementType , size_t ArraySize> | |
OutputStream & | operator<< (OutputStream &ostream, const Array< ElementType, ArraySize > &array) |
Fixed size container with a few bells and whistles.
All of the stl arrays are dynamically sizable, which means they are stored on the heap which is generally much slower for access/write operations than one which is stored on the stack. However, the stl provides no option for a fixed size container which take advantage of this, so this class provides that option. Essentially, its simply a fixed size array with a few bells and whistles.
Initialisation
We use the comma initialiser (similar to that used in Blitz++ and Eigen2) here for convenient initialisation. However there are other mechanisms, the most interesting of which is Boost's Array class which uses a normal aggregate initialiser (like that of a struct with curly braces). I did some tests to compare the performance of both, and both perform similarly. Since there was no real difference in performance I chose the comma initialiser here as it can also be used after construction and will provide a consistent means of initialisation seeing as we also use Eigen in the Math module. If you're in for strict c++ layouts, then the comma initialiser also lets you hide the base c array as a private member (the aggregate initialiser only works when your base c array is a public member).
Error Handling
Arrays will throw exceptions whenever an operation performs an out of range operation. For most operations, this will only occur in debug mode, so release mode will run at full speed. The only exception to this is the accessor function, which provides a handle that will always throw if safety is always required.
Type | : the type of the element stored in the array. |
Definition at line 106 of file array_no_mem_check.hpp.
typedef const Type* ecl::Array< Type, Size >::const_iterator |
Array's constant iterator type.
Definition at line 113 of file array_no_mem_check.hpp.
typedef const Type& ecl::Array< Type, Size >::const_reference |
Array's element const reference type.
Definition at line 115 of file array_no_mem_check.hpp.
typedef std::reverse_iterator<const_iterator> ecl::Array< Type, Size >::const_reverse_iterator |
Array's constant reverse iterator type.
Definition at line 119 of file array_no_mem_check.hpp.
typedef std::ptrdiff_t ecl::Array< Type, Size >::difference_type |
Definition at line 117 of file array_no_mem_check.hpp.
typedef blueprints::ArrayFactory<value_type,Size> ecl::Array< Type, Size >::Factory |
Generates blueprints for this class.
Definition at line 120 of file array_no_mem_check.hpp.
typedef formatters::ArrayFormatter<Type,Size> ecl::Array< Type, Size >::Formatter |
Formatter for this class.
Definition at line 121 of file array_no_mem_check.hpp.
typedef Type* ecl::Array< Type, Size >::iterator |
Array's iterator type.
Definition at line 112 of file array_no_mem_check.hpp.
typedef Type& ecl::Array< Type, Size >::reference |
Array's element reference type.
Definition at line 114 of file array_no_mem_check.hpp.
typedef std::reverse_iterator<iterator> ecl::Array< Type, Size >::reverse_iterator |
Array's reverse iterator type.
Definition at line 118 of file array_no_mem_check.hpp.
typedef std::size_t ecl::Array< Type, Size >::size_type |
Array's type used to denote the length of the array.
Definition at line 116 of file array_no_mem_check.hpp.
typedef Type ecl::Array< Type, Size >::value_type |
Array's element type.
Definition at line 111 of file array_no_mem_check.hpp.
|
inline |
Default constructor that simply allocates memory, but leaves all the element uninitialised.
Definition at line 130 of file array_no_mem_check.hpp.
|
inline |
Blueprint constructor.
Constructor that allows automatic generation of the array from an existing blueprint. This can be used simply in the following manner for any static element belonging to the BluePrintFactory.
Since this is not explicit, it will also allow assignment.
This will emit a compile time failure if the template argument does not conform to the blueprint concept (refer to ecl_concepts documentation).
blueprint | : the blue print to use to generate this instance. |
Definition at line 154 of file array_no_mem_check.hpp.
|
inlinevirtual |
Definition at line 159 of file array_no_mem_check.hpp.
|
inline |
Accesses elements in the array, returning references to the requested element. This accessor always does range checks. Compare this with the [] accessor which only checks if NDEBUG is not defined.
i | : the index of the requested element. |
StandardException : throws if range is requested element is out of range. |
Definition at line 307 of file array_no_mem_check.hpp.
|
inline |
Accesses elements in the array, returning references to the requested element. This accessor always does range checks. Compare this with the [] accessor which only checks if NDEBUG is not defined. This also ensures the references are constant, which in turn ensures the contents cannot of the array cannot be modified.
i | : the index of the requested element. |
StandardException : throws if range is requested element is out of range. |
Definition at line 325 of file array_no_mem_check.hpp.
|
inline |
Generates an reference to the last element in the array.
Definition at line 242 of file array_no_mem_check.hpp.
|
inline |
Generates a constant reference to the last element in the array (cannot change the value).
Definition at line 247 of file array_no_mem_check.hpp.
|
inline |
Generates a pointer (iterator) pointing to the start of the array.
Definition at line 188 of file array_no_mem_check.hpp.
|
inline |
Generates a const pointer (iterator) pointing to the start of the array.
Definition at line 193 of file array_no_mem_check.hpp.
|
inline |
Generates an pointer (iterator) pointing to the end of the array.
Definition at line 198 of file array_no_mem_check.hpp.
|
inline |
Generates a const pointer (iterator) pointing to the end of the array.
Definition at line 203 of file array_no_mem_check.hpp.
|
inline |
Generates an reference to the first element in the array.
Definition at line 232 of file array_no_mem_check.hpp.
|
inline |
Generates a constant reference to the first element in the array (cannot change the value).
Definition at line 237 of file array_no_mem_check.hpp.
|
inline |
Provides a comma initialisation facility. This initiates the comma initialiser with an iterator to the underlying array and then leaves the initialiser to do the rest. The initialiser will do range checking if NDEBUG is not defined.
value | : the first value to enter , ElementType, ArraySizeinto the array. |
Definition at line 177 of file array_no_mem_check.hpp.
|
inline |
Accesses elements in the array, returning references to the requested element. This accessor only does range checks in debug mode (NDEBUG is not defined). Compare this with the at() accessor which always checks if the range is exceeded.
StandardException : throws if range is requested element is out of range [debug mode only]. |
Definition at line 278 of file array_no_mem_check.hpp.
|
inline |
Accesses elements in the array, returning references to the requested element. This accessor only does range checks in debug mode (NDEBUG is not defined). Compare this with the at() accessor which always checks if the range is exceeded. This also ensures the references are constant, which in turn ensures the contents cannot of the array cannot be modified.
StandardException : throws if range is requested element is out of range [debug mode only]. |
Definition at line 293 of file array_no_mem_check.hpp.
|
inline |
Generates a reverse iterator pointing to the end of the array.
Definition at line 208 of file array_no_mem_check.hpp.
|
inline |
Generates a constant reverse iterator pointing to the end of the array.
Definition at line 213 of file array_no_mem_check.hpp.
|
inline |
Generates a reverse iterator pointing to the beginning of the array.
Definition at line 218 of file array_no_mem_check.hpp.
|
inline |
Generates a constant reverse iterator pointing to the beginning of the array.
Definition at line 223 of file array_no_mem_check.hpp.
|
inlinestatic |
The size of the array. Since the array storage is fixed, this need only be a static method for the whole class.
Definition at line 340 of file array_no_mem_check.hpp.
|
inline |
Open a window (stencil) onto the array.
Opens a window onto the array, providing a similar container-like class to manipulate.
start_index | : start of the stencil window. |
n | : number of elements to include in the window. |
StandardException : throws if the indices provided are out of range [debug mode only]. |
Definition at line 263 of file array_no_mem_check.hpp.
|
friend |
Insertion operator for sending the array to an output stream. This is raw, and has no formatting.
ostream | : the output stream. |
array | : the array to be inserted. |
Definition at line 364 of file array_no_mem_check.hpp.
|
private |
Definition at line 356 of file array_no_mem_check.hpp.