28 #ifdef TNT_BOUNDS_CHECK
33 #include "tnt_i_refvec.h"
52 void copy_(T* p,
const T* q,
int len)
const;
53 void set_(T* begin, T* end,
const T& val);
67 inline operator const T*();
68 inline Array1D & operator=(
const T &a);
73 inline T& operator[](
int i);
74 inline const T& operator[](
int i)
const;
75 inline int dim1()
const;
76 inline int dim()
const;
82 inline int ref_count()
const;
94 Array1D<T>::Array1D(
const Array1D<T> &A) : v_(A.v_), n_(A.n_),
98 std::cout <<
"Created Array1D(const Array1D<T> &A) \n";
105 Array1D<T>::Array1D(
int n) : v_(n), n_(n), data_(v_.begin())
108 std::cout <<
"Created Array1D(int n) \n";
113 Array1D<T>::Array1D(
int n,
const T &val) : v_(n), n_(n), data_(v_.begin())
116 std::cout <<
"Created Array1D(int n, const T& val) \n";
118 set_(data_, data_+ n, val);
123 Array1D<T>::Array1D(
int n, T *a) : v_(a), n_(n) , data_(v_.begin())
126 std::cout <<
"Created Array1D(int n, T* a) \n";
131 inline Array1D<T>::operator T*()
138 inline Array1D<T>::operator
const T*()
146 inline T& Array1D<T>::operator[](
int i)
148 #ifdef TNT_BOUNDS_CHECK
156 inline const T& Array1D<T>::operator[](
int i)
const
158 #ifdef TNT_BOUNDS_CHECK
169 Array1D<T> & Array1D<T>::operator=(
const T &a)
171 set_(data_, data_+n_, a);
176 Array1D<T> Array1D<T>::copy()
const
179 copy_(A.data_, data_, n_);
186 Array1D<T> & Array1D<T>::inject(
const Array1D &A)
189 copy_(data_, A.data_, n_);
199 Array1D<T> & Array1D<T>::ref(
const Array1D<T> &A)
212 Array1D<T> & Array1D<T>::operator=(
const Array1D<T> &A)
218 inline int Array1D<T>::dim1()
const {
return n_; }
221 inline int Array1D<T>::dim()
const {
return n_; }
224 Array1D<T>::~Array1D() {}
230 inline int Array1D<T>::ref_count()
const
232 return v_.ref_count();
236 inline Array1D<T> Array1D<T>::subarray(
int i0,
int i1)
238 if ((i0 > 0) && (i1 < n_) || (i0 <= i1))
257 void Array1D<T>::set_(T* begin, T* end,
const T& a)
259 for (T* p=begin; p<end; p++)
265 void Array1D<T>::copy_(T* p,
const T* q,
int len)
const