Implementation of 1-D std::vector like structure. More...
Implementation of 1-D std::vector like structure.
The layout is memory_traits_lin
T | type of object the vector store |
Memory | allocator to use |
layout | layout to use |
grow_p | grow policy for vector in case of reallocation |
OPENFPM_NATIVE implementation
Definition at line 96 of file map_vector.hpp.
#include <map_vector.hpp>
Data Structures | |
struct | pack_cond |
Structures that do a nested packing, depending on the existence of 'pack()' function inside the object. More... | |
struct | pack_cond< true, T1, Memory1, prp...> |
Structures that do a nested packing, depending on the existence of 'pack()' function inside the object. More... | |
struct | pack_simple_cond |
These structures serialize a simple (no "pack()" inside) object. More... | |
struct | pack_simple_cond< true, prp...> |
These structures serialize a simple (no "pack()" inside) object. More... | |
struct | packMem_cond |
Structures that calculate how many bytes are required to serialize an object. More... | |
struct | packMem_cond< true, T1 > |
Structures that calculate memory for an object, depending on the existence of 'packMem()'. More... | |
struct | unpack_simple_cond |
These structures do an de-serialize a simple object (no pack() inside) More... | |
struct | unpack_simple_cond< true, prp...> |
Public Types | |
typedef int | yes_i_am_vector |
it define that it is a vector | |
typedef layout | layout_type |
Type of the encapsulation memory parameter. | |
typedef vector_key_iterator | iterator_key |
iterator for the vector | |
typedef 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. | |
typedef T | value_type |
Type of the value the vector is storing. | |
typedef size_t | access_key |
Access key for the vector. | |
Public Member Functions | |
template<int... prp> | |
void | packRequest (size_t &req) const |
It calculate the number of byte required to serialize the object. More... | |
template<int... prp> | |
void | pack (ExtPreAlloc< Memory > &mem, Pack_stat &sts) const |
pack a vector selecting the properties to pack More... | |
template<int... prp> | |
void | unpack (ExtPreAlloc< Memory > &mem, Unpack_stat &ps) |
unpack a vector More... | |
size_t | size () const |
Return the size of the vector. More... | |
void | reserve (size_t sp) |
Reserve slots in the vector to avoid reallocation. More... | |
void | clear () |
Clear the vector. More... | |
void | resize (size_t slot) |
Resize the vector. More... | |
void | add () |
It insert a new emtpy object on the vector, eventually it reallocate the grid. More... | |
void | add (const T &v) |
It insert a new object on the vector, eventually it reallocate the grid. More... | |
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. More... | |
template<typename M , typename gp > | |
void | add (const vector< T, M, layout, layout_base, gp, OPENFPM_NATIVE > &v) |
It add the element of another vector to this vector. More... | |
template<template< typename, typename > class op, typename S , typename M , typename gp , unsigned int... args> | |
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. More... | |
template<template< typename, typename > class op, typename S , typename M , typename gp , template< typename > class layout_base2, unsigned int... args> | |
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. More... | |
template<template< typename, typename > class op, typename S , typename M , typename gp , template< typename > class layout_base2, unsigned int... args> | |
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. More... | |
template<typename S , typename M , typename gp , unsigned int impl, template< typename > class layout_base2, unsigned int... args> | |
void | add_prp (const vector< S, M, typename layout_base2< S >::type, layout_base2, gp, impl > &v) |
It add the element of a source vector to this vector. More... | |
void | insert (size_t key) |
Insert an entry in the vector. More... | |
void | remove (size_t key) |
Remove one entry from the vector. More... | |
void | remove (openfpm::vector< size_t > &keys, size_t start=0) |
Remove several entries from the vector. More... | |
template<unsigned int p> | |
auto | get (size_t id) const -> decltype(base.template get< p >(grid_key_dx< 1 >(0))) |
Get an element of the vector. More... | |
auto | get (size_t id) -> decltype(base.get_o(grid_key_dx< 1 >(id))) |
Get an element of the vector. More... | |
auto | get (size_t id) const -> const decltype(base.get_o(grid_key_dx< 1 >(id))) |
Get an element of the vector. More... | |
const grid_cpu< 1, T, Memory, typename layout_base< T > ::type >::container | get_o (size_t id) const |
Get an element of the vector. More... | |
const grid_cpu< 1, T, Memory, typename layout_base< T > ::type >::container | last () const |
Get the last element of the vector. More... | |
template<unsigned int p> | |
auto | get (size_t id) -> decltype(base.template get< p >(grid_key_dx< 1 >(0))) |
Get an element of the vector. More... | |
grid_cpu< 1, T, Memory, typename layout_base< T > ::type >::container | last () |
Get the last element of the vector. More... | |
~vector () THROW | |
Destructor. | |
vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > | duplicate () const |
It duplicate the vector. More... | |
vector (vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &&v) | |
Constructor from another temporal vector. More... | |
vector (const vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &v) THROW | |
Constructor from another constant vector. More... | |
vector () THROW | |
Constructor, vector of size 0. | |
vector (size_t sz) THROW | |
Constructor, vector of size sz. | |
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. More... | |
template<typename encap_S , unsigned int... args> | |
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. More... | |
void | set (size_t id, const T &obj) |
Set the object id to obj. More... | |
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. More... | |
vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > & | operator= (vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &&mv) |
Assignment operator. More... | |
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. More... | |
template<typename Mem , typename gp > | |
vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > & | operator= (vector< T, Mem, layout, layout_base, gp, OPENFPM_NATIVE > &&mv) |
Assignment operator. More... | |
template<typename Mem , typename gp > | |
vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > & | operator= (const vector< T, Mem, layout, layout_base, gp, OPENFPM_NATIVE > &mv) |
Assignment operator. More... | |
bool | operator!= (const vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &v) const |
Check that two vectors are equal. More... | |
bool | operator== (const vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &v) const |
Check that two vectors are not equal. More... | |
void | swap (openfpm::vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &v) |
Swap the memory with another vector. More... | |
void | swap (openfpm::vector< T, Memory, layout, layout_base, grow_p, OPENFPM_NATIVE > &&v) |
Swap the memory with another vector. More... | |
vector_key_iterator | getIteratorFrom (size_t start) const |
Get iterator over the particles from a particular index. More... | |
vector_key_iterator | getIteratorTo (size_t stop) const |
Get iterator over the particles from 0 until a particular index. More... | |
vector_key_iterator | getIterator () const |
Get the vector elements iterator. More... | |
size_t | packObjectSize () |
Return the size of the message needed to pack this object. More... | |
size_t | packObject (void *mem) |
Pack the object into the given pointer. More... | |
void | setMemory (Memory &mem) |
Set the memory of the base structure using an object. More... | |
void * | getPointer () |
Return the pointer that store the data. More... | |
const void * | getPointer () const |
Return the pointer that store the data. More... | |
long int | who () |
const size_t & | getInternal_v_size () const |
Internal function. More... | |
const grid_cpu< 1, T, Memory, layout > & | getInternal_base () const |
Internal function. More... | |
Static Public Member Functions | |
static bool | pack () |
static bool | packRequest () |
static bool | packMem () |
template<int... prp> | |
static size_t | calculateMem (size_t n, size_t e) |
Calculate the memory size required to allocate n elements. More... | |
template<int... prp> | |
static size_t | packMem (size_t n, size_t e) |
Calculate the memory size required to pack n elements. More... | |
static size_t | calculateNMem (size_t n) |
How many allocation are required to create n-elements. More... | |
static bool | noPointers () |
This class has pointer inside. More... | |
Private Member Functions | |
void | non_zero_one (size_t sz[1], size_t arg) |
If the argument is zero return 1 otherwise return the argument. More... | |
Private Attributes | |
size_t | v_size |
grid_cpu< 1, T, Memory, typename layout_base< T > ::type > | base |
1-D static grid | |
|
inline |
Constructor from another temporal vector.
v | the vector |
Definition at line 844 of file map_vector.hpp.
|
inline |
Constructor from another constant vector.
v | the vector |
Definition at line 859 of file map_vector.hpp.
|
inline |
It insert a new emtpy object on the vector, eventually it reallocate the grid.
Check if we have enough space
Resize the memory, double up the actual memory allocated for the vector
increase the vector size
Definition at line 243 of file map_vector.hpp.
|
inline |
It insert a new object on the vector, eventually it reallocate the grid.
v | element to add |
Check if we have enough space
Resize the memory, double up the actual memory allocated for the vector
copy the element
increase the vector size
Definition at line 270 of file map_vector.hpp.
|
inline |
It insert a new object on the vector, eventually it reallocate the vector.
v | object (encapsulated) |
Check if we have enough space
Resize the memory, double up the actual memory allocated for the vector
copy the added element
increase the vector size
Definition at line 301 of file map_vector.hpp.
|
inline |
It add the element of another vector to this vector.
v | from where to take the vector |
Add the element of v
Definition at line 328 of file map_vector.hpp.
|
inline |
It add the element of a source vector to this vector.
The number of properties in the source vector must be smaller than the destination all the properties of S must be mapped so if S has 3 properties 3 numbers for args are required
S | Base object of the source vector |
M | memory type of the source vector |
gp | Grow policy of the source vector |
args | one or more number that define which property to set-up |
v | source vector |
Add the element of v
Definition at line 549 of file map_vector.hpp.
|
inlinestatic |
Calculate the memory size required to allocate n elements.
Calculate the total size required to store n-elements in a vector
n | number of elements |
e | unused |
Definition at line 1220 of file map_vector.hpp.
|
inlinestatic |
How many allocation are required to create n-elements.
n | number of elements |
Definition at line 1264 of file map_vector.hpp.
|
inline |
Clear the vector.
Eliminate all the elements for from the vector
Definition at line 199 of file map_vector.hpp.
|
inline |
|
inline |
Get an element of the vector.
Get an element of the vector
p | Property to get |
id | Element to get |
Definition at line 673 of file map_vector.hpp.
|
inline |
Get an element of the vector.
Get an element of the vector
id | Element to get |
Definition at line 695 of file map_vector.hpp.
|
inline |
Get an element of the vector.
Get an element of the vector
id | Element to get |
Definition at line 717 of file map_vector.hpp.
|
inline |
Get an element of the vector.
Get an element of the vector
p | Property to get |
id | Element to get |
Definition at line 783 of file map_vector.hpp.
|
inline |
Get an element of the vector.
exactly as get, exist to keep the compatibility with grid
id | Element to get |
Definition at line 742 of file map_vector.hpp.
|
inline |
|
inline |
|
inline |
Get the vector elements iterator.
Definition at line 1173 of file map_vector.hpp.
|
inline |
Get iterator over the particles from a particular index.
start | starting point |
Definition at line 1141 of file map_vector.hpp.
|
inline |
Get iterator over the particles from 0 until a particular index.
stop | stop point |
Definition at line 1158 of file map_vector.hpp.
|
inline |
Return the pointer that store the data.
Definition at line 1287 of file map_vector.hpp.
|
inline |
Return the pointer that store the data.
Definition at line 1300 of file map_vector.hpp.
|
inline |
Insert an entry in the vector.
key Where to insert the element
Definition at line 570 of file map_vector.hpp.
|
inline |
Get the last element of the vector.
Definition at line 761 of file map_vector.hpp.
|
inline |
Get the last element of the vector.
Definition at line 802 of file map_vector.hpp.
|
inline |
It merge the elements of a source vector to this vector.
Given 2 vector v1 and v2 of size 7,3. and as merging operation the function add. Merging the second vector v2 to the first one v1 starting from the element 2. Mean
* * 6 8 3 2 1 0 3 v1 elements * | | | * op op op * | | | * 5 1 9 v2 elements * *------------------------------------- * 6 8 8 3 10 0 3 updated v1 elements * * This operation is done for each selected property in args * *
The number of properties in the source vector must be smaller than the destination all the properties of S must be mapped so if S has 3 properties 3 numbers for args are required
op | merging operation |
S | Base object of the source vector |
M | memory type of the source vector |
gp | Grow policy of the source vector |
args | one or more number that define which property to set-up |
v | source vector |
start | index from where to start the merging |
Add the element of v
Definition at line 374 of file map_vector.hpp.
|
inline |
It merge the elements of a source vector to this vector.
Given 2 vector v1 and v2 of size 7,3. and as merging operation the function add. Merging the second vector v2 to the first one v1 starting from the element 2. Mean
6 8 3 2 1 0 3 v1 elements | | | op op op | | | 5 1 9 v2 elements
6 8 8 3 10 0 3 updated v1 elements
This operation is done for each selected property in args
The number of properties in the source vector must be smaller than the destination all the properties of S must be mapped so if S has 3 properties 3 numbers for args are required
op | merging operation |
S | Base object of the source vector |
M | memory type of the source vector |
gp | Grow policy of the source vector |
args | one or more number that define which property to set-up |
v | source vector |
start | index from where to start the merging |
Add the element of v
Definition at line 442 of file map_vector.hpp.
|
inline |
It merge the elements of a source vector to this vector.
Given 2 vector v1 and v2 of size 7,3. and as merging operation the function add. Merging the second vector v2 to the first one v1 starting from the element 2. Mean
6 8 3 2 1 0 3 v1 elements | | | op op op | | | 5 1 9 v2 elements
6 8 8 3 10 0 3 updated v1 elements
This operation is done for each selected property in args
The number of properties in the source vector must be smaller than the destination all the properties of S must be mapped so if S has 3 properties 3 numbers for args are required
op | merging operation |
S | Base object of the source vector |
M | memory type of the source vector |
gp | Grow policy of the source vector |
args | one or more number that define which property to set-up |
v | source vector |
start | index from where to start the merging |
Add the element of v
Definition at line 509 of file map_vector.hpp.
|
inlineprivate |
If the argument is zero return 1 otherwise return the argument.
sz | output |
arg | argument |
Definition at line 112 of file map_vector.hpp.
|
inlinestatic |
|
inline |
Check that two vectors are equal.
vector | to compare |
Definition at line 1069 of file map_vector.hpp.
|
inline |
Assignment operator.
move semantic movement operator=
mv | vector |
Definition at line 976 of file map_vector.hpp.
|
inline |
Assignment operator.
it copy
mv | vector |
Definition at line 996 of file map_vector.hpp.
|
inline |
Assignment operator.
move semantic movement operator=
mv | vector |
Definition at line 1025 of file map_vector.hpp.
|
inline |
Assignment operator.
it copy
mv | vector |
Definition at line 1045 of file map_vector.hpp.
|
inline |
Check that two vectors are not equal.
vector | to compare |
Definition at line 1079 of file map_vector.hpp.
|
inlinestatic |
This file contains the implemetation of packer and unpacker for vector Created on: Jan 5, 2016 Author: Yaroslav Zaluzhnyi and Pietro Incardona
This Function to indicate the vector class has a packer function
Definition at line 13 of file map_vector.hpp.
|
inline |
pack a vector selecting the properties to pack
mem | preallocated memory where to pack the vector |
sts | pack-stat info |
Definition at line 312 of file map_vector.hpp.
|
inlinestatic |
This Function indicate that vector class has a packMem function
Definition at line 33 of file map_vector.hpp.
|
inlinestatic |
Calculate the memory size required to pack n elements.
Calculate the total size required to store n-elements in a vector
n | number of elements |
e | unused |
Definition at line 1247 of file map_vector.hpp.
|
inline |
Pack the object into the given pointer.
mem | pointer |
Definition at line 1202 of file map_vector.hpp.
|
inline |
Return the size of the message needed to pack this object.
Definition at line 1187 of file map_vector.hpp.
|
inlinestatic |
This Function indicate that vector class has a packRequest function
Definition at line 23 of file map_vector.hpp.
|
inline |
It calculate the number of byte required to serialize the object.
prp | list of properties |
req | reference to the total counter required to pack the information |
Definition at line 283 of file map_vector.hpp.
|
inline |
Remove one entry from the vector.
key | element to remove |
Definition at line 595 of file map_vector.hpp.
|
inline |
Remove several entries from the vector.
keys | objects id to remove |
start | key starting point |
Definition at line 624 of file map_vector.hpp.
|
inline |
Reserve slots in the vector to avoid reallocation.
Reserve slots in the vector to avoid reallocation
sp | number of slot to reserve |
Resize the memory
Definition at line 181 of file map_vector.hpp.
|
inline |
Resize the vector.
Resize the vector and allocate n elements
slot | number of elements |
Resize the memory
Definition at line 214 of file map_vector.hpp.
|
inline |
Set the object id to obj.
id | element |
obj | object (encapsulated) |
copy the element
Definition at line 894 of file map_vector.hpp.
|
inline |
Set the object id to obj.
id | |
obj |
copy the element
Definition at line 937 of file map_vector.hpp.
|
inline |
Set the element of the vector v from another element of another vector.
id | element id |
v | vector source |
src | source element |
Definition at line 956 of file map_vector.hpp.
|
inline |
It set an element of the vector from a object that is a subset of the vector properties.
The number of properties in the source vector must be smaller than the destination all the properties of S must be mapped so if S has 3 properties 3 numbers for args are required
encap_S | object that encapsulate the object |
args | ids of the properties to map the object to |
i | element to set |
obj | object that encapsulate the object |
v | source vector |
Definition at line 921 of file map_vector.hpp.
|
inline |
Set the memory of the base structure using an object.
mem | Memory object to use for allocation |
Definition at line 1274 of file map_vector.hpp.
|
inline |
|
inline |
Swap the memory with another vector.
v | vector |
Definition at line 1101 of file map_vector.hpp.
|
inline |
Swap the memory with another vector.
v | vector |
Definition at line 1120 of file map_vector.hpp.
|
inline |
unpack a vector
mem | preallocated memory from where to unpack the vector |
ps | unpack-stat info |
Definition at line 340 of file map_vector.hpp.
|
private |
Actual size of the vector, warning: it is not the space allocated in grid grid size increase by a fixed amount every time we need a vector bigger than the actually allocated space
Definition at line 101 of file map_vector.hpp.