35#ifndef CXXUTILS_ARRAY_H
36#define CXXUTILS_ARRAY_H
47template <
unsigned int N>
49template <
unsigned int N>
70template <
unsigned int N>
133template <
unsigned int N>
179 std::vector<unsigned int>
shape()
const;
187 unsigned int size (
unsigned int dim = 0)
const;
246 friend class Array<N+1>;
310 std::vector<unsigned int>
shape()
const;
321 unsigned int size (
unsigned int dim=0)
const;
360 friend class Array<1>;
369template <
unsigned int N>
390template <
unsigned int N>
644template <
unsigned int N>
771template <
unsigned int N>
803 requires std::assignable_from<T&, float>
812template <
unsigned int N>
Representation class for Array's.
Array()
Default constructor.
WritableArrayData(const unsigned int shape[])
Constructor.
WritableArray(Arrayrep &rep)
Constructor.
static const_iterator make_iterator(const Arrayrep *rep, unsigned int offs)
Construct an Array<1>::const_iterator.
const Arrayelt * const_iterator
Iterator type for an Array<1>.
Helper for defining iterators over Array's.
static const_iterator make_iterator(const Arrayrep *rep, unsigned int offs)
Construct an Array<N>::const_iterator.
ArrayIterator< N > const_iterator
Iterator type for an Array<N>.
Proxy to return from operator>.
const value_type * operator->() const
Dereference the proxy.
pointer(const ArrayIterator &i)
Proxy constructor.
value_type m_a
The contained Array proxy instance.
value_type operator*() const
Dereference the proxy.
Iterator class for Array<N>.
bool operator==(const ArrayIterator &other) const
Equality comparison.
const Arrayrep * m_rep
The underlying array representation.
value_type operator[](difference_type n) const
Array indexing relative to the iterator.
bool operator<(const ArrayIterator &other) const
Less-than comparison.
value_type operator*() const
Dereference the iterator.
ArrayIterator< N > & operator+=(difference_type n)
Advance the iterator.
bool operator<=(const ArrayIterator &other) const
Less-than-or-equal comparison.
ArrayIterator(const Arrayrep *rep, unsigned int offs)
Constructor from Arrayrep and offset.
ArrayIterator()
Default constructor.
bool operator>(const ArrayIterator &other) const
Greater-than comparison.
ArrayIterator< N > operator-(difference_type n) const
Return a new iterator pointing n steps behind.
const Array< N-1 > value_type
std::random_access_iterator_tag iterator_category
ArrayIterator< N > & operator--()
Back up the iterator.
ArrayIterator< N > operator+(difference_type n) const
Return a new iterator pointing n steps ahead.
pointer operator->() const
Dereference the iterator.
bool operator>=(const ArrayIterator &other) const
Greater-than-or-equal comparison.
bool operator!=(const ArrayIterator &other) const
Inequality comparison.
std::ptrdiff_t difference_type
ArrayIterator< N > & operator-=(difference_type n)
Back up the iterator.
unsigned int m_offs
Offset into the representation's data array of the first element referred to by this iterator.
ArrayIterator< N > & operator++()
Advance the iterator.
const Arrayelt * m_elt
Pointer to this array's single element.
std::vector< unsigned int > shape() const
Return the array shape.
Array()
Default constructor.
void write_array(std::ostream &stream) const
Creates a text representation of the array content.
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
Array(const Arrayrep &rep, unsigned int offs)
Private constructor for array indexing.
Array(const Arrayrep &rep)
Constructor.
bool valid() const
Test for validity.
int asint() const
Convert to an integer.
Read-only multidimensional array.
Array(const Arrayrep &rep, unsigned int offs)
Private constructor for array indexing.
Array()
Default constructor.
Array(const Arrayrep &rep)
Constructor.
Array< N-1 > operator[](unsigned int i) const
Array indexing.
void write_array(std::ostream &stream) const
Creates a text representation of the array content.
const Arrayelt * ptr() const
Return a direct pointer to array elements.
std::vector< unsigned int > shape() const
Return the array shape.
const_iterator end() const
Return an iterator pointing past the end of the container.
const_iterator begin() const
Return an iterator pointing at the beginning of the container.
bool valid() const
Test for validity.
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
const Arrayrep * m_rep
Pointer to the representation.
ArrayIteratorChooser< N >::const_iterator const_iterator
The iterator for this container.
unsigned int m_offs
Offset in the Arrayrep's data of the first element of this array.
WritableArrayData(const std::vector< unsigned int > &shape)
Constructor.
WritableArrayData(const unsigned int shape[])
Constructor.
WritableArray(Arrayrep &rep, unsigned int offs)
Private constructor for array indexing.
WritableArray(Arrayrep &rep)
Constructor.
Arrayelt * m_elt_nc
Pointer to this array's single element, non-const copy.
Read-write multidimensional array.
Arrayelt * ptr()
Return a direct pointer to array elements.
WritableArray(Arrayrep &rep, unsigned int offs)
Private constructor for array indexing.
WritableArray< N-1 > operator[](unsigned int i)
Array indexing.
WritableArray(Arrayrep &rep)
Constructor.
Arrayrep * m_rep_nc
The underlying array representation, non-const copy.
Concept testing whether a type may be used with FromArrayrep.
Namespace for helper functions.
float Arrayelt
The type of an element of an Array.
std::ostream & operator<<(std::ostream &s, const Array< N > &a)
void fromArrayrep(const CaloRec::Arrayrep &rep, T &x)
Helper to convert from an @x Arrayrep to a scalar type.
Representation class for Array's.
Arrayrep()
Default constructor.