CxxUtils::Array< N > Class Template Reference

Read-only multidimensional array. More...

#include <Array.h>

Inheritance diagram for CxxUtils::Array< N >:
CxxUtils::WritableArray< N > CxxUtils::WritableArrayData< N >

List of all members.

Public Types

enum  { NDIM = N }
 

The number of dimensions of the array.


typedef ArrayIteratorChooser
< N >::const_iterator 
const_iterator
 The iterator for this container.

Public Member Functions

 Array ()
 Default constructor.
 Array (const Arrayrep &rep)
 Constructor.
bool valid () const
 Test for validity.
std::vector< unsigned int > shape () const
 Return the array shape.
unsigned int size (unsigned int dim=0) const
 Return the size of the array along one dimension.
Array< N-1 > operator[] (unsigned int i) const
 Array indexing.
const Arrayelt * ptr () const
 Return a direct pointer to array elements.
const_iterator begin () const
 Return an iterator pointing at the beginning of the container.
const_iterator end () const
 Return an iterator pointing past the end of the container.

Protected Member Functions

 Array (const Arrayrep &rep, unsigned int offs)
 Private constructor for array indexing.

Protected Attributes

const Arrayrepm_rep
unsigned int m_offs
 Offset in the Arrayrep's data of the first element of this array.

Friends

class Array< N+1 >
class ArrayIterator< N+1 >

Detailed Description

template<unsigned int N>
class CxxUtils::Array< N >

Read-only multidimensional array.

A WriteableArray together with an Arrayrep.

Read-only multidimensional array, specialized for N=0.

Array<N> provides read-only access to an array. Indexing with [] returns an Array<N-1>. Array<0> is special; it doesn't support indexing, but does support implicit conversion to the element type, Arrayelt. The Array classes do not own their storage (and thus indexing does not require a complete copy). Rather, the complete data for the array are stored in an instance of Arrayrep. An Array holds a pointer to an Arrayrep and an offset into the data.

This is a specialization of Array for the case N=0, i.e., a scalar. It does not support indexing, but it does support implicit conversions to Arrayelt, as well as an explicit conversion to an integer.

This is a convenient way of creating from scratch an array to which you can write.


Constructor & Destructor Documentation

template<unsigned int N>
CxxUtils::Array< N >::Array (  )  [inline]

Default constructor.

This produces an invalid Array that is not associated with an Arrayrep. valid() will return false for such an array. The only other things that it is legal to do with an invalid array are to assign to it (which may make it valid) or request its size with size() (which will always return 0).

This produces an invalid Array that is not associated with an Arrayrep. valid() will return false for such an array. The only other thing that it is legal to do with an invalid array is to assign to it (which may make it valid).

template<unsigned int N>
CxxUtils::Array< N >::Array ( const Arrayrep rep  )  [inline]

Constructor.

Parameters:
rep Arrayrep from which to initialize the array.

Initialize an array from an Arrayrep. The new array will represent the entire Arrayrep. The dimension N must match the length of the Arrayrep's shape.

template<unsigned int N>
CxxUtils::Array< N >::Array ( const Arrayrep rep,
unsigned int  offs 
) [inline, protected]

Private constructor for array indexing.

Parameters:
rep Arrayrep from which to initialize the array.
offs Offset of the first element of the new array within rep.

This is a private constructor used to make the Array instances returned from an indexing operation.


Member Function Documentation

template<unsigned int N>
Array< N >::const_iterator CxxUtils::Array< N >::begin (  )  const [inline]

Return an iterator pointing at the beginning of the container.

Returns:
An iterator pointing at the beginning of the container.
template<unsigned int N>
Array< N >::const_iterator CxxUtils::Array< N >::end (  )  const [inline]

Return an iterator pointing past the end of the container.

Returns:
An iterator pointing past the end of the container.
template<unsigned int N>
Array< N-1 > CxxUtils::Array< N >::operator[] ( unsigned int  i  )  const [inline]

Array indexing.

Parameters:
i The desired index. Must be less than the array size along this dimension.
Returns:
The i'th N-1 dimensional subarray in the array.

Note that this operation is not available if N is 0.

Reimplemented in CxxUtils::WritableArray< N >.

template<unsigned int N>
const Arrayelt * CxxUtils::Array< N >::ptr (  )  const [inline]

Return a direct pointer to array elements.

Returns:
A pointer to the first array elements.

Subsequent elements follow in standard C indexing order.

template<unsigned int N>
std::vector< unsigned int > CxxUtils::Array< N >::shape (  )  const [inline]

Return the array shape.

Returns:
The array shape.

The array shape is vector with one element for each array dimension, giving the size of the array along that dimension.

template<unsigned int N>
unsigned int CxxUtils::Array< N >::size ( unsigned int  dim = 0  )  const [inline]

Return the size of the array along one dimension.

Parameters:
dim The dimension of the size to retrieve. Must be less than the number of dimensions.
Returns:
The array size along dimension .
Parameters:
dim The dimension of the size to retrieve. Must be less than the number of dimensions.

As a special case, the size of an invalid array will always be 0.

Returns:
The array size along dimension .
template<unsigned int N>
bool CxxUtils::Array< N >::valid (  )  const [inline]

Test for validity.

Returns:
True if the Array is associated with an Arrayrep, false if not.

Member Data Documentation

template<unsigned int N>
const Arrayrep* CxxUtils::Array< N >::m_rep [protected]

Pointer to the representation. Null if this instance was created using the default constructor.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 1 Dec 2017 for RootCore Packages by  doxygen 1.6.1