16#ifndef TRUSTArray_TPP_included
17#define TRUSTArray_TPP_included
21#include <TRUSTTravPool.h>
26template <
typename _TYPE_,
typename _SIZE_>
42template <
typename _TYPE_,
typename _SIZE_>
46 assert( ( mem_ ==
nullptr || (
int)mem_->size() == new_size ) ||
47 std::string(
typeid(*this).name()).find(
"TRUSTArray") != std::string::npos );
51 assert( span_.empty() || mem_ !=
nullptr );
61template <
typename _TYPE_,
typename _SIZE_>
72template <
typename _TYPE_,
typename _SIZE_>
75 storage_type_ = storage;
85template <
typename _TYPE_,
typename _SIZE_>
88 assert(ptr != 0 || size == 0);
90 assert(storage_type_ != STORAGE::TEMP_STORAGE);
92 span_ =
Span_(ptr, size);
94 data_location_ = std::make_shared<DataLocation>(DataLocation::HostOnly);
102template <
typename _TYPE_,
typename _SIZE_>
106 assert(storage_type_ != STORAGE::TEMP_STORAGE);
114template <
typename _TYPE_,
typename _SIZE_>
132template<
typename _TYPE_,
typename _SIZE_>
142template<
typename _TYPE_,
typename _SIZE_>
158template <
typename _TYPE_,
typename _SIZE_>
165template <
typename _TYPE_,
typename _SIZE_>
172template <
typename _TYPE_,
typename _SIZE_>
178template <
typename _TYPE_,
typename _SIZE_>
186template <
typename _TYPE_,
typename _SIZE_>
189 return (_SIZE_)span_.size();
195template <
typename _TYPE_,
typename _SIZE_>
198 return mem_ ? (int)mem_.use_count() : -1;
202template <
typename _TYPE_,
typename _SIZE_>
215template <
typename _TYPE_,
typename _SIZE_>
227template <
typename _TYPE_,
typename _SIZE_>
231 std::sort(span_.begin(), span_.end());
241template <
typename _TYPE_,
typename _SIZE_>
245 assert(span_.empty() && mem_ ==
nullptr);
247 assert(m.mem_ !=
nullptr || (start == 0 && size <= 0));
251 assert(! (m.mem_ ==
nullptr && !m.span_.empty()) );
256 assert(start >= 0 && size >=0 && start + size <= m.
size_array());
262 data_location_ = m.data_location_;
265 storage_type_ = m.storage_type_;
269 span_ =
Span_((_TYPE_ *)(m.span_.begin()+start), size);
276template <
typename _TYPE_,
typename _SIZE_>
281 if (storage_type_ == STORAGE::TEMP_STORAGE)
284 else if (isAllocatedOnDevice(*
this))
285 deleteOnDevice(*
this);
290 data_location_ =
nullptr;
296template<
typename _TYPE_,
typename _SIZE_>
void attach_array(const TRUSTArray &a, _SIZE_ start=0, _SIZE_ size=-1)
void resize_array_(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void append_array(_TYPE_ valeur)
_SIZE_ size_array() const
virtual void ref_array(TRUSTArray &, _SIZE_ start=0, _SIZE_ sz=-1)
TRUSTArray & inject_array(const TRUSTArray &source, _SIZE_ nb_elements=-1, _SIZE_ first_element_dest=0, _SIZE_ first_element_source=0)
virtual void resize_tab(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void set_mem_storage(const STORAGE storage)
tcb::span< _TYPE_ > Span_
_TYPE_ & operator[](_SIZE_ i)
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
virtual _SIZE_ dimension_tot(int) const
TRUSTArray & operator=(const TRUSTArray &)
virtual void ref_data(_TYPE_ *ptr, _SIZE_ size)
static void ReleaseBlock(block_ptr_t)