Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

mask_array


Valarray helpers

Summary

A numeric array class that gives a masked view of a valarray.

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <valarray>
template <class T>
class mask_array;

Description

mask_array<T> gives a masked view into a valarray. mask_arrays are only produced by applying the mask subscript operator to a valarray. This subscript operator takes a valarray<bool> argument and produces a mask_array. Only the elements in the valarray whose corresponding elements in the valarray<bool> argument were true are selected by the mask_array. The elements in a mask_array are references to selected elements in the valarray (so changing an element in the mask_array really changes the corresponding element in the valarray). A mask_array does not itself hold any distinct elements. The template cannot be instantiated directly since all its constructors are private. However, you can copy a slice_array to a valarray using either the valarray copy constructor or the assignment operator. Reference semantics are lost at that point.

Interface

template <class T> class mask_array {
public:

  // types
  typedef T value_type;

  // destructor
  ~mask_array();

  // public assignment
  void operator= (const valarray<T>& array) const;
  // computed assignment
  void operator*= (const valarray<T>& array) const;
  void operator/= (const valarray<T>& array) const;
  void operator%= (const valarray<T>& array) const;
  void operator+= (const valarray<T>& array) const;
  void operator-= (const valarray<T>& array) const;
  void operator^= (const valarray<T>& array) const;
  void operator&= (const valarray<T>& array) const;
  void operator|= (const valarray<T>& array) const;
  void operator<<= (const valarray<T>& array) const;
  void operator>>= (const valarray<T>& array) const;
 
  // other
  void operator= (const T&) const; 

private:
  // constructors
  mask_array();
  mask_array(const mask_array<T>&);
  // operator =
  mask_array<T>& operator= (const mask_array<T>& array);
};

Constructors

mask_array();
mask_array(const mask_array&);

Assignment Operators

void operator=(const valarray<T>& x) const;
mask_array<T>& 
operator=(const mask-_array<T>& x);

Computed Assignment Operators

void operator*=(const valarray<T>& val) const;
void operator/=(const valarray<T>& val) const;
void operator%=(const valarray<T>& val) const;
void operator+=(const valarray<T>& val) const;
void operator-=(const valarray<T>& val) const;
void operator^=(const valarray<T>& val) const;
void operator&=(const valarray<T>& val) const;
void operator|=(const valarray<T>& val) const;
void operator<<=(const valarray<T>& val) const;
void operator>>=(const valarray<T>& val) const;

Member Functions

void operator= (const T& x) const;

Example

Program Output

Warnings

If your compiler does not support namespaces, then you do not need the using declaration for std.

See Also

valarray, slice_array, slice, gslice, gslice_array, indirect_array



Previous fileTop of documentContentsIndexNext file
©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.
OEM Release, June 1998