⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wy__arrayvalue.h

📁 一个不错
💻 H
📖 第 1 页 / 共 3 页
字号:
         #ifdef WY_DEBUG           if(((des_ptr-_b_bgn)+n_elem+(_b_end-src_ptr))!=rs) {             WY_TERMINATE("");           }         #endif         _objmove(des_ptr+n_elem,src_ptr,_b_end-src_ptr);         for(SizeType i=0 ; i<n_elem; ++des_ptr,++i) {           *des_ptr=InsElem;         }         _b_end=_b_bgn+rs;       } else {         // allocate memory for the new array         const SizeType cap( rs );         ElemType *ptmp=_alloc_raw(cap*sizeof(ElemType));         if(ptmp==NULL) {           WY_THROW( typename Wy_Array<ElemType>::Reply(Wym_ENOMEM) );         }         ElemType *p1(ptmp+sidx);   // insert point         for(SizeType i=0; i<n_elem; ++p1,++i) {           *p1=elem;         }         ElemType* des_ptr=ptmp;         ElemType* p2=_b_bgn;         p1=ptmp+sidx;         // move all elements in _b_bgn to ptmp         for(; des_ptr!=p1; ++p2,++des_ptr) {           *des_ptr=*p2;         }         des_ptr+=n_elem;         p2+=slen;         for(; p2!=_b_end; ++p2,++des_ptr) {           *des_ptr=*p2;         }         // update _b_bgn,_b_end,_b_eob to the new array(ptmp)         p2=_b_bgn;         _b_bgn=ptmp;         _b_end=des_ptr;         _b_eob=ptmp+cap;         _free_raw(p2);       };        WY__CHK_VALIDOBJ(*this);      };    void resize(SizeType nsize)      {       WY__CHK_VALIDOBJ(*this);       if(nsize<this->size()) {         ElemType *p1(_b_bgn+nsize);         _b_end=p1;       } else if(nsize>this->size()) {         // reserve enough capacity         const WyRet r( this->_reserve(nsize) );         if(r!=Ok) {           WY_THROW( typename Wy_Array<ElemType>::Reply(r) );         }         ElemType *p2(_b_bgn+nsize);         for(; _b_end<p2; ++_b_end) {           *_b_end=ElemType();         }       } else {       };       WY__CHK_VALIDOBJ(*this);      };    void resize(SizeType nsize, const ElemType& elem)      {       WY__CHK_VALIDOBJ(*this);       if(nsize<this->size()) {         ElemType *p1(_b_bgn+nsize);         _b_end=p1;       } else if(nsize>this->size()) {         // reserve enough capacity         const WyRet r( this->_reserve(nsize) );         if(r!=Ok) {           WY_THROW( typename Wy_Array<ElemType>::Reply(r) );         }         ElemType *p2(_b_bgn+nsize);         for(; _b_end<p2; ++_b_end) {           *_b_end=elem;         }       } else {       };       WY__CHK_VALIDOBJ(*this);      };    bool operator ==(const Wy__ArrayValue& rhs) const      {        WY__CHK_VALIDOBJ(*this);        if(this->size()!=rhs.size()) {          return(false);        }        for(const ElemType *p1(_b_bgn), *p2(rhs._b_bgn); p1!=_b_end; ++p1,++p2) {          if(*p1==*p2) {          } else {            return(false);          }        }        return(true);      };    bool operator !=(const Wy__ArrayValue& rhs) const       {        WY__CHK_VALIDOBJ(*this);        if(this->size()!=rhs.size()) {          return(true);        }        for(const ElemType *p1(_b_bgn), *p2(rhs._b_bgn); p1!=_b_end; ++p1,++p2) {          if(*p1!=*p2) {            return(true);          } else {          }        }        return(false);      };    SizeType _capacity(void) const WY__TSPC()      { WY__CHK_VALIDOBJ(*this);        return _b_eob-_b_bgn; };    WyRet _reserve(SizeType rcap) WY__TSPC()      {        WY__CHK_VALIDOBJ(*this);        if(rcap<=this->_capacity()) {          return(Ok);        }        if(rcap>this->max_capacity()) {          WY_RETURN( Wym_EFBIG );        }        const SizeType OrgSize(this->size());        ElemType *ptmp=_dup_array(_b_bgn,OrgSize,rcap);        if(ptmp==NULL) {          WY_RETURN( Wym_ENOMEM );        }        _free_raw(_b_bgn);        _b_bgn=ptmp;        _b_end=ptmp+OrgSize;        _b_eob=ptmp+rcap;        WY__CHK_VALIDOBJ(*this);        return(Ok);      };};template<typename T>const size_t Wy__ArrayValue<T>::MaxSizeRawMemory            =Wy_Array_MaxSizeRawMemory;template<typename T>const size_t Wy__ArrayValue<T>::MinimumCapacity            =Wy_Array_MinimumCapacity;template<typename T>const size_t Wy__ArrayValue<T>::DefaultSize            =Wy_Array_DefaultSize;template<>struct Wy_Array<char> : Wy__ArrayValue<char> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<char>() {};  Wy_Array(size_t s,const char& elem) : Wy__ArrayValue<char>(s,elem) {};  Wy_Array(const WySeg<char>& src) : Wy__ArrayValue<char>(src) {};  Wy_Array(const WySeg<const char>& src) : Wy__ArrayValue<char>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<char>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<char>(p,t) {};  const Wy__ArrayValue<char>& operator=(const WySeg<char>& rhs)        { return Wy__ArrayValue<char>::operator=(rhs); };  const Wy__ArrayValue<char>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<char>::operator=(rhs); };};template<>struct Wy_Array<bool> : Wy__ArrayValue<bool> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<bool>() {};  Wy_Array(size_t s,const bool& elem) : Wy__ArrayValue<bool>(s,elem) {};  Wy_Array(const WySeg<bool>& src) : Wy__ArrayValue<bool>(src) {};  Wy_Array(const WySeg<const bool>& src) : Wy__ArrayValue<bool>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<bool>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<bool>(p,t) {};  const Wy__ArrayValue<bool>& operator=(const WySeg<bool>& rhs)        { return Wy__ArrayValue<bool>::operator=(rhs); };  const Wy__ArrayValue<bool>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<bool>::operator=(rhs); };};template<>struct Wy_Array<signed char> : Wy__ArrayValue<signed char> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<signed char>() {};  Wy_Array(size_t s, const signed char& elem) : Wy__ArrayValue<signed char>(s,elem) {};  Wy_Array(const WySeg<signed char>& src) : Wy__ArrayValue<signed char>(src) {};  Wy_Array(const WySeg<const signed char>& src) : Wy__ArrayValue<signed char>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<signed char>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<signed char>(p,t) {};  const Wy__ArrayValue<signed char>& operator=(const WySeg<signed char>& rhs)        { return Wy__ArrayValue<signed char>::operator=(rhs); };  const Wy__ArrayValue<signed char>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<signed char>::operator=(rhs); };};template<>struct Wy_Array<signed short int> : Wy__ArrayValue<signed short int> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<signed short int>() {};  Wy_Array(size_t s,const signed short int& elem) : Wy__ArrayValue<signed short int>(s,elem) {};  Wy_Array(const WySeg<signed short int>& src) : Wy__ArrayValue<signed short int>(src) {};  Wy_Array(const WySeg<const signed short int>& src) : Wy__ArrayValue<signed short int>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<signed short int>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<signed short int>(p,t) {};  const Wy__ArrayValue<signed short int>& operator=(const WySeg<signed short int>& rhs)        { return Wy__ArrayValue<signed short int>::operator=(rhs); };  const Wy__ArrayValue<signed short int>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<signed short int>::operator=(rhs); };};template<>struct Wy_Array<signed int> : Wy__ArrayValue<signed int> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<signed int>() {};  Wy_Array(size_t s,const signed int& elem) : Wy__ArrayValue<signed int>(s,elem) {};  Wy_Array(const WySeg<signed int>& src) : Wy__ArrayValue<signed int>(src) {};  Wy_Array(const WySeg<const signed int>& src) : Wy__ArrayValue<signed int>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<signed int>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<signed int>(p,t) {};  const Wy__ArrayValue<signed int>& operator=(const WySeg<signed int>& rhs)        { return Wy__ArrayValue<signed int>::operator=(rhs); };  const Wy__ArrayValue<signed int>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<signed int>::operator=(rhs); };};template<>struct Wy_Array<signed long int> : Wy__ArrayValue<signed long int> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<signed long int>() {};  Wy_Array(size_t s, const signed long int& elem) : Wy__ArrayValue<signed long int>(s,elem) {};  Wy_Array(const WySeg<signed long int>& src) : Wy__ArrayValue<signed long int>(src) {};  Wy_Array(const WySeg<const signed long int>& src) : Wy__ArrayValue<signed long int>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<signed long int>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<signed long int>(p,t) {};  const Wy__ArrayValue<signed long int>& operator=(const WySeg<signed long int>& rhs)        { return Wy__ArrayValue<signed long int>::operator=(rhs); };  const Wy__ArrayValue<signed long int>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<signed long int>::operator=(rhs); };};template<>struct Wy_Array<signed long long int> : Wy__ArrayValue<signed long long int> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<signed long long int>() {};  Wy_Array(size_t s,const signed long long int& elem) : Wy__ArrayValue<signed long long int>(s,elem) {};  Wy_Array(const WySeg<signed long long int>& src) : Wy__ArrayValue<signed long long int>(src) {};  Wy_Array(const WySeg<const signed long long int>& src) : Wy__ArrayValue<signed long long int>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<signed long long int>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<signed long long int>(p,t) {};  const Wy__ArrayValue<signed long long int>& operator=(const WySeg<signed long long int>& rhs)        { return Wy__ArrayValue<signed long long int>::operator=(rhs); };  const Wy__ArrayValue<signed long long int>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<signed long long int>::operator=(rhs); };};template<>struct Wy_Array<unsigned char> : Wy__ArrayValue<unsigned char> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<unsigned char>() {};  Wy_Array(size_t s,const unsigned char& elem) : Wy__ArrayValue<unsigned char>(s,elem) {};  Wy_Array(const WySeg<unsigned char>& src) : Wy__ArrayValue<unsigned char>(src) {};  Wy_Array(const WySeg<const unsigned char>& src) : Wy__ArrayValue<unsigned char>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<unsigned char>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<unsigned char>(p,t) {};  const Wy__ArrayValue<unsigned char>& operator=(const WySeg<unsigned char>& rhs)        { return Wy__ArrayValue<unsigned char>::operator=(rhs); };  const Wy__ArrayValue<unsigned char>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<unsigned char>::operator=(rhs); };};template<>struct Wy_Array<unsigned short int> : Wy__ArrayValue<unsigned short int> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<unsigned short int>() {};  Wy_Array(size_t s,const unsigned short int& elem) : Wy__ArrayValue<unsigned short int>(s,elem) {};  Wy_Array(const WySeg<unsigned short int>& src) : Wy__ArrayValue<unsigned short int>(src) {};  Wy_Array(const WySeg<const unsigned short int>& src) : Wy__ArrayValue<unsigned short int>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<unsigned short int>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<unsigned short int>(p,t) {};  const Wy__ArrayValue<unsigned short int>& operator=(const WySeg<unsigned short int>& rhs)        { return Wy__ArrayValue<unsigned short int>::operator=(rhs); };  const Wy__ArrayValue<unsigned short int>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<unsigned short int>::operator=(rhs); };};template<>struct Wy_Array<unsigned int> : Wy__ArrayValue<unsigned int> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<unsigned int>() {};  Wy_Array(size_t s,const unsigned int& elem) : Wy__ArrayValue<unsigned int>(s,elem) {};  Wy_Array(const WySeg<unsigned int>& src) : Wy__ArrayValue<unsigned int>(src) {};  Wy_Array(const WySeg<const unsigned int>& src) : Wy__ArrayValue<unsigned int>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<unsigned int>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<unsigned int>(p,t) {};  const Wy__ArrayValue<unsigned int>& operator=(const WySeg<unsigned int>& rhs)        { return Wy__ArrayValue<unsigned int>::operator=(rhs); };  const Wy__ArrayValue<unsigned int>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<unsigned int>::operator=(rhs); };};template<>struct Wy_Array<unsigned long int> : Wy__ArrayValue<unsigned long int> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<unsigned long int>() {};  Wy_Array(size_t s,const unsigned long int& elem) : Wy__ArrayValue<unsigned long int>(s,elem) {};  Wy_Array(const WySeg<unsigned long int>& src) : Wy__ArrayValue<unsigned long int>(src) {};  Wy_Array(const WySeg<const unsigned long int>& src) : Wy__ArrayValue<unsigned long int>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<unsigned long int>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<unsigned long int>(p,t) {};  const Wy__ArrayValue<unsigned long int>& operator=(const WySeg<unsigned long int>& rhs)        { return Wy__ArrayValue<unsigned long int>::operator=(rhs); };  const Wy__ArrayValue<unsigned long int>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<unsigned long int>::operator=(rhs); };};template<>struct Wy_Array<unsigned long long int> : Wy__ArrayValue<unsigned long long int> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<unsigned long long int>() {};  Wy_Array(size_t s,const unsigned long long int& elem) : Wy__ArrayValue<unsigned long long int>(s,elem) {};  Wy_Array(const WySeg<unsigned long long int>& src) : Wy__ArrayValue<unsigned long long int>(src) {};  Wy_Array(const WySeg<const unsigned long long int>& src) : Wy__ArrayValue<unsigned long long int>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<unsigned long long int>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<unsigned long long int>(p,t) {};  const Wy__ArrayValue<unsigned long long int>& operator=(const WySeg<unsigned long long int>& rhs)        { return Wy__ArrayValue<unsigned long long int>::operator=(rhs); };  const Wy__ArrayValue<unsigned long long int>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<unsigned long long int>::operator=(rhs); };};template<>struct Wy_Array<float> : Wy__ArrayValue<float> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<float>() {};  Wy_Array(size_t s,const float& elem) : Wy__ArrayValue<float>(s,elem) {};  Wy_Array(const WySeg<float>& src) : Wy__ArrayValue<float>(src) {};  Wy_Array(const WySeg<const float>& src) : Wy__ArrayValue<float>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<float>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<float>(p,t) {};  const Wy__ArrayValue<float>& operator=(const WySeg<float>& rhs)        { return Wy__ArrayValue<float>::operator=(rhs); };  const Wy__ArrayValue<float>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<float>::operator=(rhs); };};template<>struct Wy_Array<double> : Wy__ArrayValue<double> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<double>() {};  Wy_Array(size_t s,const double& elem) : Wy__ArrayValue<double>(s,elem) {};  Wy_Array(const WySeg<double>& src) : Wy__ArrayValue<double>(src) {};  Wy_Array(const WySeg<const double>& src) : Wy__ArrayValue<double>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<double>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<double>(p,t) {};  const Wy__ArrayValue<double>& operator=(const WySeg<double>& rhs)        { return Wy__ArrayValue<double>::operator=(rhs); };  const Wy__ArrayValue<double>& operator=(const Wy_Array& rhs)        { return Wy__ArrayValue<double>::operator=(rhs); };};template<>struct Wy_Array<long double> : Wy__ArrayValue<long double> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<long double>() {};  Wy_Array(size_t s,const long double& elem) : Wy__ArrayValue<long double>(s,elem) {};  Wy_Array(const WySeg<long double>& src) : Wy__ArrayValue<long double>(src) {};  Wy_Array(const WySeg<const long double>& src) : Wy__ArrayValue<long double>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<long double>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<long double>(p,t) {};};template<typename T>struct Wy_Array<T*> : Wy__ArrayValue<T*> {  WY_THROW_REPLY;  Wy_Array() : Wy__ArrayValue<T*>() {};  Wy_Array(size_t s,T* elem) : Wy__ArrayValue<T*>(s,elem) {};  Wy_Array(const WySeg<T*>& src) : Wy__ArrayValue<T*>(src) {};  Wy_Array(const WySeg<T* const>& src) : Wy__ArrayValue<T*>(src) {};  Wy_Array(const Wy_Array& s) : Wy__ArrayValue<T*>(s) {};  Wy_Array(Wy_Array& p, Wy::ByMove_t t) : Wy__ArrayValue<T*>(p,t) {};};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -