Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends
ecl::Array< Type, Size > Class Template Reference

Fixed size container with a few bells and whistles. More...

#include <array_no_mem_check.hpp>

Inheritance diagram for ecl::Array< Type, Size >:
Inheritance graph
[legend]

List of all members.

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.
typedef
formatters::ArrayFormatter
< Type, Size > 
Formatter
 Formatter for this class.
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.
reference at (size_type i) throw (StandardException)
const_reference at (size_type i) const throw (StandardException)
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) ecl_assert_throw_decl(StandardException)
const_reference operator[] (size_type i) const ecl_assert_throw_decl(StandardException)
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) ecl_assert_throw_decl(StandardException)
 Open a window (stencil) onto the array.
virtual ~Array ()

Static Public Member Functions

static size_type size ()

Private Attributes

value_type elements [Size]

Friends

template<typename OutputStream , typename ElementType , size_t ArraySize>
OutputStream & operator<< (OutputStream &ostream, const Array< ElementType, ArraySize > &array)

Detailed Description

template<typename Type, std::size_t Size = DynamicStorage>
class ecl::Array< Type, Size >

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).

 Array<int,4> array; // At this point it is uninitialised.
 array = 1,2,3,4;    // If NDEBUG is not defined, this will throw if you exceed the range.

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.

 int i = array[2];   // If NDEBUG is not defined, this will throw if you exceed the range.
 int i = array.at(2); // This will always throw if you exceed the range.
Template Parameters:
Type: the type of the element stored in the array.
See also:
BoundedListInitialiser, ArrayFactory.

Definition at line 106 of file array_no_mem_check.hpp.


Member Typedef Documentation

template<typename Type, std::size_t Size = DynamicStorage>
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.

template<typename Type, std::size_t Size = DynamicStorage>
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.

template<typename Type, std::size_t Size = DynamicStorage>
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.

template<typename Type, std::size_t Size = DynamicStorage>
typedef std::ptrdiff_t ecl::Array< Type, Size >::difference_type

Definition at line 117 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
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.

template<typename Type, std::size_t Size = DynamicStorage>
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.

template<typename Type, std::size_t Size = DynamicStorage>
typedef Type* ecl::Array< Type, Size >::iterator

Array's iterator type.

Definition at line 112 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
typedef Type& ecl::Array< Type, Size >::reference

Array's element reference type.

Definition at line 114 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
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.

template<typename Type, std::size_t Size = DynamicStorage>
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.

template<typename Type, std::size_t Size = DynamicStorage>
typedef Type ecl::Array< Type, Size >::value_type

Array's element type.

Definition at line 111 of file array_no_mem_check.hpp.


Constructor & Destructor Documentation

template<typename Type, std::size_t Size = DynamicStorage>
ecl::Array< Type, Size >::Array ( ) [inline]

Default constructor that simply allocates memory, but leaves all the element uninitialised.

