21 #ifndef mia_core_vector_hh 22 #define mia_core_vector_hh 42 struct array_destructor {
44 virtual void operator () (T *p) {
56 struct array_void_destructor {
58 virtual void operator () (T *) {
80 typedef const T& const_reference;
82 typedef const T *const_iterator;
83 typedef size_t size_type;
95 m_data(new T[n], array_destructor<T>()),
99 memset(m_data.get(), 0, m_size*
sizeof(T));
107 m_size(other.m_size),
108 m_data(other.m_data),
109 m_cdata(other.m_cdata)
116 m_size = other.m_size;
117 m_data = other.m_data;
118 m_cdata = other.m_cdata;
130 m_data(init, array_void_destructor<T>()),
151 reference operator[] (
size_t i) {
154 "TCArrayWrapper::operator[]: No writeable data available or not unique," 155 " call TCArrayWrapper::make_unique() first or enforce the use of " 156 "'TCArrayWrapper::operator[](...) const'");
157 return m_data.get()[i];
163 const_reference operator[] (
size_t i)
const {
173 "TCArrayWrapper::begin(): No writeable data available or not unique, " 174 "call TCArrayWrapper::make_unique() first or enforce the use of " 175 "'TCArrayWrapper::begin() const'");
184 "TCArrayWrapper::begin(): No writeable data available or not unique, " 185 "call TCArrayWrapper::make_unique() first or enforce the use of " 186 "'TCArrayWrapper::end() const'");
187 return m_data.get() + m_size;
201 const_iterator
end()
const{
202 return m_cdata + m_size;
222 if (m_data && m_data.unique())
227 m_data.reset(
new T[m_size], array_destructor<T>());
228 std::copy(m_cdata, m_cdata + m_size, m_data.get());
229 m_cdata = m_data.get();
234 std::shared_ptr<T> m_data;
239 template <
typename T>
240 std::ostream& operator << (std::ostream& os, const TCArrayWrapper<T>& v)
TCArrayWrapper(size_t n, bool clean=true)
*/
A wrapper around the c-array to provide an STL like interface for iterators.
const_iterator end() const
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
#define DEBUG_ASSERT_RELEASE_THROW(cond, msg...)
TCArrayWrapper(size_t n, const T *init)
TCArrayWrapper< double > CDoubleVector
TCArrayWrapper(const TCArrayWrapper< T > &other)
const_iterator begin() const
TCArrayWrapper(size_t n, T *init)
#define NS_MIA_END
conveniance define to end the mia namespace