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
00030
00031
00037 #ifndef __ARRAY_VECTOR_H_
00038 #define __ARRAY_VECTOR_H_
00039
00040 #if defined(__GNUC__)
00041 #define VGTL_VECTOR_START _M_start
00042 #define VGTL_VECTOR_FINISH _M_finish
00043 #define VGTL_VECTOR_EOS _M_end_of_storage
00044 #elif defined(_MSC_VER)
00045 #define VGTL_VECTOR_START _Myfirst
00046 #define VGTL_VECTOR_FINISH _Mylast
00047 #define VGTL_VECTOR_EOS _Myend
00048 #else
00049 #error "No proper array_vector implementation found!"
00050 #endif
00051
00052 #if VGTL_VECTOR_NEEDS_IMPL
00053 #define VGTL_VECTOR_IMPL _M_impl.
00054 #else
00055 #define VGTL_VECTOR_IMPL
00056 #endif
00057
00058 template <class _TT>
00059 class array_vector : public std::vector<_TT>
00060 {
00061 public:
00065 array_vector()
00066 { this->VGTL_VECTOR_IMPL VGTL_VECTOR_START =
00067 this->VGTL_VECTOR_IMPL VGTL_VECTOR_FINISH =
00068 this->VGTL_VECTOR_IMPL VGTL_VECTOR_EOS = NULL; }
00069
00073 array_vector(_TT* __a, int n)
00074 {
00075 this->VGTL_VECTOR_IMPL VGTL_VECTOR_START = __a;
00076 this->VGTL_VECTOR_IMPL VGTL_VECTOR_FINISH =
00077 this->VGTL_VECTOR_IMPL VGTL_VECTOR_EOS = __a+n;
00078 }
00079
00083 ~array_vector() { this->VGTL_VECTOR_IMPL VGTL_VECTOR_START =
00084 this->VGTL_VECTOR_IMPL VGTL_VECTOR_FINISH =
00085 this->VGTL_VECTOR_IMPL VGTL_VECTOR_EOS = NULL; }
00086
00090 void assignvector(_TT* __a, int n)
00091 {
00092 this->VGTL_VECTOR_IMPL VGTL_VECTOR_START = __a;
00093 this->VGTL_VECTOR_IMPL VGTL_VECTOR_FINISH =
00094 this->VGTL_VECTOR_IMPL VGTL_VECTOR_EOS = __a+n;
00095 }
00096
00097 int copy_into(const std::vector<_TT>& _r)
00098 {
00099 size_t n;
00100 if((size_t)(this->VGTL_VECTOR_IMPL VGTL_VECTOR_FINISH-
00101 this->VGTL_VECTOR_IMPL VGTL_VECTOR_START) < _r.size())
00102 n = this->VGTL_VECTOR_IMPL VGTL_VECTOR_FINISH-this->VGTL_VECTOR_IMPL VGTL_VECTOR_START;
00103 else
00104 n = _r.size();
00105 std::memcpy((void*)this->VGTL_VECTOR_IMPL VGTL_VECTOR_START,
00106 (void*)&(_r[0]), n*sizeof(_TT));
00107 return n;
00108 }
00109
00110
00111
00112
00113
00114
00115 };
00116
00117 #endif