Definition at line 130 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
template<typename T >
ecl::Array< Type, Size >::Array ( const blueprints::ArrayBluePrint< T > &  blueprint) [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.

 Array<int,4> array = Array<int,4>::Constant(3);

Since this is not explicit, it will also allow assignment.

 Array<int,4> array;
 array = Array<int,4>::Constant(3);

This will emit a compile time failure if the template argument does not conform to the blueprint concept (refer to ecl_concepts documentation).

Parameters:
blueprint: the blue print to use to generate this instance.
See also:
ArrayFactory.

Definition at line 154 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
virtual ecl::Array< Type, Size >::~Array ( ) [inline, virtual]

Definition at line 159 of file array_no_mem_check.hpp.


Member Function Documentation

template<typename Type, std::size_t Size = DynamicStorage>
reference ecl::Array< Type, Size >::at ( size_type  i) throw (StandardException) [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.

Parameters:
i: the index of the requested element.
Returns:
reference : a reference to the requested element.
Exceptions:
:StandardException : throws if range is requested element is out of range.

Definition at line 307 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
const_reference ecl::Array< Type, Size >::at ( size_type  i) const throw (StandardException) [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.

Parameters:
i: the index of the requested element.
Returns:
const_reference : a const_reference to the requested element.
Exceptions:
:StandardException : throws if range is requested element is out of range.

Definition at line 325 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
reference ecl::Array< Type, Size >::back ( ) [inline]

Generates an reference to the last element in the array.

Returns:
reference : reference to the last element in the array.

Definition at line 242 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
const_reference ecl::Array< Type, Size >::back ( ) const [inline]

Generates a constant reference to the last element in the array (cannot change the value).

Returns:
const_reference : const_reference to the last element in the array.

Definition at line 247 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
iterator ecl::Array< Type, Size >::begin ( ) [inline]

Generates a pointer (iterator) pointing to the start of the array.

Returns:
iterator : points to the beginning of the array.

Definition at line 188 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
const_iterator ecl::Array< Type, Size >::begin ( ) const [inline]

Generates a const pointer (iterator) pointing to the start of the array.

Returns:
const_iterator : constant pointer (iterator) pointing to the end of the array.

Definition at line 193 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
iterator ecl::Array< Type, Size >::end ( ) [inline]

Generates an pointer (iterator) pointing to the end of the array.

Returns:
iterator : points to the end of the array.

Definition at line 198 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
const_iterator ecl::Array< Type, Size >::end ( ) const [inline]

Generates a const pointer (iterator) pointing to the end of the array.

Returns:
const_iterator : constant pointer (iterator) pointing to the end of the array.

Definition at line 203 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
reference ecl::Array< Type, Size >::front ( ) [inline]

Generates an reference to the first element in the array.

Returns:
reference : reference to the first element in the array.

Definition at line 232 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
const_reference ecl::Array< Type, Size >::front ( ) const [inline]

Generates a constant reference to the first element in the array (cannot change the value).

Returns:
const_reference : const_reference to the first element in the array.

Definition at line 237 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
containers::BoundedListInitialiser<Type,Type*,Size> ecl::Array< Type, Size >::operator<< ( const Type &  value) [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.

 Array<int,4> array; // At this point it is uninitialised.
 array << 1,2,3,4;    // If NDEBUG is not defined, this will throw if you exceed the range.
Parameters:
value: the first value to enter , ElementType, ArraySizeinto the array.
Returns:
BoundedListInitialiser : the comma initialiser mechanism.

Definition at line 177 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
reference ecl::Array< Type, Size >::operator[] ( size_type  i) [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.

Returns:
reference : a reference to the requested element.
Exceptions:
: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.

template<typename Type, std::size_t Size = DynamicStorage>
const_reference ecl::Array< Type, Size >::operator[] ( size_type  i) const [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.

Returns:
const_reference : a constant reference to the requested element.
Exceptions:
: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.

template<typename Type, std::size_t Size = DynamicStorage>
reverse_iterator ecl::Array< Type, Size >::rbegin ( ) [inline]

Generates a reverse iterator pointing to the end of the array.

Returns:
reverse_iterator : points to the end of the array.

Definition at line 208 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
const_reverse_iterator ecl::Array< Type, Size >::rbegin ( ) const [inline]

Generates a constant reverse iterator pointing to the end of the array.

Returns:
const_reverse_iterator : constant reverse iterator pointing to the end of the array.

Definition at line 213 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
reverse_iterator ecl::Array< Type, Size >::rend ( ) [inline]

Generates a reverse iterator pointing to the beginning of the array.

Returns:
reverse_iterator : points to the beginning of the array.

Definition at line 218 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
const_reverse_iterator ecl::Array< Type, Size >::rend ( ) const [inline]

Generates a constant reverse iterator pointing to the beginning of the array.

Returns:
const_reverse_iterator : constant reverse iterator pointing to the beginning of the array.

Definition at line 223 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
static size_type ecl::Array< Type, Size >::size ( ) [inline, static]

The size of the array. Since the array storage is fixed, this need only be a static method for the whole class.

Returns:
size_type : the size of the array.

Definition at line 340 of file array_no_mem_check.hpp.

template<typename Type, std::size_t Size = DynamicStorage>
Stencil< Array<Type,Size> > ecl::Array< Type, Size >::stencil ( const unsigned int &  start_index,
const unsigned int &  n 
) [inline]

Open a window (stencil) onto the array.

Opens a window onto the array, providing a similar container-like class to manipulate.

Parameters:
start_index: start of the stencil window.
n: number of elements to include in the window.
Returns:
Stencil<Array> : the generated stencil.
Exceptions:
:StandardException : throws if the indices provided are out of range [debug mode only].

Definition at line 263 of file array_no_mem_check.hpp.


Friends And Related Function Documentation

template<typename Type, std::size_t Size = DynamicStorage>
template<typename OutputStream , typename ElementType , size_t ArraySize>
OutputStream& operator<< ( OutputStream &  ostream,
const Array< ElementType, ArraySize > &  array 
) [friend]

Insertion operator for sending the array to an output stream. This is raw, and has no formatting.

Parameters:
ostream: the output stream.
array: the array to be inserted.
Returns:
OutputStream : continue streaming with the updated output stream.

Definition at line 364 of file array_no_mem_check.hpp.


Member Data Documentation

template<typename Type, std::size_t Size = DynamicStorage>
value_type ecl::Array< Type, Size >::elements[Size] [private]

Definition at line 356 of file array_no_mem_check.hpp.


The documentation for this class was generated from the following file:


ecl_containers
Author(s): Daniel Stonier
autogenerated on Mon Jul 3 2017 02:21:42