8 #ifndef OPENFPM_DATA_SRC_VECTOR_MAP_VECTOR_STD_PTR_HPP_ 9 #define OPENFPM_DATA_SRC_VECTOR_MAP_VECTOR_STD_PTR_HPP_ 12 template<
typename T,
typename gp>
57 if (slot > mem->
size()/
sizeof(T))
58 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: this vector cannot be bigger than " << mem->
size()/
sizeof(T) <<
" elements\n";
79 inline void add(
const T & v)
81 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: you cannot add a new element to this vector \n";
93 inline void add(T && v)
95 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: you cannot add new element to this vector \n";
106 if (v_size > mem->
size()/
sizeof(T))
107 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: you cannot resize a PtrMemory vector over the size stored by PtrMemory";
116 void erase(
typename std::vector<T>::iterator start,
typename std::vector<T>::iterator end)
118 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: you cannot erase element from this vector \n";
129 vector_overflow(key);
131 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: you cannot remove elements from this vector \n";
169 inline const T *
end()
const 183 std::cerr <<
"Error vector: " << __FILE__ <<
":" << __LINE__ <<
" vector of size 0\n";
197 std::cerr <<
"Error vector: " << __FILE__ <<
":" << __LINE__ <<
" vector of size 0" << std::endl;
211 template <
unsigned int p>
inline T&
get(
size_t id)
215 {std::cerr <<
"Error the property does not exist" <<
"\n";}
237 template <
unsigned int p>
inline const T&
get(
size_t id)
const 241 {std::cerr <<
"Error the property does not exist" <<
"\n";}
260 std::cerr <<
"Error vector: " << __FILE__ <<
":" << __LINE__ <<
" overflow id: " <<
id <<
"\n";
272 inline const T &
get(
size_t id)
const 289 inline void fill(
unsigned char fl)
291 memset(mem->
getPointer(),fl,v_size *
sizeof(T));
306 :v_size(0),mem(NULL),err_code(0)
312 :v_size(sz),err_code(0)
317 vector(
const vector<T,PtrMemory,layout_base,gp,STD_VECTOR> & v) noexcept
318 :v_size(0),err_code(0)
320 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: copy constructor is not supported by this vector \n";
325 vector(vector<T,PtrMemory,layout_base,gp,STD_VECTOR> && v) noexcept
326 :v_size(0),err_code(0)
328 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: copy constructor is not supported by this vector \n";
343 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: swap is not supported by this vector \n";
351 vector<T,HeapMemory,layout_base,grow_policy_double,STD_VECTOR> &
operator=(
const vector<T,HeapMemory,layout_base,grow_policy_double,STD_VECTOR> & v)
353 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: operator= is not supported by this vector \n";
365 vector<T,HeapMemory,layout_base,grow_policy_double,STD_VECTOR> &
operator=(vector<T,HeapMemory,layout_base,grow_policy_double,STD_VECTOR> && v)
367 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: operator= is not supported by this vector \n";
379 bool operator!=(
const vector<T, HeapMemory, layout_base,grow_policy_double,STD_VECTOR> & v)
const 381 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: operator!= is not supported by this vector \n";
393 bool operator==(
const vector<T, HeapMemory, layout_base,grow_policy_double,STD_VECTOR> & v)
const 395 std::cerr << __FILE__ <<
":" << __LINE__ <<
" error: operator== is not supported by this vector \n";
407 return vector_key_iterator(v_size);
415 template<
unsigned int ... prp>
void hostToDevice()
421 template<
unsigned int ... prp>
void deviceToHost()
428 template<
unsigned int ... prp>
void deviceToHost(
size_t start,
size_t stop)
482 std::cerr <<
"Error vector: " << __FILE__ <<
":" << __LINE__ <<
" overflow id: " << v1 <<
"\n";\
483 size_t * err_code_pointer = (
size_t *)&this->err_code;\
484 *err_code_pointer = 2001;\
485 ACTION_ON_ERROR(VECTOR_ERROR_OBJECT);\
bool operator!=(const vector< T, HeapMemory, layout_base, grow_policy_double, STD_VECTOR > &v) const
Check that two vectors are equal.
size_t size() const
return the size of the vector
vector< T, HeapMemory, layout_base, grow_policy_double, STD_VECTOR > & operator=(const vector< T, HeapMemory, layout_base, grow_policy_double, STD_VECTOR > &v)
Operator= copy the vector into another.
vector_key_iterator getIterator() const
Get iterator.
const T & get(size_t id) const
Get an element of the vector.
Transform the boost::fusion::vector into memory specification (memory_traits)
virtual size_t size() const
the the size of the allocated memory
void * getPointer()
Return the pointer to the chunk of memory.
const void * getPointer() const
Return the pointer to the chunk of memory.
void add()
Add an empty object (it call the default constructor () ) at the end of the vector.
vector_key_iterator iterator_key
iterator for the vector
vector(size_t sz) noexcept
Constructor, vector of size sz.
const T * end() const
Return an std compatible iterator to the past the last element.
size_t getLastError()
Return the last error.
T & get(size_t id)
Get an element of the vector.
size_t err_code
Error code.
int yes_i_am_vector
it define that it is a vector
vector< T, HeapMemory, layout_base, grow_policy_double, STD_VECTOR > & operator=(vector< T, HeapMemory, layout_base, grow_policy_double, STD_VECTOR > &&v)
Operator= copy the vector into another.
void add(T &&v)
It insert a new object on the vector, eventually it reallocate the grid.
vector(const vector< T, PtrMemory, layout_base, gp, STD_VECTOR > &v) noexcept
Constructor from another vector.
void add(const T &v)
It insert a new object on the vector, eventually it reallocate the grid.
void reserve(size_t ns)
reserve a memory space in advance to avoid reallocation
const T & last() const
Get the last element.
bool operator==(const vector< T, HeapMemory, layout_base, grow_policy_double, STD_VECTOR > &v) const
Check that two vectors are not equal.
void erase(typename std::vector< T >::iterator start, typename std::vector< T >::iterator end)
Erase the elements from start to end.
T * end()
Return an std compatible iterator to the past the last element.
~vector() noexcept
destructor
T & last()
Get the last element.
void remove(size_t key)
Remove one entry from the vector.
void vector_overflow(size_t v1) const
check that the id does not overflow the buffer
T & get(size_t id)
Get an element of the vector.
void swap(openfpm::vector< T, PtrMemory, layout_base, gp, STD_VECTOR > &v)
vector() noexcept
Constructor, vector of size 0.
const T & get(size_t id) const
Get an element of the vector.
virtual void * getPointer()
get a readable pointer with the data
const T * begin() const
Return an std compatible iterator to the first element.
void fill(unsigned char fl)
it fill all the memory of fl patterns
void clear()
Remove all the element from the vector.
Implementation of 1-D std::vector like structure.
PtrMemory * mem
1-D static grid
static bool noPointers()
This class has pointer inside.
T value_type
Type of the value the vector is storing.
T * begin()
Return an std compatible iterator to the first element.
vector(vector< T, PtrMemory, layout_base, gp, STD_VECTOR > &&v) noexcept
Constructor from another vector.
memory_traits_lin< T >::type layout
Memory layout.
This class give memory from a preallocated memory, memory destruction is not performed.