00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _MASK_ARRAY_H
00034 #define _MASK_ARRAY_H 1
00035
00036 #pragma GCC system_header
00037
00038 namespace std _GLIBCXX_VISIBILITY(default)
00039 {
00040 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 template <class _Tp>
00063 class mask_array
00064 {
00065 public:
00066 typedef _Tp value_type;
00067
00068
00069
00070
00071
00072 mask_array (const mask_array&);
00073
00074
00075
00076 mask_array& operator=(const mask_array&);
00077
00078 void operator=(const valarray<_Tp>&) const;
00079
00080 void operator*=(const valarray<_Tp>&) const;
00081
00082 void operator/=(const valarray<_Tp>&) const;
00083
00084 void operator%=(const valarray<_Tp>&) const;
00085
00086 void operator+=(const valarray<_Tp>&) const;
00087
00088 void operator-=(const valarray<_Tp>&) const;
00089
00090 void operator^=(const valarray<_Tp>&) const;
00091
00092 void operator&=(const valarray<_Tp>&) const;
00093
00094 void operator|=(const valarray<_Tp>&) const;
00095
00096 void operator<<=(const valarray<_Tp>&) const;
00097
00098 void operator>>=(const valarray<_Tp>&) const;
00099
00100 void operator=(const _Tp&) const;
00101
00102
00103
00104 template<class _Dom>
00105 void operator=(const _Expr<_Dom,_Tp>&) const;
00106 template<class _Dom>
00107 void operator*=(const _Expr<_Dom,_Tp>&) const;
00108 template<class _Dom>
00109 void operator/=(const _Expr<_Dom,_Tp>&) const;
00110 template<class _Dom>
00111 void operator%=(const _Expr<_Dom,_Tp>&) const;
00112 template<class _Dom>
00113 void operator+=(const _Expr<_Dom,_Tp>&) const;
00114 template<class _Dom>
00115 void operator-=(const _Expr<_Dom,_Tp>&) const;
00116 template<class _Dom>
00117 void operator^=(const _Expr<_Dom,_Tp>&) const;
00118 template<class _Dom>
00119 void operator&=(const _Expr<_Dom,_Tp>&) const;
00120 template<class _Dom>
00121 void operator|=(const _Expr<_Dom,_Tp>&) const;
00122 template<class _Dom>
00123 void operator<<=(const _Expr<_Dom,_Tp>&) const;
00124 template<class _Dom>
00125 void operator>>=(const _Expr<_Dom,_Tp>&) const;
00126
00127 private:
00128 mask_array(_Array<_Tp>, size_t, _Array<bool>);
00129 friend class valarray<_Tp>;
00130
00131 const size_t _M_sz;
00132 const _Array<bool> _M_mask;
00133 const _Array<_Tp> _M_array;
00134
00135
00136 mask_array();
00137 };
00138
00139 template<typename _Tp>
00140 inline mask_array<_Tp>::mask_array(const mask_array<_Tp>& a)
00141 : _M_sz(a._M_sz), _M_mask(a._M_mask), _M_array(a._M_array) {}
00142
00143 template<typename _Tp>
00144 inline
00145 mask_array<_Tp>::mask_array(_Array<_Tp> __a, size_t __s, _Array<bool> __m)
00146 : _M_sz(__s), _M_mask(__m), _M_array(__a) {}
00147
00148 template<typename _Tp>
00149 inline mask_array<_Tp>&
00150 mask_array<_Tp>::operator=(const mask_array<_Tp>& __a)
00151 {
00152 std::__valarray_copy(__a._M_array, __a._M_mask,
00153 _M_sz, _M_array, _M_mask);
00154 return *this;
00155 }
00156
00157 template<typename _Tp>
00158 inline void
00159 mask_array<_Tp>::operator=(const _Tp& __t) const
00160 { std::__valarray_fill(_M_array, _M_sz, _M_mask, __t); }
00161
00162 template<typename _Tp>
00163 inline void
00164 mask_array<_Tp>::operator=(const valarray<_Tp>& __v) const
00165 { std::__valarray_copy(_Array<_Tp>(__v), __v.size(), _M_array, _M_mask); }
00166
00167 template<typename _Tp>
00168 template<class _Ex>
00169 inline void
00170 mask_array<_Tp>::operator=(const _Expr<_Ex, _Tp>& __e) const
00171 { std::__valarray_copy(__e, __e.size(), _M_array, _M_mask); }
00172
00173 #undef _DEFINE_VALARRAY_OPERATOR
00174 #define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
00175 template<typename _Tp> \
00176 inline void \
00177 mask_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
00178 { \
00179 _Array_augmented_##_Name(_M_array, _M_mask, \
00180 _Array<_Tp>(__v), __v.size()); \
00181 } \
00182 \
00183 template<typename _Tp> \
00184 template<class _Dom> \
00185 inline void \
00186 mask_array<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e) const\
00187 { \
00188 _Array_augmented_##_Name(_M_array, _M_mask, __e, __e.size()); \
00189 }
00190
00191 _DEFINE_VALARRAY_OPERATOR(*, __multiplies)
00192 _DEFINE_VALARRAY_OPERATOR(/, __divides)
00193 _DEFINE_VALARRAY_OPERATOR(%, __modulus)
00194 _DEFINE_VALARRAY_OPERATOR(+, __plus)
00195 _DEFINE_VALARRAY_OPERATOR(-, __minus)
00196 _DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
00197 _DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
00198 _DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
00199 _DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
00200 _DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
00201
00202 #undef _DEFINE_VALARRAY_OPERATOR
00203
00204
00205
00206 _GLIBCXX_END_NAMESPACE_VERSION
00207 }
00208
00209 #endif