OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
map_vector.hpp
1 /*
2  * map_vector.hpp
3  *
4  * Created on: Aug 30, 2014
5  * Author: Pietro Incardona
6  */
7 
8 #ifndef MAP_VECTOR_HPP
9 #define MAP_VECTOR_HPP
10 
11 #include <iostream>
12 #include <typeinfo>
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"
26 #include "util.hpp"
27 #ifdef HAVE_MPI
28 #include <mpi.h>
29 #endif
30 #include "util/Pack_stat.hpp"
31 #include "memory/ExtPreAlloc.hpp"
32 #include <string.h>
33 #include "Packer_Unpacker/Unpacker.hpp"
34 #include "Packer_Unpacker/Packer.hpp"
35 #include <fstream>
36 #include "Packer_Unpacker/Packer_util.hpp"
37 #include "Packer_Unpacker/has_pack_agg.hpp"
38 #include "timer.hpp"
39 #include "map_vector_std_util.hpp"
40 #include "data_type/aggregate.hpp"
41 #include "vector_map_iterator.hpp"
42 
43 namespace openfpm
44 {
45 
60  template<typename T, typename Memory, typename layout, template<typename> class layout_base, typename grow_p, unsigned int impl>
61  class vector
62  {
70  size_t size()
71  {
72  std::cerr << __FILE__ << ":" << __LINE__ << " Error stub vector created" << std::endl;
73  return 0;
74  }
75  };
76 
77  #include "map_vector_std.hpp"
78  #include "map_vector_std_ptr.hpp"
79 
95  template<typename T,typename Memory, typename layout, template <typename> class layout_base, typename grow_p>
96  class vector<T,Memory,layout,layout_base,grow_p,OPENFPM_NATIVE>
97  {
101  size_t v_size;
105 
112  void non_zero_one(size_t sz[1], size_t arg)
113  {
114  if (arg == 0)
115  {sz[0] = 1;}
116  else
117  {sz[0] = arg;}
118  }
120 #ifdef SE_CLASS1
128  void check_overflow(size_t id) const
129  {
130  if (id >= v_size)
131  {
132  std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " overflow id: " << id << "\n";
133  ACTION_ON_ERROR(VECTOR_ERROR_OBJECT);
134  }
135  }
136 
137 #endif
138 
139  public:
140 
142  typedef int yes_i_am_vector;
145  typedef layout layout_type;
146 
149 
151  // you can access all the properties of T
155  typedef T value_type;
156 
157  // Implementation of packer and unpacker for vector
158 #include "vector_pack_unpack.ipp"
165  size_t size() const
166  {
167 #ifdef SE_CLASS2
168  check_valid(this,8);
169 #endif
170  return v_size;
171  }
172 
181  void reserve(size_t sp)
182  {
183 #ifdef SE_CLASS2
184  check_valid(this,8);
185 #endif
186  if (sp > base.size())
187  {
189  size_t sz[1] = {sp};
190  base.resize(sz);
191  }
192  }
193 
199  void clear()
200  {
201 #ifdef SE_CLASS2
202  check_valid(this,8);
203 #endif
204  resize(0);
205  }
206 
214  void resize(size_t slot)
215  {
216 #ifdef SE_CLASS2
217  check_valid(this,8);
218 #endif
219  // If we need more space than what we allocated, allocate new memory
220 
221  if (slot > base.size())
222  {
223  size_t gr = grow_p::grow(base.size(),slot);
224 
226  size_t sz[1] = {gr};
227  base.resize(sz);
228  }
229 
230  // update the vector size
231  v_size = slot;
232  }
233 
235  typedef size_t access_key;
236 
243  void add()
244  {
245 #ifdef SE_CLASS2
246  check_valid(this,8);
247 #endif
250  if (v_size >= base.size())
251  {
253  size_t sz[1];
254  non_zero_one(sz,2*base.size());
255  base.resize(sz);
256  }
257 
259  v_size++;
260  }
261 
270  void add(const T & v)
271  {
272 #ifdef SE_CLASS2
273  check_valid(this,8);
274 #endif
275 
277  if (v_size >= base.size())
278  {
280  size_t sz[1];
281  non_zero_one(sz,2*base.size());
282  base.resize(sz);
283  }
284 
286  base.set(v_size,v);
287 
289  v_size++;
290  }
291 
301  void add(const typename grid_cpu<1,T,Memory,typename layout_base<T>::type>::container & v)
302  {
303 #ifdef SE_CLASS2
304  check_valid(this,8);
305 #endif
306 
308  if (v_size >= base.size())
309  {
311  size_t sz[1];
312  non_zero_one(sz,2*base.size());
313  base.resize(sz);
314  }
315 
317  base.set(v_size,v);
318 
320  v_size++;
321  }
322 
328  template <typename M, typename gp> void add(const vector<T, M,layout, layout_base,gp,OPENFPM_NATIVE> & v)
329  {
330 #ifdef SE_CLASS2
331  check_valid(this,8);
332 #endif
333  for (size_t i = 0 ; i < v.size() ; i++)
335  add(v.get(i));
336  }
337 
373  template <template<typename,typename> class op, typename S, typename M, typename gp, unsigned int ...args>
374  void merge_prp(const vector<S,M,typename layout_base<S>::type,layout_base,gp,OPENFPM_NATIVE> & v,
375  const openfpm::vector<size_t> & opart)
376  {
377 #ifdef SE_CLASS2
378  check_valid(this,8);
379 #endif
380 #ifdef SE_CLASS1
381 
382  if (v.size() != opart.size())
383  std::cerr << __FILE__ << ":" << __LINE__ << " error merge_prp: v.size()=" << v.size() << " must be the same as o_part.size()" << opart.size() << std::endl;
385 #endif
386  for (size_t i = 0 ; i < v.size() ; i++)
388  {
389 #ifdef SE_CLASS1
390 
391  if (opart.get(i) > size())
392  std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " try to access element " << opart.get(i) << " but the vector has size " << size() << std::endl;
393 
394 #endif
395  // write the object in the last element
396  object_s_di_op<op,decltype(v.get(i)),decltype(get(size()-1)),OBJ_ENCAP,args...>(v.get(i),get(opart.get(i)));
397  }
398  }
399 
400 
436  template <template<typename,typename> class op,
437  typename S,
438  typename M,
439  typename gp,
440  template <typename> class layout_base2,
441  unsigned int ...args>
442  void merge_prp_v(const vector<S,M,typename layout_base2<S>::type,layout_base2,gp,OPENFPM_NATIVE> & v,
444  {
445 #ifdef SE_CLASS2
446  check_valid(this,8);
447 #endif
448 #ifdef SE_CLASS1
449 
450  if (v.size() != opart.size())
451  std::cerr << __FILE__ << ":" << __LINE__ << " error merge_prp: v.size()=" << v.size() << " must be the same as o_part.size()" << opart.size() << std::endl;
452 
453 #endif
454  for (size_t i = 0 ; i < v.size() ; i++)
456  {
457 #ifdef SE_CLASS1
458 
459  if (i >= opart.size())
460  std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " try to access element " << opart.template get<0>(i) << " but the vector has size " << size() << std::endl;
461 
462 #endif
463  // write the object in the last element
464  object_s_di_op<op,decltype(v.get(i)),decltype(get(size()-1)),OBJ_ENCAP,args...>(v.get(i),get(opart.template get<0>(i)));
465  }
466  }
467 
503  template <template<typename,typename> class op,
504  typename S,
505  typename M,
506  typename gp,
507  template <typename> class layout_base2,
508  unsigned int ...args>
509  void merge_prp_v(const vector<S,M,typename layout_base2<S>::type,layout_base2,gp,OPENFPM_NATIVE> & v,
510  size_t start)
511  {
512 #ifdef SE_CLASS2
513  check_valid(this,8);
514 #endif
515  for (size_t i = 0 ; i < v.size() ; i++)
517  {
518 #ifdef SE_CLASS1
519 
520  if (start + i >= v_size)
521  std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " try to access element " << start+i << " but the vector has size " << size() << std::endl;
523 #endif
524  // write the object in the last element
525  object_s_di_op<op,decltype(v.get(0)),decltype(get(0)),OBJ_ENCAP,args...>(v.get(i),get(start+i));
526  }
527  }
528 
543  template <typename S,
544  typename M,
545  typename gp,
546  unsigned int impl,
547  template <typename> class layout_base2,
548  unsigned int ...args>
549  void add_prp(const vector<S,M,typename layout_base2<S>::type,layout_base2,gp,impl> & v)
550  {
551 #ifdef SE_CLASS2
552  check_valid(this,8);
553 #endif
554  for (size_t i = 0 ; i < v.size() ; i++)
556  {
557  // Add a new element
558  add();
559 
560  // write the object in the last element
561  object_s_di<decltype(v.get(i)),decltype(get(size()-1)),OBJ_ENCAP,args...>(v.get(i),get(size()-1));
562  }
563  }
564 
570  void insert(size_t key)
571  {
572 #ifdef SE_CLASS2
573  check_valid(this,8);
574 #endif
575  add();
576 
577  long int d_k = (long int)size()-1;
578  long int s_k = (long int)size()-2;
579 
580  // keys
581  while (s_k >= (long int)key)
582  {
583  set(d_k,get(s_k));
584  d_k--;
585  s_k--;
586  }
587  }
588 
589 
595  void remove(size_t key)
596  {
597 #ifdef SE_CLASS2
598  check_valid(this,8);
599 #endif
600  size_t d_k = key;
601  size_t s_k = key + 1;
602 
603  // keys
604  while (s_k < size())
605  {
606  set(d_k,get(s_k));
607  d_k++;
608  s_k++;
609  }
610 
611  // re-calculate the vector size
613  v_size--;
614  }
615 
624  void remove(openfpm::vector<size_t> & keys, size_t start = 0)
625  {
626 #ifdef SE_CLASS2
627  check_valid(this,8);
628 #endif
629  // Nothing to remove return
630  if (keys.size() <= start )
631  return;
632 
633  size_t a_key = start;
634  size_t d_k = keys.get(a_key);
635  size_t s_k = keys.get(a_key) + 1;
636 
637  // keys
638  while (s_k < size())
639  {
640  // s_k should always point to a key that is not going to be deleted
641  while (a_key+1 < keys.size() && s_k == keys.get(a_key+1))
642  {
643  a_key++;
644  s_k = keys.get(a_key) + 1;
645  }
646 
647  // In case of overflow
648  if (s_k >= size())
649  break;
650 
651  set(d_k,get(s_k));
652  d_k++;
653  s_k++;
654  }
655 
656  // re-calculate the vector size
657 
658  v_size -= keys.size() - start;
659  }
660 
672  template <unsigned int p>
673  inline auto get(size_t id) const -> decltype(base.template get<p>(grid_key_dx<1>(0)))
674  {
675 #ifdef SE_CLASS2
676  check_valid(this,8);
677 #endif
678 #ifdef SE_CLASS1
679  check_overflow(id);
680 #endif
681  grid_key_dx<1> key(id);
682 
683  return base.template get<p>(key);
684  }
685 
695  inline auto get(size_t id) -> decltype(base.get_o(grid_key_dx<1>(id)))
696  {
697 #ifdef SE_CLASS2
698  check_valid(this,8);
699 #endif
700 #ifdef SE_CLASS1
701  check_overflow(id);
702 #endif
703  grid_key_dx<1> key(id);
704 
705  return base.get_o(key);
706  }
707 
717  inline auto get(size_t id) const -> const decltype(base.get_o(grid_key_dx<1>(id)))
718  {
719 #ifdef SE_CLASS2
720  check_valid(this,8);
721 #endif
722 #ifdef SE_CLASS1
723  check_overflow(id);
724 #endif
725  grid_key_dx<1> key(id);
727  return base.get_o(key);
728  }
729 
743  {
744 #ifdef SE_CLASS2
745  check_valid(this,8);
746 #endif
747 #ifdef SE_CLASS1
748  check_overflow(id);
749 #endif
750  grid_key_dx<1> key(id);
751 
752  return base.get_o(key);
753  }
754 
762  {
763 #ifdef SE_CLASS2
764  check_valid(this,8);
765 #endif
766  grid_key_dx<1> key(size()-1);
767 
768  return base.get_o(key);
769  }
770 
782  template <unsigned int p>
783  inline auto get(size_t id) -> decltype(base.template get<p>(grid_key_dx<1>(0)))
784  {
785 #ifdef SE_CLASS2
786  check_valid(this,8);
787 #endif
788 #ifdef SE_CLASS1
789  check_overflow(id);
790 #endif
791  grid_key_dx<1> key(id);
792 
793  return base.template get<p>(key);
794  }
795 
803  {
804 #ifdef SE_CLASS2
805  check_valid(this,8);
806 #endif
807  grid_key_dx<1> key(size()-1);
808 
809  return base.get_o(key);
810  }
811 
813  ~vector() THROW
814  {
815  // Eliminate the pointer
816  #ifdef SE_CLASS2
817  check_delete(this);
818  #endif
819  }
820 
827  {
828 #ifdef SE_CLASS2
829  check_valid(this,8);
830 #endif
832 
833  dup.v_size = v_size;
834  dup.base.swap(base.duplicate());
835 
836  return dup;
837  }
838 
845  :v_size(0)
846  {
847  // Add this pointer
848 #ifdef SE_CLASS2
849  check_new(this,8,VECTOR_EVENT,1);
850 #endif
851  swap(v);
852  }
860  :v_size(0)
861  {
862 #ifdef SE_CLASS2
863  check_new(this,8,VECTOR_EVENT,1);
864 #endif
865  swap(v.duplicate());
866  }
867 
869  vector() THROW
870  :v_size(0),base(0)
871  {
872 #ifdef SE_CLASS2
873  check_new(this,8,VECTOR_EVENT,1);
874 #endif
875  base.setMemory();
876  }
877 
879  vector(size_t sz) THROW
880  :v_size(sz),base(sz)
881  {
882 #ifdef SE_CLASS2
883  check_new(this,8,VECTOR_EVENT,1);
884 #endif
885  base.setMemory();
886  }
887 
894  void set(size_t id, const typename grid_cpu<1,T,Memory,typename layout_base<T>::type>::container & obj)
895  {
896 #ifdef SE_CLASS2
897  check_valid(this,8);
898 #endif
899 #ifdef SE_CLASS1
900  check_overflow(id);
901 #endif
902  base.set(id,obj);
904  }
905 
921  template <typename encap_S, unsigned int ...args> void set_o(size_t i, const encap_S & obj)
922  {
923 #ifdef SE_CLASS2
924  check_valid(this,8);
925 #endif
926 
927  // write the object in the last element
928  object_s_di<encap_S,decltype(get(i)),OBJ_ENCAP,args...>(obj,get(i));
929  }
930 
937  void set(size_t id, const T & obj)
938  {
939 #ifdef SE_CLASS2
940  check_valid(this,8);
941 #endif
942 #ifdef SE_CLASS1
943  check_overflow(id);
944 #endif
945  base.set(id,obj);
947  }
948 
957  {
958 #ifdef SE_CLASS2
959  check_valid(this,8);
960 #endif
961 #ifdef SE_CLASS1
962  check_overflow(id);
963 #endif
964  base.set(id,v.base,src);
965  }
966 
977  {
978 #ifdef SE_CLASS2
979  check_valid(this,8);
980 #endif
981  v_size = mv.v_size;
982  base.swap(mv.base);
983 
984  return *this;
985  }
986 
997  {
998 #ifdef SE_CLASS2
999  check_valid(this,8);
1000 #endif
1001  v_size = mv.v_size;
1002  size_t rsz[1] = {v_size};
1003  if (base.size() < v_size)
1004  base.resize(rsz);
1005 
1006  // copy the object
1007  for (size_t i = 0 ; i < v_size ; i++ )
1008  {
1009  grid_key_dx<1> key(i);
1010  base.set(key,mv.base,key);
1011  }
1012 
1013  return *this;
1014  }
1026  {
1027 #ifdef SE_CLASS2
1028  check_valid(this,8);
1029 #endif
1030  v_size = mv.v_size;
1031  base.swap(mv.base);
1032 
1033  return *this;
1034  }
1035 
1046  {
1047 #ifdef SE_CLASS2
1048  check_valid(this,8);
1049 #endif
1050  v_size = mv.getInternal_v_size();
1051  size_t rsz[1] = {v_size};
1052  base.resize(rsz);
1053 
1054  // copy the object
1055  for (size_t i = 0 ; i < v_size ; i++ )
1056  {
1057  grid_key_dx<1> key(i);
1058  base.set(key,mv.getInternal_base(),key);
1059  }
1060 
1061  return *this;
1062  }
1063 
1070  {
1071  return !this->operator==(v);
1072  }
1073 
1080  {
1081  if (v_size != v.v_size)
1082  return false;
1083 
1084  // check object by object
1085  for (size_t i = 0 ; i < v_size ; i++ )
1086  {
1087  grid_key_dx<1> key(i);
1088 
1089  if (base.get_o(key) != v.base.get_o(key))
1090  return false;
1091  }
1092 
1093  return true;
1094  }
1095 
1102  {
1103 #ifdef SE_CLASS2
1104  check_valid(this,8);
1105 #endif
1106  size_t sz_sp = v_size;
1107 
1108  // swap the v_size
1109  v_size = v.v_size;
1110 
1111  base.swap(v.base);
1112  v.v_size = sz_sp;
1113  }
1114 
1121  {
1122 #ifdef SE_CLASS2
1123  check_valid(this,8);
1124 #endif
1125  size_t sz_sp = v_size;
1126 
1127  // swap the v_size
1128  v_size = v.v_size;
1129 
1130  base.swap(v.base);
1131  v.v_size = sz_sp;
1132  }
1133 
1142  {
1143 #ifdef SE_CLASS2
1144  check_valid(this,8);
1145 #endif
1146  return vector_key_iterator(v_size,start);
1147  }
1148 
1159  {
1160 #ifdef SE_CLASS2
1161  check_valid(this,8);
1162 #endif
1163  return vector_key_iterator(stop,0);
1164  }
1165 
1174  {
1175 #ifdef SE_CLASS2
1176  check_valid(this,8);
1177 #endif
1178  return vector_key_iterator(v_size);
1179  }
1180 
1188  {
1189 #ifdef SE_CLASS2
1190  check_valid(this,8);
1191 #endif
1192  return base.packObjectSize();
1193  }
1194 
1202  size_t packObject(void * mem)
1203  {
1204 #ifdef SE_CLASS2
1205  check_valid(this,8);
1206 #endif
1207  return base.packObject(mem);
1208  }
1209 
1220  template<int ... prp> static inline size_t calculateMem(size_t n, size_t e)
1221  {
1222  if (n == 0)
1223  {
1224  return 0;
1225  }
1226  else
1227  {
1228  if (sizeof...(prp) == 0)
1229  return grow_p::grow(0,n) * sizeof(typename T::type);
1230 
1231  typedef object<typename object_creator<typename T::type,prp...>::type> prp_object;
1232 
1233  return grow_p::grow(0,n) * sizeof(prp_object);
1234  }
1235  }
1236 
1247  template<int ... prp> static inline size_t packMem(size_t n, size_t e)
1248  {
1249  if (sizeof...(prp) == 0)
1250  return n * sizeof(typename T::type);
1251 
1252  typedef object<typename object_creator<typename T::type,prp...>::type> prp_object;
1253 
1254  return n * sizeof(prp_object);
1255  }
1256 
1264  inline static size_t calculateNMem(size_t n)
1265  {
1266  return 1;
1267  }
1268 
1274  void setMemory(Memory & mem)
1275  {
1276 #ifdef SE_CLASS2
1277  check_valid(this,8);
1278 #endif
1279  base.setMemory(mem);
1280  }
1281 
1287  void * getPointer()
1288  {
1289 #ifdef SE_CLASS2
1290  check_valid(this,8);
1291 #endif
1292  return base.getPointer();
1293  }
1294 
1300  const void * getPointer() const
1301  {
1302 #ifdef SE_CLASS2
1303  check_valid(this,8);
1304 #endif
1305  return base.getPointer();
1306  }
1307 
1313  static bool noPointers()
1314  {
1315  return false;
1316  }
1317 
1318  /* \brief It return the id of structure in the allocation list
1319  *
1320  * \see print_alloc and SE_CLASS2
1321  *
1322  */
1323  long int who()
1324  {
1325 #ifdef SE_CLASS2
1326  return check_whoami(this,8);
1327 #else
1328  return -1;
1329 #endif
1330  }
1331 
1337  const size_t & getInternal_v_size() const
1338  {
1339  return v_size;
1340  }
1341 
1348  {
1349  return base;
1350  }
1351  };
1352 
1353  template <typename T> using vector_std = vector<T, HeapMemory, typename memory_traits_lin<T>::type, memory_traits_lin, openfpm::grow_policy_double, STD_VECTOR>;
1354 
1355 }
1356 
1357 #endif
It copy the properties from one object to another.
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:96
void set(size_t id, const T &obj)
Set the object id to obj.
Definition: map_vector.hpp:937
void merge_prp_v(const vector< S, M, typename layout_base2< S >::type, layout_base2, gp, OPENFPM_NATIVE > &v, size_t start)
It merge the elements of a source vector to this vector.
Definition: map_vector.hpp:509
Transform the boost::fusion::vector into memory specification (memory_traits)
Definition: memory_conf.hpp:93
const grid_cpu< 1, T, Memory, layout > & getInternal_base() const
Internal function.
layout layout_type
Type of the encapsulation memory parameter.
Definition: map_vector.hpp:145
Grow policy define how the vector should grow every time we exceed the size.
grid_key_dx is the key to access any element in the grid
Definition: grid_key.hpp:18
size_t packObject(void *mem)
Pack the object into the given pointer.
void swap(openfpm::vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &&v)
Swap the memory with another vector.
void * getPointer()
Return the pointer that store the data.
vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > duplicate() const
It duplicate the vector.
Definition: map_vector.hpp:826
size_t size()
Stub size.
Definition: map_vector.hpp:70
vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > & operator=(const vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &mv)
Assignment operator.
Definition: map_vector.hpp:996
void insert(size_t key)
Insert an entry in the vector.
Definition: map_vector.hpp:570
void reserve(size_t sp)
Reserve slots in the vector to avoid reallocation.
Definition: map_vector.hpp:181
vector(size_t sz) THROW
Constructor, vector of size sz.
Definition: map_vector.hpp:879
grid_cpu< 1, T, Memory, typename layout_base< T >::type > base
1-D static grid
Definition: map_vector.hpp:104
size_t packObjectSize()
Return the size of the message needed to pack this object.
void add(const typename grid_cpu< 1, T, Memory, typename layout_base< T >::type >::container &v)
It insert a new object on the vector, eventually it reallocate the vector.
Definition: map_vector.hpp:301
void set(size_t id, const typename grid_cpu< 1, T, Memory, typename layout_base< T >::type >::container &obj)
Set the object id to obj.
Definition: map_vector.hpp:894
void setMemory(Memory &mem)
Set the memory of the base structure using an object.
vector_key_iterator getIterator() const
Get the vector elements iterator.
void non_zero_one(size_t sz[1], size_t arg)
If the argument is zero return 1 otherwise return the argument.
Definition: map_vector.hpp:112
static size_t packMem(size_t n, size_t e)
Calculate the memory size required to pack n elements.
const grid_cpu< 1, T, Memory, typename layout_base< T >::type >::container last() const
Get the last element of the vector.
Definition: map_vector.hpp:761
const void * getPointer() const
Return the pointer that store the data.
void add(const T &v)
It insert a new object on the vector, eventually it reallocate the grid.
Definition: map_vector.hpp:270
vector(const vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &v) THROW
Constructor from another constant vector.
Definition: map_vector.hpp:859
It copy the properties from one object to another applying an operation.
void set(size_t id, vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &v, size_t src)
Set the element of the vector v from another element of another vector.
Definition: map_vector.hpp:956
vector(vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &&v)
Constructor from another temporal vector.
Definition: map_vector.hpp:844
vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > & operator=(const vector< T, Mem, layout, layout_base, gp, OPENFPM_NATIVE > &mv)
Assignment operator.
vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > & operator=(vector< T, Mem, layout, layout_base, gp, OPENFPM_NATIVE > &&mv)
Assignment operator.
void merge_prp_v(const vector< S, M, typename layout_base2< S >::type, layout_base2, gp, OPENFPM_NATIVE > &v, const openfpm::vector< aggregate< size_t, size_t >> &opart)
It merge the elements of a source vector to this vector.
Definition: map_vector.hpp:442
bool operator==(const vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &v) const
Check that two vectors are not equal.
void add()
It insert a new emtpy object on the vector, eventually it reallocate the grid.
Definition: map_vector.hpp:243
void swap(openfpm::vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &v)
Swap the memory with another vector.
void set_o(size_t i, const encap_S &obj)
It set an element of the vector from a object that is a subset of the vector properties.
Definition: map_vector.hpp:921
This class is a trick to indicate the compiler a specific specialization pattern. ...
Definition: memory_c.hpp:201
vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > & operator=(vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &&mv)
Assignment operator.
Definition: map_vector.hpp:976
const grid_cpu< 1, T, Memory, typename layout_base< T >::type >::container get_o(size_t id) const
Get an element of the vector.
Definition: map_vector.hpp:742
void merge_prp(const vector< S, M, typename layout_base< S >::type, layout_base, gp, OPENFPM_NATIVE > &v, const openfpm::vector< size_t > &opart)
It merge the elements of a source vector to this vector.
Definition: map_vector.hpp:374
vector_key_iterator getIteratorTo(size_t stop) const
Get iterator over the particles from 0 until a particular index.
It create a boost::fusion vector with the selected properties.
void add(const vector< T, M, layout, layout_base, gp, OPENFPM_NATIVE > &v)
It add the element of another vector to this vector.
Definition: map_vector.hpp:328
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Definition: aggregate.hpp:81
static size_t calculateMem(size_t n, size_t e)
Calculate the memory size required to allocate n elements.
grid_cpu< 1, T, Memory, typename layout_base< T >::type >::container last()
Get the last element of the vector.
Definition: map_vector.hpp:802
bool operator!=(const vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &v) const
Check that two vectors are equal.
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61
static size_t calculateNMem(size_t n)
How many allocation are required to create n-elements.
vector_key_iterator getIteratorFrom(size_t start) const
Get iterator over the particles from a particular index.
grid_cpu< 1, T, Memory, typename layout_base< T >::type >::container container
Object container for T, it is the return type of get_o it return a object type trough.
Definition: map_vector.hpp:152