8#ifndef OPENFPM_DATA_SRC_VECTOR_MAP_VECTOR_STD_PTR_HPP_
9#define OPENFPM_DATA_SRC_VECTOR_MAP_VECTOR_STD_PTR_HPP_
12template<
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);\
This class give memory from a preallocated memory, memory destruction is not performed.
virtual size_t size() const
the the size of the allocated memory
virtual void * getPointer()
get a readable pointer with the data
Implementation of 1-D std::vector like structure.
void erase(typename std::vector< T >::iterator start, typename std::vector< T >::iterator end)
Erase the elements from start to end.
void remove(size_t key)
Remove one entry from the vector.
void add()
Add an empty object (it call the default constructor () ) at the end of the vector.
bool operator==(const vector< T, HeapMemory, layout_base, grow_policy_double, STD_VECTOR > &v) const
Check that two vectors are not equal.
vector(const vector< T, PtrMemory, layout_base, gp, STD_VECTOR > &v) noexcept
Constructor from another vector.
~vector() noexcept
destructor
void add(T &&v)
It insert a new object on the vector, eventually it reallocate the grid.
T value_type
Type of the value the vector is storing.
int yes_i_am_vector
it define that it is a vector
static bool noPointers()
This class has pointer inside.
void add(const T &v)
It insert a new object on the vector, eventually it reallocate the grid.
void clear()
Remove all the element from the vector.
bool operator!=(const vector< T, HeapMemory, layout_base, grow_policy_double, STD_VECTOR > &v) const
Check that two vectors are equal.
const T * end() const
Return an std compatible iterator to the past the last element.
T & get(size_t id)
Get an element of the vector.
T * begin()
Return an std compatible iterator to the first element.
size_t size() const
return the size of the vector
vector(size_t sz) noexcept
Constructor, vector of size sz.
T & get(size_t id)
Get an element of the vector.
const T & last() const
Get the last element.
vector_key_iterator iterator_key
iterator for the vector
vector() noexcept
Constructor, vector of size 0.
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.
const T & get(size_t id) const
Get an element of the vector.
const T * begin() const
Return an std compatible iterator to the first element.
void reserve(size_t ns)
reserve a memory space in advance to avoid reallocation
size_t err_code
Error code.
PtrMemory * mem
1-D static grid
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.
const T & get(size_t id) const
Get an element of the vector.
vector(vector< T, PtrMemory, layout_base, gp, STD_VECTOR > &&v) noexcept
Constructor from another vector.
void fill(unsigned char fl)
it fill all the memory of fl patterns
void swap(openfpm::vector< T, PtrMemory, layout_base, gp, STD_VECTOR > &v)
size_t getLastError()
Return the last error.
memory_traits_lin< T >::type layout
Memory layout.
T * end()
Return an std compatible iterator to the past the last element.
void vector_overflow(size_t v1) const
check that the id does not overflow the buffer
const void * getPointer() const
Return the pointer to the chunk of memory.
void * getPointer()
Return the pointer to the chunk of memory.
vector_key_iterator getIterator() const
Get iterator.
T & last()
Get the last element.
Transform the boost::fusion::vector into memory specification (memory_traits)