mask_array
mask_array
template<class T>
class mask_array {
public:
typedef T value_type;
void operator=(const valarray<T> x) const;
void operator=(const T& x);
void operator*=(const valarray<T> x) const;
void operator/=(const valarray<T> x) const;
void operator%=(const valarray<T> x) const;
void operator+=(const valarray<T> x) const;
void operator-=(const valarray<T> x) const;
void operator^=(const valarray<T> x) const;
void operator&=(const valarray<T> x) const;
void operator|=(const valarray<T> x) const;
void operator<<=(const valarray<T> x) const;
void operator>>=(const valarray<T> x) const;
void fill();
};
The class describes an object that stores a reference to an object x
of class valarray
<T>
, along with an object ba
of class valarray<bool>
which describes the sequence of elements to select from the valarray<T>
object.
You construct a mask_array<T>
object only by writing an expression of the form x[xa]
. The member functions of class mask_array
then behave like the corresponding function signatures defined for valarray<T>
, except that only the sequence of selected elements is affected.
The sequence consists of, at most, ba.
size
()
elements. An element j
is included only if ba[j]
is true. Thus, there are as many elements in the sequence as there are true elements in ba
. If i
is the index of the lowest true element in ba
, then x[i]
is element zero in the selected sequence. For example:
const bool vb[] = {false, false, true, true, false, true};
// x[valarray<bool>(vb, 56] selects eleeents with indices
// 2, 3, 5