The interface to the container representation of arrays. More...
#include <ArrayContainer.h>
Public Types | |
| typedef types::value_type | value_type |
| The element type of the array. | |
| typedef types::parameter_type | parameter_type |
| The parameter type. | |
| typedef types::unqualified_value_type | unqualified_value_type |
| The unqualified value type. | |
| typedef types::pointer | pointer |
| A pointer to an array element. | |
| typedef types::const_pointer | const_pointer |
| A pointer to a constant array element. | |
| typedef types::iterator | iterator |
| An iterator in the array. | |
| typedef types::const_iterator | const_iterator |
| A iterator on constant elements in the array. | |
| typedef types::reference | reference |
| A reference to an array element. | |
| typedef types::const_reference | const_reference |
| A reference to a constant array element. | |
| typedef types::size_type | size_type |
| The size type is a signed integer. | |
| typedef types::difference_type | difference_type |
| Pointer difference type. | |
Public Member Functions | |
Accessors | |
| size_type | size () const |
| Return the size of the array. | |
| bool | empty () const |
| Return true if the array is empty. | |
| size_type | max_size () const |
| Return the size of the largest possible array. | |
| const_iterator | begin () const |
| Return a const iterator to the first value. | |
| const_iterator | end () const |
| Return a const iterator to one past the last value. | |
| pointer | data () const |
| Return a const pointer to the beginning of the data. | |
| parameter_type | operator[] (const int i) const |
| Return the i_th element. | |
| size_type | getMemoryUsage () const |
| Return the memory size. | |
Manipulators | |
| iterator | begin () |
| Return an iterator to the first value. | |
| iterator | end () |
| Return an iterator to one past the last value. | |
| pointer | data () |
| Return a pointer to the beginning of the data. | |
| reference | operator[] (const int i) |
| Return a reference to the element. | |
| void | negate () |
| Negate each component. | |
| void | fill (parameter_type value) |
Fill the array with the given value. | |
Assignment operators with scalar operand. | |
| ArrayContainer & | operator= (parameter_type x) |
Set each component to x. | |
Equality. | |
| template<typename T2 , bool A2> | |
| bool | operator== (const ArrayContainer< T2, A2 > &x) const |
| Return true if the arrays are equal. | |
| template<typename T2 , bool A2> | |
| bool | operator!= (const ArrayContainer< T2, A2 > &x) const |
| Return true if the arrays are not equal. | |
File I/O | |
| void | put (std::ostream &out) const |
| Write the elements in ascii format. Do not write the array size. | |
| void | get (std::istream &in) |
| Read the elements in ascii format. Do not read the array size. | |
| void | write (std::ostream &out) const |
| Write the elements in binary format. Do not write the array size. | |
| void | write_elements_ascii (std::ostream &out) const |
| Write the elements in ascii format. Do not write the array size. | |
| void | write_elements_binary (std::ostream &out) const |
| Write the elements in binary format. Do not write the array size. | |
| void | read (std::istream &in) |
| Read the elements in binary format. Do not read the array size. | |
| void | read_elements_ascii (std::istream &in) |
| Read the elements in ascii format. Do not read the array size. | |
| void | read_elements_binary (std::istream &in) |
| Read the elements in binary format. Do not read the array size. | |
Protected Member Functions | |
Constructors etc. | |
| ArrayContainer () | |
| Default constructor. | |
| ArrayContainer (const ArrayContainer &x) | |
| template<typename T2 , bool A2> | |
| ArrayContainer (const ArrayContainer< T2, A2 > &x) | |
| ArrayContainer & | operator= (const ArrayContainer &other) |
| Assignment operator. | |
| template<typename T2 , bool A2> | |
| ArrayContainer & | operator= (const ArrayContainer< T2, A2 > &x) |
| Assignment operator for an array of different type or allocation policy. | |
| template<typename ForwardIterator > | |
| ArrayContainer (ForwardIterator start, ForwardIterator finish) | |
| Construct from a range of elements. | |
| template<typename ForwardIterator > | |
| void | rebuild (ForwardIterator start, ForwardIterator finish) |
| Rebuild from a range of elements. | |
| template<typename Type > | |
| ArrayContainer (Type *start, Type *finish) | |
| Construct from a range of elements. | |
| template<typename Type > | |
| void | rebuild (Type *start, Type *finish) |
| Rebuild from a range of elements. | |
| ArrayContainer (const size_type size) | |
| Construct from the array size. | |
| void | rebuild (const size_type size) |
| Rebuild from the array size. | |
| void | swap (ArrayContainer &other) |
| Swaps data with another ArrayContainer. | |
| void | resize (const size_type size) |
| Resize the array container. | |
| ~ArrayContainer () | |
| Destructor. Delete memory if it was allocated. | |
The interface to the container representation of arrays.
| \c | T is the value type. By default it is double. | |
| \c | A determines whether the array will allocate memory for the elements or use externally allocated memory. By default A is true. |
This is a base class for all arrays.
| typedef types::parameter_type ArrayContainer< T, A >::parameter_type |
The parameter type.
This is used for passing the value type as an argument.
Reimplemented in Array< N, T, A >, Array< 1, T, A >, SparseArray< 1, T >, SparseArray< 2, T >, SparseArraySigned< 1, T >, StaticArrayOfArrays< T >, Array< 1, int >, Array< 1, iterator >, and Array< 1, container_type >.
| typedef types::size_type ArrayContainer< T, A >::size_type |
The size type is a signed integer.
Having std::size_t (which is an unsigned integer) as the size type causes minor problems. Consult "Large Scale C++ Software Design" by John Lakos for a discussion of using unsigned integers in a class interface.
Reimplemented in Array< N, T, A >, Array< 1, T, A >, SparseArray< 1, T >, SparseArray< 2, T >, SparseArraySigned< 1, T >, StaticArrayOfArrays< T >, Array< 1, int >, Array< 1, iterator >, and Array< 1, container_type >.
| typedef types::unqualified_value_type ArrayContainer< T, A >::unqualified_value_type |
The unqualified value type.
The value type with top level const and volatile qualifiers removed.
Reimplemented in Array< N, T, A >, Array< 1, T, A >, SparseArray< 1, T >, SparseArray< 2, T >, SparseArraySigned< 1, T >, StaticArrayOfArrays< T >, Array< 1, int >, Array< 1, iterator >, and Array< 1, container_type >.
| ArrayContainer< T, A >::ArrayContainer | ( | const ArrayContainer< T, A > & | x | ) | [inline, protected] |
If A is true, allocate memory and copy the elements. Otherwise, reference the data in x.
| ArrayContainer< T, A >::ArrayContainer | ( | const ArrayContainer< T2, A2 > & | x | ) | [inline, protected] |
If A is true, allocate memory and copy the elements. Otherwise, reference the data in x.
| ArrayContainer< T, A >::ArrayContainer | ( | ForwardIterator | start, | |
| ForwardIterator | finish | |||
| ) | [inline, protected] |
Construct from a range of elements.
This may only be used if A is true.
| ArrayContainer< T, A >::ArrayContainer | ( | Type * | start, | |
| Type * | finish | |||
| ) | [inline, protected] |
Construct from a range of elements.
This may be used if A is true or false.
| ArrayContainer< T, A >::ArrayContainer | ( | const size_type | size | ) | [inline, explicit, protected] |
Construct from the array size.
This constructor may only be called if A is true.
| pointer ArrayContainer< T, A >::data | ( | ) | const [inline] |
Return a const pointer to the beginning of the data.
Note that the return type is pointer. This is necessary for some of the copy constructors and assignment operators to work.
Referenced by Array< 1, container_type >::Array(), Array< 1, T, A >::operator=(), Array< 1, container_type >::operator=(), and Array< 1, T, A >::rebuild().
| size_type ArrayContainer< T, A >::getMemoryUsage | ( | ) | const [inline] |
Return the memory size.
Count the array memory whether we allocated it or not.
Reimplemented in Array< N, T, A >, Array< 1, T, A >, SparseArray< 1, T >, SparseArray< 2, T >, SparseArraySigned< 1, T >, StaticArrayOfArrays< T >, Array< 1, int >, Array< 1, iterator >, and Array< 1, container_type >.
| ArrayContainer& ArrayContainer< T, A >::operator= | ( | const ArrayContainer< T2, A2 > & | x | ) | [inline, protected] |
Assignment operator for an array of different type or allocation policy.
If A is true, allocate memory and copy the elements. Otherwise, reference the data in x.
| ArrayContainer& ArrayContainer< T, A >::operator= | ( | const ArrayContainer< T, A > & | other | ) | [inline, protected] |
Assignment operator.
If A is true, allocate memory and copy the elements. Otherwise, reference the data in x.
Referenced by Array< 1, container_type >::Array(), Array< 1, T, A >::operator=(), Array< 1, container_type >::operator=(), and Array< 1, container_type >::put().
| reference ArrayContainer< T, A >::operator[] | ( | const int | i | ) | [inline] |
Return a reference to the element.
This performs indexing into the container. The index i must be in the range [ 0 .. size()). This is different than ArrayIndexing::operator().
Reimplemented in StaticArrayOfArrays< T >.
| parameter_type ArrayContainer< T, A >::operator[] | ( | const int | i | ) | const [inline] |
Return the i_th element.
This performs indexing into the container. The index i must be in the range [ 0 .. size()). This is different than ArrayIndexing::operator().
Reimplemented in StaticArrayOfArrays< T >.
| void ArrayContainer< T, A >::rebuild | ( | const size_type | size | ) | [inline, protected] |
Rebuild from the array size.
This function should only be called if A is true.
| void ArrayContainer< T, A >::rebuild | ( | Type * | start, | |
| Type * | finish | |||
| ) | [inline, protected] |
Rebuild from a range of elements.
This may be used if A is true or false.
| void ArrayContainer< T, A >::rebuild | ( | ForwardIterator | start, | |
| ForwardIterator | finish | |||
| ) | [inline, protected] |
Rebuild from a range of elements.
This may only be used if A is true.
Reimplemented in Array< 1, T, A >.
Referenced by SparseArray< 1, T >::rebuild(), and Array< 1, T, A >::rebuild().
1.6.3