13 #include "util/common.hpp"
14 #include "memory/PtrMemory.hpp"
15 #include "util/object_util.hpp"
16 #include "Grid/util.hpp"
17 #include "Vector/util.hpp"
18 #include "Vector/map_vector_grow_p.hpp"
19 #include "memory/ExtPreAlloc.hpp"
20 #include "util/util_debug.hpp"
21 #include "util/Pack_stat.hpp"
22 #include "Grid/map_grid.hpp"
23 #include "memory/HeapMemory.hpp"
24 #include "vect_isel.hpp"
25 #include "util/object_s_di.hpp"
30 #include "util/Pack_stat.hpp"
31 #include "memory/ExtPreAlloc.hpp"
33 #include "vect_isel.hpp"
34 #include "Packer_Unpacker/Unpacker.hpp"
35 #include "Packer_Unpacker/Packer.hpp"
87 void set(
int d,
size_t sz)
143 template<
typename T,
typename Memory,
typename grow_p,
unsigned int impl>
148 #include "map_vector_std.hpp"
165 template<
typename T,
typename Memory,
typename grow_p>
166 class vector<T,Memory,grow_p,OPENFPM_NATIVE>
191 std::vector<size_t>
getV(
size_t sz)
193 std::vector<size_t> tmp;
233 #include "vector_pack_unpack.ipp"
262 if (sp > base.size())
297 if (slot > base.size())
299 size_t gr = grow_p::grow(base.size(),slot);
326 if (v_size >= base.size())
330 non_zero_one(sz,2*base.size());
353 if (v_size >= base.size())
357 non_zero_one(sz,2*base.size());
384 if (v_size >= base.size())
388 non_zero_one(sz,2*base.size());
409 for (
size_t i = 0 ; i < v.size() ; i++)
433 for (
size_t i = 0 ; i < v.size() ; i++)
440 object_s_di<decltype(v.get(i)),decltype(
get(size()-1)),OBJ_ENCAP,args...>(v.get(i),
get(size()-1));
455 size_t s_k =
key + 1;
482 if (keys.size() <= start )
485 size_t a_key = start;
486 size_t d_k = keys.get(a_key);
487 size_t s_k = keys.get(a_key) + 1;
493 while (a_key+1 < keys.size() && s_k == keys.get(a_key+1))
496 s_k = keys.get(a_key) + 1;
510 v_size -= keys.size() - start;
530 VECTOR_OVERFLOW_NATIVE(
id)
534 return base.template get<p>(
key);
553 VECTOR_OVERFLOW_NATIVE(
id)
557 return base.get_o(
key);
573 return base.get_o(key);
593 VECTOR_OVERFLOW_NATIVE(
id)
597 return base.template get<p>(key);
616 VECTOR_OVERFLOW_NATIVE(
id)
620 return base.get_o(key);
636 return base.get_o(key);
672 :v_size(0),err_code(0)
676 check_new(
this,8,VECTOR_EVENT,1);
687 :v_size(0),err_code(0)
690 check_new(
this,8,VECTOR_EVENT,1);
697 :v_size(0),base(getV(0)),err_code(0)
700 check_new(
this,8,VECTOR_EVENT,1);
707 :v_size(sz),base(getV(sz)),err_code(0)
710 check_new(
this,8,VECTOR_EVENT,1);
727 VECTOR_OVERFLOW_NATIVE(
id)
739 void set(
size_t id,
const T & obj)
745 VECTOR_OVERFLOW_NATIVE(
id)
764 VECTOR_OVERFLOW_NATIVE(
id)
766 base.set(
id,v.
base,src);
804 size_t rsz[1] = {v_size};
808 for (
size_t i = 0 ; i < v_size ; i++ )
811 base.set(key,mv.
base,key);
824 return !this->operator==(v);
838 for (
size_t i = 0 ; i < v_size ; i++ )
842 if (base.get_o(key) != v.
base.
get_o(key))
859 size_t sz_sp = v_size;
878 size_t sz_sp = v_size;
926 return base.packObjectSize();
941 return base.packObject(mem);
954 template<
int ... prp>
static inline size_t calculateMem(
size_t n,
size_t e)
962 if (
sizeof...(prp) == 0)
963 return grow_p::grow(0,n) *
sizeof(
typename T::type);
965 typedef object<
typename object_creator<
typename T::type,prp...>::type> prp_object;
967 std::cout <<
"Inside calculateMem() (map_vector)" << std::endl;
969 return grow_p::grow(0,n) *
sizeof(prp_object);
983 template<
int ... prp>
static inline size_t packMem(
size_t n,
size_t e)
985 if (
sizeof...(prp) == 0)
986 return n *
sizeof(
typename T::type);
988 typedef object<
typename object_creator<
typename T::type,prp...>::type> prp_object;
990 std::cout <<
"Inside packMem() (map_vector)" << std::endl;
992 return n *
sizeof(prp_object);
1015 check_valid(
this,8);
1017 base.setMemory(mem);
1028 check_valid(
this,8);
1030 return base.getPointer();
1041 check_valid(
this,8);
1043 return base.getPointer();
1052 check_valid(
this,8);
1075 return check_whoami(
this,8);
1082 template <
typename T>
using vector_std = vector<T, HeapMemory, openfpm::grow_policy_double, STD_VECTOR>;
static size_t packMem(size_t n, size_t e)
Calculate the memory size required to pack n elements.
vector_key_iterator getIterator() const
Get the vector elements iterator.
It copy the properties from one object to another.
std::vector< size_t > getV(size_t sz)
Create a 1D vector that contain the vector size.
vector< T, Memory, grow_p, OPENFPM_NATIVE > & operator=(const vector< T, Memory, grow_p, OPENFPM_NATIVE > &mv)
Assignment operator.
void reserve(size_t sp)
Reserve slots in the vector to avoid reallocation.
vector() THROW
Constructor, vector of size 0.
const void * getPointer() const
Return the pointer that store the data.
grid_key_dx is the key to access any element in the grid
grid_cpu< 1, T >::memory_conf memory_conf
Type of the encapsulation memory parameter.
vector_key_iterator operator++()
Get the next element.
vector(vector< T, Memory, grow_p, OPENFPM_NATIVE > &&v)
Constructor from another temporal vector.
void setMemory(Memory &mem)
Set the memory of the base structure using an object.
void add(const typename grid_cpu< 1, T >::container &v)
It insert a new object on the vector, eventually it reallocate the vector.
~vector() THROW
Destructor.
size_t end
Linearized end element.
size_t packObject(void *mem)
Pack the object into the given pointer.
size_t err_code
Error code.
void swap(openfpm::vector< T, Memory, grow_p, OPENFPM_NATIVE > &&v)
Swap the memory with another vector.
vector_key_iterator getIteratorFrom(size_t mark) const
Get iterator over the particles from a particular index.
vector< T, Memory, grow_p, OPENFPM_NATIVE > & operator=(vector< T, Memory, grow_p, OPENFPM_NATIVE > &&mv)
Assignment operator.
vector_key_iterator(size_t end, size_t start=0)
Constructor require the size of the vector.
void set(int d, size_t sz)
Set the dimension.
vector(const vector< T, Memory, grow_p, OPENFPM_NATIVE > &v) THROW
Constructor from another constant vector.
size_t access_key
Access key for the vector.
int yes_i_am_vector
it define that it is a vector
vector(size_t sz) THROW
Constructor, vector of size sz.
bool isNext()
Check if there is the next element.
encapc< dim, T, Mem > get_o(const grid_key_dx< dim > &v1)
Get the of the selected element as a boost::fusion::vector.
static size_t calculateMem(size_t n, size_t e)
Calculate the memory size required to allocate n elements.
bool operator!=(const vector< T, Memory, grow_p, OPENFPM_NATIVE > &v) const
Check that two vectors are equal.
grid_cpu< 1, T, Memory > base
1-D static grid
grid_cpu< 1, T >::container container
Object container for T, it is the return type of get_o it return a object type trough.
size_t packObjectSize()
Return the size of the message needed to pack this object.
size_t size() const
Return the size of the vector.
size_t getLastError()
Return the last error.
void swap(openfpm::vector< T, Memory, grow_p, OPENFPM_NATIVE > &v)
Swap the memory with another vector.
void add(const vector< T, M, gp, OPENFPM_NATIVE > &v)
It add the element of another vector to this vector.
void clear()
Clear the vector.
static bool noPointers()
This class has pointer inside.
void * getPointer()
Return the pointer that store the data.
void add_prp(const vector< S, M, gp, OPENFPM_NATIVE > &v)
It add the element of a source vector to this vector.
void set(size_t id, vector< T, Memory, grow_p, OPENFPM_NATIVE > &v, size_t src)
Set the element of the vector v from another element of another vector.
static size_t calculateNMem(size_t n)
How many allocation are required to create n-elements.
T value_type
Type of the value the vector is storing.
this structure encapsulate an object of the grid
void set(size_t id, const typename grid_cpu< 1, T >::container &obj)
Set the object id to obj.
bool operator==(const vector< T, Memory, grow_p, OPENFPM_NATIVE > &v) const
Check that two vectors are not equal.
void swap(grid_cpu< dim, T, S, Mem > &grid)
It move the allocated object from one grid to another.
This class is a trick to indicate the compiler a specific specialization pattern. ...
grid_cpu< 1, T, Memory >::memory_lin memory_lin
This structure use this layout.
vector< T, Memory, grow_p, OPENFPM_NATIVE > duplicate() const
It duplicate the vector.
void non_zero_one(size_t sz[1], size_t arg)
If the argument is zero return 1 otherwise return the argument.
vector_key_iterator iterator_key
iterator for the vector
It create a boost::fusion vector with the selected properties.
void set(size_t id, const T &obj)
Set the object id to obj.
grid_cpu< 1, T >::container last()
Get the last element of the vector.
boost::fusion::result_of::at< vtype, boost::mpl::int_< p > >::type type
return a memory_c<...>
const grid_cpu< 1, T >::container last() const
Get the last element of the vector.
void add(const T &v)
It insert a new object on the vector, eventually it reallocate the grid.
Implementation of 1-D std::vector like structure.
void resize(size_t slot)
Resize the vector.
Implementation of 1-D std::vector like structure.
void add()
It insert a new emtpy object on the vector, eventually it reallocate the grid.