OpenFPM  5.2.0
Project that contain the implementation of distributed structures
map_vector_std.hpp
1 /*
2  * map_vector_std.hpp
3  *
4  * Created on: Mar 8, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef MAP_VECTOR_STD_HPP_
9 #define MAP_VECTOR_STD_HPP_
10 
11 #include "se_vector.hpp"
12 #include "map_vector_std_ptr.hpp"
13 
14 #define OBJECT_ADD false
15 #define VECTOR_ADD true
16 
18 template<bool objv, typename vect_dst>
20 {
36  template <typename S, typename M, typename gp, unsigned int impl, unsigned int ...args>
37  inline static void add(const vector<S,M,memory_traits_lin,gp,impl> & v_src, vect_dst & v_dst)
38  {
40  for (size_t i = 0 ; i < v_src.size() ; i++)
41  {
42  // Add a new element
43  v_dst.add();
44 
45  // equal object
46  v_dst.get(v_dst.size()-1) = v_src.get(i);
47  }
48  }
49 };
50 
52 template<typename vect_dst>
53 struct add_prp_impl<OBJECT_ADD,vect_dst>
54 {
70  template <typename S, typename M, typename gp, unsigned int impl, unsigned int ...args> inline static void add(const vector<S,M,memory_traits_lin,gp,impl> & v_src, vect_dst & v_dst)
71  {
72  // Add a new element
73  v_dst.add();
74 
75  // equal object
76  v_dst.get(v_dst.size()-1) = v_src;
77  }
78 };
79 
80 
92 template<typename T, typename grow_p>
93 class vector<T,HeapMemory,memory_traits_lin,grow_p,STD_VECTOR>
94 {
95  // Memory layout
96  typedef typename memory_traits_lin<T>::type layout;
97 // Doeas not work on gcc 4.8.4
98 // template <typename lb> using layout_base = memory_traits_lin<lb>;
99 
101  std::vector<T> base;
102 
104  size_t err_code = 0;
105 
106 public:
107 
109  typedef int yes_i_am_vector;
110 
112 
114  typedef vector_key_iterator iterator_key;
116  typedef T value_type;
117 
118  typedef void base_to_copy;
119 
121  typedef grow_policy_double grow_policy;
122 
123  template<typename Tobj>
124  struct layout_base__
125  {
127  };
128 
129  //This file implements a pack and unpack for std vector
130 #include "vector_std_pack_unpack.ipp"
131 
133  inline size_t size() const
134  {
135  return base.size();
136  }
137 
138 
144  inline void resize(size_t slot)
145  {
146  base.resize(slot);
147  }
148 
152  inline void clear()
153  {
154  base.clear();
155  }
156 
160  inline void shrink_to_fit()
161  {
162  base.shrink_to_fit();
163  }
164 
174  inline void add(const T & v)
175  {
176  if (std::is_same<grow_p,openfpm::grow_policy_identity>::value == true)
177  {
178  // we reserve just one space more to avoid the capacity to increase by two
179  base.reserve(base.size()+1);
180  }
181 
182  base.push_back(v);
183  }
184 
194  inline void add(T && v)
195  {
196  if (std::is_same<grow_p,openfpm::grow_policy_identity>::value == true)
197  {
198  // we reserve just one space more to avoid the capacity to increase by two
199  base.reserve(base.size()+1);
200  }
201 
202  base.emplace_back(v);
203  }
204 
208  inline void add()
209  {
210  base.emplace_back(T());
211  }
212 
218  template<typename Mem,template<typename> class lb,typename gp> inline void add(const openfpm::vector<T,Mem,lb,gp> & eles)
219  {
220  if (std::is_same<grow_p,openfpm::grow_policy_identity>::value == true)
221  {
222  // we reserve just one space more to avoid the capacity to increase by two
223  base.reserve(base.size() + eles.size());
224  }
225 
226  size_t start = base.size();
227  base.resize(base.size() + eles.size());
228 
229  // copy the elements
230  std::copy(eles.begin(),eles.end(),base.begin()+start);
231  }
232 
242  template<typename S> inline void add(const S & v)
243  {
245  }
246 
256  template<typename S> inline void add(const S && v)
257  {
258  if (std::is_same<grow_p,openfpm::grow_policy_identity>::value == true)
259  {
260  // we reserve just one space more to avoid the capacity to increase by two
261  base.reserve(base.size() + 1);
262  }
263 
264  base.push_back(v);
265  }
266 
281  template <typename S,
282  typename M,
283  typename gp,
284  unsigned int impl,
285  template <typename> class layout_base,
286  unsigned int ...args>
287  void add_prp(const vector<S,M,layout_base,gp,impl> & v)
288  {
289  add_prp_impl<std::is_same<S,T>::value,typename std::remove_pointer<decltype(*this)>::type>::template add<S,M,gp,impl,args...>(v,*this);
290  }
291 
306  template <typename S,
307  typename M,
308  typename gp,
309  unsigned int impl,
310  template <typename> class layout_base,
311  unsigned int ...args>
312  void add_prp_device(const vector<S,M,layout_base,gp,impl> & v)
313  {
314  add_prp_impl<std::is_same<S,T>::value,typename std::remove_pointer<decltype(*this)>::type>::template add<S,M,gp,impl,args...>(v,*this);
315  }
316 
330  template <typename S,
331  typename M,
332  typename gp,
333  unsigned int impl,
334  template <typename> class layout_base,
335  unsigned int ...args>
336  void add_prp(const T & v)
337  {
338  add(v);
339  }
340 
347  void erase(typename std::vector<T>::iterator start, typename std::vector<T>::iterator end)
348  {
349  base.erase(start,end);
350  }
351 
357  void remove(size_t key)
358  {
359 #ifdef SE_CLASS1
360  vector_overflow(key);
361 #endif
362  base.erase(base.begin() + key);
363  }
364 
373  void remove(openfpm::vector<size_t> & keys, size_t start = 0)
374  {
375  // Nothing to remove return
376  if (keys.size() <= start )
377  return;
378 
379  size_t a_key = start;
380  size_t d_k = keys.get(a_key);
381  size_t s_k = keys.get(a_key) + 1;
382 
383  // keys
384  while (s_k < size())
385  {
386  // s_k should always point to a key that is not going to be deleted
387  while (a_key+1 < keys.size() && s_k == keys.get(a_key+1))
388  {
389  a_key++;
390  s_k = keys.get(a_key) + 1;
391  }
392 
393  // In case of overflow
394  if (s_k >= size())
395  break;
396 
397  base[d_k] = base[s_k];
398  d_k++;
399  s_k++;
400  }
401 
402  // re-calculate the vector size
403 
404  base.resize(base.size() - (keys.size() - start));
405  }
406 
412  inline auto begin() -> decltype(base.begin())
413  {
414  return base.begin();
415  }
416 
422  inline auto end() -> decltype(base.begin())
423  {
424  return base.end();
425  }
426 
432  inline auto begin() const -> const decltype(base.begin())
433  {
434  return base.begin();
435  }
436 
442  inline auto end() const -> const decltype(base.begin())
443  {
444  return base.end();
445  }
446 
452  inline T & last()
453  {
454 #ifdef SE_CLASS1
455  if (base.size() == 0)
456  std::cerr << "Error vector: " << __FILE__ << ":" << __LINE__ << " vector of size 0\n";
457 #endif
458  return base[base.size()-1];
459  }
460 
466  inline const T & last() const
467  {
468 #ifdef SE_CLASS1
469  if (base.size() == 0)
470  std::cerr << "Error vector: " << __FILE__ << ":" << __LINE__ << " vector of size 0\n";
471 #endif
472  return base[base.size()-1];
473  }
474 
481  {
482  return *this;
483  }
484 
490  void swap(std::vector<T> && v)
491  {
492  base.swap(v);
493  }
494 
500  void unique()
501  {
502  auto it = std::unique(base.begin(),base.end());
503  base.resize( std::distance(base.begin(),it) );
504  }
505 
511  void sort()
512  {
513  std::sort(base.begin(), base.end());
514  }
515 
525  template <unsigned int p>inline T& get(size_t id)
526  {
527 #ifdef SE_CLASS1
528  if (p != 0)
529  {std::cerr << "Error the property does not exist" << "\n";}
530 
531  vector_overflow(id);
532 #endif
533 
534  return base[id];
535  }
536 
546  template <unsigned int p>inline const T& get(size_t id) const
547  {
548 #ifdef SE_CLASS1
549  if (p != 0)
550  {std::cerr << "Error the property does not exist" << "\n";}
551 
552  vector_overflow(id);
553 #endif
554 
555  return base[id];
556  }
557 
565  inline T & get(size_t id)
566  {
567 #ifdef SE_CLASS1
568  vector_overflow(id);
569 #endif
570  return base[id];
571  }
572 
580  inline const T & get(size_t id) const
581  {
582 #ifdef SE_CLASS1
583  vector_overflow(id);
584 #endif
585  return base[id];
586  }
587 
596  inline void fill(unsigned char fl)
597  {
598  memset(&base[0],fl,base.size() * sizeof(T));
599  }
600 
606  inline void reserve(size_t ns)
607  {
608  base.reserve(ns);
609  }
610 
612  vector() noexcept
613  :err_code(0)
614  {
615  }
616 
618  vector(size_t sz) noexcept
619  :base(sz),err_code(0)
620  {
621  }
622 
624  vector(const vector<T,HeapMemory,memory_traits_lin,grow_policy_double,STD_VECTOR> & v) noexcept
625  :err_code(0)
626  {
627  base = v.base;
628  }
629 
635  vector(const std::initializer_list<T> & v)
636  :base(v)
637  {
638  }
639 
641  vector(vector<T,HeapMemory,memory_traits_lin,grow_policy_double,STD_VECTOR> && v) noexcept
642  :err_code(0)
643  {
644  base.swap(v.base);
645  }
646 
648  template< class InputIt >
649  vector(InputIt first, InputIt last)
650  {
651  while(first != last) {
652  add(*first);
653  ++first;
654  }
655  }
656 
658  ~vector() noexcept
659  {
660  }
661 
668  {
669  base.swap(v.base);
670  }
671 
678  {
679  base.swap(v.base);
680  }
681 
689  vector<T,HeapMemory,memory_traits_lin,grow_policy_double,STD_VECTOR> & operator=(const vector<T,HeapMemory,memory_traits_lin,grow_policy_double,STD_VECTOR> & v)
690  {
691  base = v.base;
692 
693  return *this;
694  }
695 
701  template<typename Mem, typename gp> vector<T,HeapMemory,memory_traits_lin,grow_policy_double,STD_VECTOR> & operator=(const vector<T,Mem,memory_traits_lin,gp,STD_VECTOR> & v)
702  {
704  decltype(*this),
705  vector<T,Mem,memory_traits_lin,gp,STD_VECTOR> >::copy(*this,v);
706 
707  return *this;
708  }
709 
717  vector<T,HeapMemory,memory_traits_lin,grow_policy_double,STD_VECTOR> & operator=(vector<T,HeapMemory,memory_traits_lin,grow_policy_double,STD_VECTOR> && v)
718  {
719  base.swap(v.base);
720 
721  return *this;
722  }
723 
731  template<typename Mem, typename gp> vector<T,HeapMemory,memory_traits_lin,grow_policy_double,STD_VECTOR> & operator=(vector<T,Mem,memory_traits_lin,gp,STD_VECTOR> && v)
732  {
733  base.swap(v.base);
734 
735  return *this;
736  }
737 
745  bool operator!=(const vector<T, HeapMemory, memory_traits_lin,grow_policy_double,STD_VECTOR> & v) const
746  {
747  return base != v.base;
748  }
749 
757  bool operator==(const vector<T, HeapMemory, memory_traits_lin,grow_policy_double,STD_VECTOR> & v) const
758  {
759  return base == v.base;
760  }
761 
767  vector_key_iterator getIterator() const
768  {
769  return vector_key_iterator(base.size());
770  }
771 
779  vector_key_iterator getIteratorTo(size_t k) const
780  {
781  return vector_key_iterator(k);
782  }
783 
794  template<int ... prp> inline size_t packMem(size_t n, size_t e) const
795  {
796  if (n == 0)
797  return 0;
798  else
799  {
800  packMem_cond<has_packMem<T>::type::value, openfpm::vector<T, HeapMemory, memory_traits_lin, grow_policy_double>, prp...> cm;
801  return cm.packMemory(*this,n,0);
802  }
803  }
804 
815  inline static size_t calculateMemDummy(size_t n, size_t e)
816  {
817  return n*sizeof(T);
818  }
819 
827  inline static size_t calculateNMem(size_t n)
828  {
829 
830  return 1;
831  }
832 
838  void * getPointer()
839  {
840  return &base[0];
841  }
842 
846  template<unsigned int ... prp> void hostToDevice()
847  {}
848 
852  template<unsigned int ... prp> void deviceToHost()
853  {}
854 
859  template<unsigned int ... prp> void deviceToHost(size_t start, size_t stop)
860  {}
861 
866  template<unsigned int ... prp> void hostToDevice(size_t start, size_t stop)
867  {}
868 
874  const void * getPointer() const
875  {
876  return &base[0];
877  }
878 
884  static bool noPointers()
885  {
886  return false;
887  }
888 
894  size_t getLastError()
895  {
896  return err_code;
897  }
898 
904  inline void vector_overflow(size_t v1) const
905  {
906  if (v1 >= base.size())
907  {
908  std::cerr << "Error vector: " << __FILE__ << ":" << __LINE__ << " overflow id: " << v1 << "\n";\
909  size_t * err_code_pointer = (size_t *)&this->err_code;\
910  *err_code_pointer = 2001;\
911 
912  ACTION_ON_ERROR(VECTOR_ERROR_OBJECT);\
913  }
914  }
915 };
916 
929 template<typename T>
931 :private vector<T,HeapMemory,memory_traits_lin,grow_policy_double,STD_VECTOR>
932 {
933  typedef vector<T,HeapMemory,memory_traits_lin,grow_policy_double,STD_VECTOR> base_type;
934 
936  size_t v_size = 0;
937 
938 public:
939 
945  size_t size()
946  {
947  return v_size;
948  }
949 
955  size_t size_base()
956  {
957  return base_type::size();
958  }
959 
965  void resize(size_t sz)
966  {
967  if (sz <= base_type::size())
968  {
969  v_size = sz;
970  return;
971  }
972 
973  base_type::resize(sz);
974 
975  v_size = sz;
976  }
977 
982  void clear()
983  {
984  resize(0);
985  }
986 
991  void add()
992  {
993  resize(v_size+1);
994  }
995 
1001  void resize_base(size_t sz)
1002  {
1003  base_type::resize(sz);
1004  v_size = sz;
1005  }
1006 
1014  inline T & get(size_t id)
1015  {
1016  return base_type::get(id);
1017  }
1018 
1026  inline T & operator[](size_t id)
1027  {
1028  return base_type::get(id);
1029  }
1030 
1038  inline T & last()
1039  {
1040  return base_type::get(size()-1);
1041  }
1042 
1048  void swap(openfpm::vector_fr<T> & v)
1049  {
1050  size_t v_size_tmp = v.v_size;
1051  v.v_size = v_size;
1052  v_size = v_size_tmp;
1053 
1054  base_type::swap(v);
1055  }
1056 };
1057 
1058 #endif /* MAP_VECTOR_STD_HPP_ */
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::sort
void sort()
It sort the vector.
Definition: map_vector_std.hpp:511
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::add
void add(const openfpm::vector< T, Mem, lb, gp > &eles)
add elements to the vector
Definition: map_vector_std.hpp:218
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::add
void add(const S &&v)
It insert a new object on the vector, eventually it reallocate the grid.
Definition: map_vector_std.hpp:256
HeapMemory
This class allocate, and destroy CPU memory.
Definition: HeapMemory.hpp:39
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::get
const T & get(size_t id) const
Get an element of the vector.
Definition: map_vector_std.hpp:580
base_copy
Definition: map_vector_std_util.hpp:140
add_prp_impl
struct to merge two vectors
Definition: map_vector_std.hpp:19
vector_fr::operator[]
T & operator[](size_t id)
Get an element of the vector.
Definition: map_vector_std.hpp:1026
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::operator=
vector< T, HeapMemory, memory_traits_lin, grow_policy_double, STD_VECTOR > & operator=(vector< T, Mem, memory_traits_lin, gp, STD_VECTOR > &&v)
Operator= copy the vector into another.
Definition: map_vector_std.hpp:731
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::operator==
bool operator==(const vector< T, HeapMemory, memory_traits_lin, grow_policy_double, STD_VECTOR > &v) const
Check that two vectors are not equal.
Definition: map_vector_std.hpp:757
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::erase
void erase(typename std::vector< T >::iterator start, typename std::vector< T >::iterator end)
Erase the elements from start to end.
Definition: map_vector_std.hpp:347
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::base
std::vector< T > base
1-D static grid
Definition: map_vector_std.hpp:101
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::begin
auto begin() const -> const decltype(base.begin())
Return an std compatible iterator to the first element.
Definition: map_vector_std.hpp:432
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::deviceToHost
void deviceToHost(size_t start, size_t stop)
Do nothing.
Definition: map_vector_std.hpp:859
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::end
auto end() -> decltype(base.begin())
Return an std compatible iterator to the last element.
Definition: map_vector_std.hpp:422
vector_fr::swap
void swap(openfpm::vector_fr< T > &v)
Definition: map_vector_std.hpp:1048
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::getPointer
void * getPointer()
Return the pointer to the chunk of memory.
Definition: map_vector_std.hpp:838
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::add_prp_device
void add_prp_device(const vector< S, M, layout_base, gp, impl > &v)
It add the element of a source vector to this vector.
Definition: map_vector_std.hpp:312
vector_fr::size
size_t size()
return the size of the vector
Definition: map_vector_std.hpp:945
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::size
size_t size() const
return the size of the vector
Definition: map_vector_std.hpp:133
vector_fr::resize_base
void resize_base(size_t sz)
resize the base vector (this kill the objects)
Definition: map_vector_std.hpp:1001
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::vector
vector(const std::initializer_list< T > &v)
Initializer from constructor.
Definition: map_vector_std.hpp:635
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::value_type
T value_type
Type of the value the vector is storing.
Definition: map_vector_std.hpp:116
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::add
void add(T &&v)
It insert a new object on the vector, eventually it reallocate the grid.
Definition: map_vector_std.hpp:194
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::last
const T & last() const
Get the last element.
Definition: map_vector_std.hpp:466
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::deviceToHost
void deviceToHost()
Do nothing.
Definition: map_vector_std.hpp:852
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::vector
vector(size_t sz) noexcept
Constructor, vector of size sz.
Definition: map_vector_std.hpp:618
vector_fr::clear
void clear()
Eliminate all elements.
Definition: map_vector_std.hpp:982
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::operator=
vector< T, HeapMemory, memory_traits_lin, grow_policy_double, STD_VECTOR > & operator=(vector< T, HeapMemory, memory_traits_lin, grow_policy_double, STD_VECTOR > &&v)
Operator= copy the vector into another.
Definition: map_vector_std.hpp:717
openfpm::vector::size
size_t size()
Stub size.
Definition: map_vector.hpp:212
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::packMem
size_t packMem(size_t n, size_t e) const
Calculate the memory size required to allocate n elements.
Definition: map_vector_std.hpp:794
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::iterator_key
vector_key_iterator iterator_key
iterator for the vector
Definition: map_vector_std.hpp:114
openfpm::vector
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:203
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::vector
vector(const vector< T, HeapMemory, memory_traits_lin, grow_policy_double, STD_VECTOR > &v) noexcept
Constructor from another vector.
Definition: map_vector_std.hpp:624
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::unique
void unique()
It eliminate double entries.
Definition: map_vector_std.hpp:500
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::vector
vector(InputIt first, InputIt last)
Constructor from iterators.
Definition: map_vector_std.hpp:649
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::yes_i_am_vector
int yes_i_am_vector
it define that it is a vector
Definition: map_vector_std.hpp:109
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::add
void add(const T &v)
It insert a new object on the vector, eventually it reallocate the grid.
Definition: map_vector_std.hpp:174
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::reserve
void reserve(size_t ns)
reserve a memory space in advance to avoid reallocation
Definition: map_vector_std.hpp:606
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::getIteratorTo
vector_key_iterator getIteratorTo(size_t k) const
Get iterator until a specified element.
Definition: map_vector_std.hpp:779
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::remove
void remove(size_t key)
Remove one entry from the vector.
Definition: map_vector_std.hpp:357
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::operator!=
bool operator!=(const vector< T, HeapMemory, memory_traits_lin, grow_policy_double, STD_VECTOR > &v) const
Check that two vectors are equal.
Definition: map_vector_std.hpp:745
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::hostToDevice
void hostToDevice(size_t start, size_t stop)
Do nothing.
Definition: map_vector_std.hpp:866
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::add
void add()
Add an empty object (it call the default constructor () ) at the end of the vector.
Definition: map_vector_std.hpp:208
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::calculateMemDummy
static size_t calculateMemDummy(size_t n, size_t e)
Calculate the memory size required to allocate n elements.
Definition: map_vector_std.hpp:815
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::last
T & last()
Get the last element.
Definition: map_vector_std.hpp:452
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::add_prp
void add_prp(const vector< S, M, layout_base, gp, impl > &v)
It add the element of a source vector to this vector.
Definition: map_vector_std.hpp:287
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::end
auto end() const -> const decltype(base.begin())
Return an std compatible iterator to the last element.
Definition: map_vector_std.hpp:442
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::fill
void fill(unsigned char fl)
it fill all the memory of fl patterns
Definition: map_vector_std.hpp:596
push_back_op
Definition: map_vector_std_util.hpp:100
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::resize
void resize(size_t slot)
Definition: map_vector_std.hpp:144
add_prp_impl< OBJECT_ADD, vect_dst >::add
static void add(const vector< S, M, memory_traits_lin, gp, impl > &v_src, vect_dst &v_dst)
It add the element of a source vector to a destination vector.
Definition: map_vector_std.hpp:70
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::swap
void swap(openfpm::vector< T, HeapMemory, memory_traits_lin, grow_policy_double, STD_VECTOR > &v)
Definition: map_vector_std.hpp:667
vector_fr::v_size
size_t v_size
size of the vector
Definition: map_vector_std.hpp:936
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::add
void add(const S &v)
It insert a new object on the vector, eventually it reallocate the object.
Definition: map_vector_std.hpp:242
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::grow_policy
grow_policy_double grow_policy
growing policy of this vector
Definition: map_vector_std.hpp:121
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::operator=
vector< T, HeapMemory, memory_traits_lin, grow_policy_double, STD_VECTOR > & operator=(const vector< T, HeapMemory, memory_traits_lin, grow_policy_double, STD_VECTOR > &v)
Operator= copy the vector into another.
Definition: map_vector_std.hpp:689
vector_fr::get
T & get(size_t id)
Get an element of the vector.
Definition: map_vector_std.hpp:1014
vector_fr::last
T & last()
Get an element of the vector.
Definition: map_vector_std.hpp:1038
add_prp_impl::add
static void add(const vector< S, M, memory_traits_lin, gp, impl > &v_src, vect_dst &v_dst)
It add the element of a source vector to this vector.
Definition: map_vector_std.hpp:37
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::calculateNMem
static size_t calculateNMem(size_t n)
How many allocation are required to create n-elements.
Definition: map_vector_std.hpp:827
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::get
const T & get(size_t id) const
Get an element of the vector.
Definition: map_vector_std.hpp:546
vector_fr
Implementation of 1-D std::vector like structure.
Definition: map_vector_std.hpp:930
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::~vector
~vector() noexcept
destructor
Definition: map_vector_std.hpp:658
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::getPointer
const void * getPointer() const
Return the pointer to the chunk of memory.
Definition: map_vector_std.hpp:874
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::vector_overflow
void vector_overflow(size_t v1) const
check that the id does not overflow the buffer
Definition: map_vector_std.hpp:904
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::getLastError
size_t getLastError()
Return the last error.
Definition: map_vector_std.hpp:894
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::clear
void clear()
Remove all the element from the vector.
Definition: map_vector_std.hpp:152
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::operator=
vector< T, HeapMemory, memory_traits_lin, grow_policy_double, STD_VECTOR > & operator=(const vector< T, Mem, memory_traits_lin, gp, STD_VECTOR > &v)
Operator= copy the vector into another.
Definition: map_vector_std.hpp:701
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::add_prp
void add_prp(const T &v)
It add the element it is equivalent to add.
Definition: map_vector_std.hpp:336
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::begin
auto begin() -> decltype(base.begin())
Return an std compatible iterator to the first element.
Definition: map_vector_std.hpp:412
vector_fr::add
void add()
Add another element.
Definition: map_vector_std.hpp:991
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::duplicate
openfpm::vector< T > duplicate() const
Duplicate the vector.
Definition: map_vector_std.hpp:480
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::remove
void remove(openfpm::vector< size_t > &keys, size_t start=0)
Remove several entries from the vector.
Definition: map_vector_std.hpp:373
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::vector
vector() noexcept
Constructor, vector of size 0.
Definition: map_vector_std.hpp:612
vector_fr::resize
void resize(size_t sz)
resize the vector retaining the objects
Definition: map_vector_std.hpp:965
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::noPointers
static bool noPointers()
This class has pointer inside.
Definition: map_vector_std.hpp:884
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::getIterator
vector_key_iterator getIterator() const
Get an iterator over all the elements of the vector.
Definition: map_vector_std.hpp:767
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::swap
void swap(openfpm::vector< T, HeapMemory, memory_traits_lin, grow_policy_double, STD_VECTOR > &&v)
Definition: map_vector_std.hpp:677
vector_fr::size_base
size_t size_base()
return the base size of the vector
Definition: map_vector_std.hpp:955
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::get
T & get(size_t id)
Get an element of the vector.
Definition: map_vector_std.hpp:565
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::vector
vector(vector< T, HeapMemory, memory_traits_lin, grow_policy_double, STD_VECTOR > &&v) noexcept
Constructor from another vector.
Definition: map_vector_std.hpp:641
is_vector
Definition: util.hpp:15
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::shrink_to_fit
void shrink_to_fit()
Fit the memory to the size of the vector.
Definition: map_vector_std.hpp:160
memory_traits_lin
Transform the boost::fusion::vector into memory specification (memory_traits)
Definition: memory_conf.hpp:242
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::swap
void swap(std::vector< T > &&v)
swap the memory between the two vector
Definition: map_vector_std.hpp:490
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::get
T & get(size_t id)
Get an element of the vector.
Definition: map_vector_std.hpp:525
memory_c
Definition: memory_c.hpp:29
vector< T, HeapMemory, memory_traits_lin, grow_p, STD_VECTOR >::hostToDevice
void hostToDevice()
Do nothing.
Definition: map_vector_std.hpp:846