📄 vector.h
字号:
// void storeToBuffer(void* buffer, int bufferLength) const;
void reference(T_vector&);
void resize(int length);
void resizeAndPreserve(int newLength);
// int restoreFromBuffer(void* buffer, int bufferLength);
T_vector reverse()
{ return T_vector(*this,Range(length()-1,0,-1)); }
int stride() const
{ return stride_; }
operator _bz_VecExpr<VectorIterConst<T_numtype> > () const
{ return _bz_VecExpr<VectorIterConst<T_numtype> >(begin()); }
/////////////////////////////////////////////
// Library-internal member functions
// These are undocumented and may change or
// disappear in future releases.
/////////////////////////////////////////////
int _bz_suggestLength() const
{ return length_; }
_bz_bool _bz_hasFastAccess() const
{ return stride_ == 1; }
T_numtype& _bz_fastAccess(int i)
{ return data_[i]; }
T_numtype _bz_fastAccess(int i) const
{ return data_[i]; }
template<class P_expr, class P_updater>
void _bz_assign(P_expr, P_updater);
_bz_VecExpr<T_constIterator> _bz_asVecExpr() const
{ return _bz_VecExpr<T_constIterator>(begin()); }
//////////////////////////////////////////////
// Subscripting operators
//////////////////////////////////////////////
// operator()(int) may be used only when the vector has unit
// stride. Otherwise, use operator[].
T_numtype operator()(int i) const
{
BZPRECONDITION(i < length_);
BZPRECONDITION(stride_ == 1);
return data_[i];
}
// operator()(int) may be used only when the vector has unit
// stride. Otherwise, use operator[].
T_numtype& _bz_restrict operator()(int i)
{
BZPRECONDITION(i < length_);
BZPRECONDITION(stride_ == 1);
return data_[i];
}
T_numtype operator[](int i) const
{
BZPRECONDITION(i < length_);
return data_[i * stride_];
}
T_numtype& _bz_restrict operator[](int i)
{
BZPRECONDITION(i < length_);
return data_[i * stride_];
}
T_vector operator()(Range r)
{
return T_vector(*this, r);
}
T_vector operator[](Range r)
{
return T_vector(*this, r);
}
T_pick operator()(T_indexVector i)
{
return T_pick(*this, i);
}
T_pick operator[](T_indexVector i)
{
return T_pick(*this, i);
}
// T_vector operator()(difference-equation-expression)
//////////////////////////////////////////////
// Assignment operators
//////////////////////////////////////////////
// Scalar operand
ListInitializationSwitch<T_vector,T_iterator> operator=(T_numtype x)
{
return ListInitializationSwitch<T_vector,T_iterator>(*this, x);
}
T_iterator getInitializationIterator()
{ return begin(); }
T_vector& initialize(T_numtype);
T_vector& operator+=(T_numtype);
T_vector& operator-=(T_numtype);
T_vector& operator*=(T_numtype);
T_vector& operator/=(T_numtype);
T_vector& operator%=(T_numtype);
T_vector& operator^=(T_numtype);
T_vector& operator&=(T_numtype);
T_vector& operator|=(T_numtype);
T_vector& operator>>=(int);
T_vector& operator<<=(int);
// Vector operand
template<class P_numtype2> T_vector& operator=(const Vector<P_numtype2> &);
// Specialization uses memcpy instead of element-by-element cast and
// copy
// NEEDS_WORK -- KCC won't accept this syntax; standard??
// template<> T_vector& operator=(const T_vector&);
template<class P_numtype2> T_vector& operator+=(const Vector<P_numtype2> &);
template<class P_numtype2> T_vector& operator-=(const Vector<P_numtype2> &);
template<class P_numtype2> T_vector& operator*=(const Vector<P_numtype2> &);
template<class P_numtype2> T_vector& operator/=(const Vector<P_numtype2> &);
template<class P_numtype2> T_vector& operator%=(const Vector<P_numtype2> &);
template<class P_numtype2> T_vector& operator^=(const Vector<P_numtype2> &);
template<class P_numtype2> T_vector& operator&=(const Vector<P_numtype2> &);
template<class P_numtype2> T_vector& operator|=(const Vector<P_numtype2> &);
template<class P_numtype2> T_vector& operator>>=(const Vector<P_numtype2> &);
template<class P_numtype2> T_vector& operator<<=(const Vector<P_numtype2> &);
// Vector expression operand
template<class P_expr> T_vector& operator=(_bz_VecExpr<P_expr>);
template<class P_expr> T_vector& operator+=(_bz_VecExpr<P_expr>);
template<class P_expr> T_vector& operator-=(_bz_VecExpr<P_expr>);
template<class P_expr> T_vector& operator*=(_bz_VecExpr<P_expr>);
template<class P_expr> T_vector& operator/=(_bz_VecExpr<P_expr>);
template<class P_expr> T_vector& operator%=(_bz_VecExpr<P_expr>);
template<class P_expr> T_vector& operator^=(_bz_VecExpr<P_expr>);
template<class P_expr> T_vector& operator&=(_bz_VecExpr<P_expr>);
template<class P_expr> T_vector& operator|=(_bz_VecExpr<P_expr>);
template<class P_expr> T_vector& operator>>=(_bz_VecExpr<P_expr>);
template<class P_expr> T_vector& operator<<=(_bz_VecExpr<P_expr>);
// VectorPick operand
template<class P_numtype2>
T_vector& operator=(const VectorPick<P_numtype2> &);
template<class P_numtype2>
T_vector& operator+=(const VectorPick<P_numtype2> &);
template<class P_numtype2>
T_vector& operator-=(const VectorPick<P_numtype2> &);
template<class P_numtype2>
T_vector& operator*=(const VectorPick<P_numtype2> &);
template<class P_numtype2>
T_vector& operator/=(const VectorPick<P_numtype2> &);
template<class P_numtype2>
T_vector& operator%=(const VectorPick<P_numtype2> &);
template<class P_numtype2>
T_vector& operator^=(const VectorPick<P_numtype2> &);
template<class P_numtype2>
T_vector& operator&=(const VectorPick<P_numtype2> &);
template<class P_numtype2>
T_vector& operator|=(const VectorPick<P_numtype2> &);
template<class P_numtype2>
T_vector& operator>>=(const VectorPick<P_numtype2> &);
template<class P_numtype2>
T_vector& operator<<=(const VectorPick<P_numtype2> &);
// Range operand
T_vector& operator=(Range);
T_vector& operator+=(Range);
T_vector& operator-=(Range);
T_vector& operator*=(Range);
T_vector& operator/=(Range);
T_vector& operator%=(Range);
T_vector& operator^=(Range);
T_vector& operator&=(Range);
T_vector& operator|=(Range);
T_vector& operator>>=(Range);
T_vector& operator<<=(Range);
// Random operand
template<class P_distribution>
T_vector& operator=(Random<P_distribution>& random);
template<class P_distribution>
T_vector& operator+=(Random<P_distribution>& random);
template<class P_distribution>
T_vector& operator-=(Random<P_distribution>& random);
template<class P_distribution>
T_vector& operator*=(Random<P_distribution>& random);
template<class P_distribution>
T_vector& operator/=(Random<P_distribution>& random);
template<class P_distribution>
T_vector& operator%=(Random<P_distribution>& random);
template<class P_distribution>
T_vector& operator^=(Random<P_distribution>& random);
template<class P_distribution>
T_vector& operator&=(Random<P_distribution>& random);
template<class P_distribution>
T_vector& operator|=(Random<P_distribution>& random);
//////////////////////////////////////////////
// Unary operators
//////////////////////////////////////////////
// T_vector& operator++();
// void operator++(int);
// T_vector& operator--();
// void operator--(int);
private:
int length_;
int stride_;
};
// Global I/O functions
template<class P_numtype>
ostream& operator<<(ostream& os, const Vector<P_numtype>& x);
template<class P_expr>
ostream& operator<<(ostream& os, _bz_VecExpr<P_expr> expr);
BZ_NAMESPACE_END
#include <blitz/veciter.h> // Iterators
#include <blitz/vecpick.h> // VectorPick
#include <blitz/vecexpr.h> // Expression templates
#include <blitz/vecglobs.h> // Global functions
#include <blitz/vector.cc> // Member functions
#include <blitz/vecio.cc> // IO functions
#endif // BZ_VECTOR_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -