Partial template specialization for N = 2. More...
#include <FixedArray2.h>
Public Types | |
STL container requirements. | |
typedef Types::value_type | value_type |
The element type of the array. | |
typedef Types::parameter_type | parameter_type |
The parameter type for the value type. | |
typedef Types::pointer | pointer |
A pointer to an array element. | |
typedef Types::const_pointer | const_pointer |
A const pointer to an array element. | |
typedef Types::iterator | iterator |
An iterator in the array. | |
typedef Types::const_iterator | const_iterator |
A const iterator in the array. | |
typedef Types::reference | reference |
A reference to an array element. | |
typedef Types::const_reference | const_reference |
A const reference to an 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 | |
Constructors etc. | |
FixedArray () | |
Default constructor. Leave the data uninitialized. | |
~FixedArray () | |
Trivial destructor. | |
FixedArray (const FixedArray &x) | |
Copy constructor. | |
template<typename T2 > | |
FixedArray (const FixedArray< 2, T2 > &x) | |
Copy constructor for a FixedArray of different type. | |
FixedArray (parameter_type x) | |
Constructor. Specify the component. | |
FixedArray (const void *vp) | |
Constructor. Initialize from a C array. | |
FixedArray (parameter_type x0, parameter_type x1) | |
Constructor. Specify the two components. | |
Assignment operators. | |
FixedArray & | operator= (const FixedArray &x) |
Assignment operator. | |
FixedArray & | operator= (parameter_type x) |
Assignment operator. Assign from a value. | |
template<typename T2 > | |
FixedArray & | operator= (const FixedArray< 2, T2 > &x) |
Assignment operator for a FixedArray of different type. | |
template<typename T2 , bool A> | |
FixedArray & | operator= (const Array< 1, T2, A > &x) |
Assignment operator for an Array. | |
Accessors. | |
const_iterator | begin () const |
Return a const_iterator to the beginning of the data. | |
const_iterator | end () const |
Return a const_iterator to the end of the data. | |
const_pointer | data () const |
Return a const_pointer to the data. | |
parameter_type | operator() (const int i) const |
Subscripting. Return the i_th component. | |
parameter_type | operator[] (const int i) const |
Subscripting. Return the i_th component. | |
template<typename EqualityComparable > | |
const_iterator | find (const EqualityComparable &x) const |
Linear search for x . | |
template<typename EqualityComparable > | |
int | find_index (const EqualityComparable &x) const |
Linear search for x . Return the index of the matching element. | |
template<typename EqualityComparable > | |
bool | has (const EqualityComparable &x) const |
Return true if this array has the element x . | |
bool | is_sorted () const |
Return true if the array is in sorted order. | |
template<class StrictWeakOrdering > | |
bool | is_sorted (StrictWeakOrdering comp) const |
Return true if the array is in sorted order. | |
int | min_index () const |
Return the index of the minimum element. | |
template<class StrictWeakOrdering > | |
int | min_index (StrictWeakOrdering comp) const |
Return the index of the minimum element using the comparison functor. | |
int | max_index () const |
Return the index of the maximum element. | |
template<class StrictWeakOrdering > | |
int | max_index (StrictWeakOrdering comp) const |
Return the index of the maximum element using the comparison functor. | |
Manipulators. | |
iterator | begin () |
Return an iterator to the beginning of the data. | |
iterator | end () |
Return an iterator to the end of the data. | |
pointer | data () |
Return a pointer to the data. | |
reference | operator() (const int i) |
Subscripting. Return a reference to the i_th component. | |
reference | operator[] (const int i) |
Subscripting. Return a reference to the i_th component. | |
void | swap (FixedArray &x) |
Swaps data with another FixedArray of the same size and type. | |
template<typename EqualityComparable > | |
iterator | find (const EqualityComparable &x) |
Linear search for x . | |
void | negate () |
Negate each component. | |
void | fill (parameter_type value) |
Fill the array with the given value . | |
template<typename InputIterator > | |
void | copy (InputIterator start, InputIterator finish) |
Copy the specified range into the array. | |
void | sort () |
Sort the elements of the array. | |
template<class StrictWeakOrdering > | |
void | sort (StrictWeakOrdering comp) |
Sort the elements of the array. | |
Assignment operators with scalar operand. | |
FixedArray & | operator+= (parameter_type x) |
Add x to each component. | |
FixedArray & | operator-= (parameter_type x) |
Subtract x from each component. | |
FixedArray & | operator*= (parameter_type x) |
Multiply each component by x . | |
FixedArray & | operator/= (parameter_type x) |
Divide each component by x . | |
FixedArray & | operator%= (parameter_type x) |
Mod each component by x . | |
FixedArray & | operator<<= (const int offset) |
Left-shift each component by the offset . | |
FixedArray & | operator>>= (const int offset) |
Right-shift each component by the offset . | |
Assignment operators with FixedArray operand. | |
template<typename T2 > | |
FixedArray & | operator+= (const FixedArray< 2, T2 > &x) |
Add x to this. | |
template<typename T2 > | |
FixedArray & | operator-= (const FixedArray< 2, T2 > &x) |
Subtract x from this. | |
template<typename T2 > | |
FixedArray & | operator*= (const FixedArray< 2, T2 > &x) |
Multiply this by x. | |
template<typename T2 > | |
FixedArray & | operator/= (const FixedArray< 2, T2 > &x) |
Divide this by x. | |
template<typename T2 > | |
FixedArray & | operator%= (const FixedArray< 2, T2 > &x) |
Mod this by x. | |
Static Public Member Functions | |
Static members. | |
static size_type | size () |
Return the size of the array. | |
static bool | empty () |
Return true if the array has zero size. | |
static size_type | max_size () |
Return the size of the largest possible FixedArray. |
Partial template specialization for N = 2.
typedef Types::size_type FixedArray< 2, T >::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.