22 #ifndef TNT_I_REFVEC_H
23 #define TNT_I_REFVEC_H
28 #ifdef TNT_BOUNDS_CHECK
71 inline const T* begin()
const;
72 inline T& operator[](
int i);
73 inline const T& operator[](
int i)
const;
75 void copy_(T* p,
const T* q,
const T* e);
76 void set_(T* p,
const T* b,
const T* e);
77 inline int ref_count()
const;
78 inline int is_null()
const;
79 inline void destroy();
87 for (T* t=p; q<e; t++, q++)
92 i_refvec<T>::i_refvec() : data_(NULL), ref_count_(NULL) {}
103 std::cout <<
"new data storage.\n";
106 ref_count_ =
new int;
113 ref_count_(V.ref_count_)
115 if (V.ref_count_ != NULL)
121 i_refvec<T>::i_refvec(T* data) : data_(data), ref_count_(NULL) {}
124 inline T* i_refvec<T>::begin()
130 inline const T& i_refvec<T>::operator[](
int i)
const
136 inline T& i_refvec<T>::operator[](
int i)
143 inline const T* i_refvec<T>::begin()
const
151 i_refvec<T> & i_refvec<T>::operator=(
const i_refvec<T> &V)
157 if (ref_count_ != NULL)
160 if ((*ref_count_) == 0)
165 ref_count_ = V.ref_count_;
167 if (V.ref_count_ != NULL)
174 void i_refvec<T>::destroy()
176 if (ref_count_ != NULL)
179 std::cout <<
"destorying data... \n";
184 std::cout <<
"deleted ref_count_ ...\n";
189 std::cout <<
"deleted data_[] ...\n";
202 int i_refvec<T>::is_null()
const
204 return (data_ == NULL ? 1 : 0);
214 int i_refvec<T>::ref_count()
const
219 return (ref_count_ != NULL ? *ref_count_ : -1) ;
223 i_refvec<T>::~i_refvec()
225 if (ref_count_ != NULL)
229 if (*ref_count_ == 0)