OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
Mem_fast< local_index > Class Template Reference

It is a class that work like a vector of vector. More...

Detailed Description

template<typename local_index = size_t>
class Mem_fast< local_index >

It is a class that work like a vector of vector.

Template Parameters
local_indextype used for the local index

It is a class that work like a vector(1) of vector(2). To emulate the vector of vector it use a 1D array of size N_ele * N_max_slot where N_ele is the number of elements in vector(1) and N_max_slot is the maximum number of elements across the vectors

Definition at line 30 of file MemFast.hpp.

#include <MemFast.hpp>

Public Types

typedef local_index loc_index
 expose the type of the local index
 

Public Member Functions

size_t size ()
 return the number of elements More...
 
void init_to_zero (local_index slot, local_index tot_n_cell)
 Initialize the data to zero. More...
 
void operator= (const Mem_fast< local_index > &mem)
 copy an object Mem_fast More...
 
void operator= (Mem_fast< local_index > &&mem)
 copy an object Mem_fast More...
 
void addCell (local_index cell_id, typename base::value_type ele)
 Add an element to the cell. More...
 
void add (local_index cell_id, typename base::value_type ele)
 Add an element to the cell. More...
 
auto get (local_index cell, local_index ele) -> decltype(cl_base.get(cell *slot+ele))&
 Get an element in the cell. More...
 
auto get (local_index cell, local_index ele) const -> decltype(cl_base.get(cell *slot+ele))&
 Get an element in the cell. More...
 
void remove (local_index cell, local_index ele)
 Remove an element in the cell. More...
 
size_t getNelements (const local_index cell_id) const
 Get the number of elements in the cell. More...
 
void swap (Mem_fast< local_index > &mem)
 swap to Mem_fast object More...
 
void swap (Mem_fast< local_index > &&mem)
 swap to Mem_fast object More...
 
void clear ()
 Delete all the elements in the Cell-list. More...
 
const local_index & getStartId (local_index cell_id) const
 Get the first element of a cell (as reference) More...
 
const local_index & getStopId (local_index cell_id) const
 Get the last element of a cell (as reference) More...
 
const local_index & get_lin (const local_index *part_id) const
 Just return the value pointed by part_id. More...
 
 Mem_fast (local_index slot)
 Constructor. More...
 
void set_slot (local_index slot)
 Set the number of slot for each cell. More...
 

Private Types

typedef openfpm::vector
< local_index > 
base
 base that store the data
 

Private Member Functions

void realloc ()
 realloc the data structures More...
 

Private Attributes

local_index slot
 Number of slot for each cell.
 
openfpm::vector< local_index > cl_n
 number of particle in each cell list
 
base cl_base
 

Constructor & Destructor Documentation

template<typename local_index = size_t>
Mem_fast< local_index >::Mem_fast ( local_index  slot)
inline

Constructor.

Parameters
slotnumber of slot for each cell

Definition at line 298 of file MemFast.hpp.

Member Function Documentation

template<typename local_index = size_t>
void Mem_fast< local_index >::add ( local_index  cell_id,
typename base::value_type  ele 
)
inline

Add an element to the cell.

Parameters
cell_idid of the cell
eleelement to add

Definition at line 154 of file MemFast.hpp.

template<typename local_index = size_t>
void Mem_fast< local_index >::addCell ( local_index  cell_id,
typename base::value_type  ele 
)
inline

Add an element to the cell.

Parameters
cell_idid of the cell
eleelement to add

Definition at line 131 of file MemFast.hpp.

template<typename local_index = size_t>
void Mem_fast< local_index >::clear ( )
inline

Delete all the elements in the Cell-list.

Definition at line 246 of file MemFast.hpp.

template<typename local_index = size_t>
auto Mem_fast< local_index >::get ( local_index  cell,
local_index  ele 
) -> decltype(cl_base.get(cell * slot + ele)) &
inline

Get an element in the cell.

Parameters
cellid of the cell
eleelement id in the cell
Returns
the reference to the selected element

Definition at line 169 of file MemFast.hpp.

template<typename local_index = size_t>
auto Mem_fast< local_index >::get ( local_index  cell,
local_index  ele 
) const -> decltype(cl_base.get(cell * slot + ele)) &
inline

Get an element in the cell.

Parameters
cellid of the cell
eleelement id in the cell
Returns
the reference to the selected element

Definition at line 183 of file MemFast.hpp.

template<typename local_index = size_t>
const local_index& Mem_fast< local_index >::get_lin ( const local_index *  part_id) const
inline

Just return the value pointed by part_id.

Parameters
part_id
Returns
the value pointed by part_id

Definition at line 283 of file MemFast.hpp.

template<typename local_index = size_t>
size_t Mem_fast< local_index >::getNelements ( const local_index  cell_id) const
inline

Get the number of elements in the cell.

Parameters
cell_idid of the cell
Returns
the number of elements in the cell

Definition at line 207 of file MemFast.hpp.

template<typename local_index = size_t>
const local_index& Mem_fast< local_index >::getStartId ( local_index  cell_id) const
inline

Get the first element of a cell (as reference)

Parameters
cell_idcell-id
Returns
a reference to the first element

Definition at line 259 of file MemFast.hpp.

template<typename local_index = size_t>
const local_index& Mem_fast< local_index >::getStopId ( local_index  cell_id) const
inline

Get the last element of a cell (as reference)

Parameters
cell_idcell-id
Returns
a reference to the last element

Definition at line 271 of file MemFast.hpp.

template<typename local_index = size_t>
void Mem_fast< local_index >::init_to_zero ( local_index  slot,
local_index  tot_n_cell 
)
inline

Initialize the data to zero.

Parameters
slotnumber of slot for each cell
tot_n_celltotal number of cells

Definition at line 88 of file MemFast.hpp.

template<typename local_index = size_t>
void Mem_fast< local_index >::operator= ( const Mem_fast< local_index > &  mem)
inline

copy an object Mem_fast

Parameters
memMem_fast to copy

Definition at line 107 of file MemFast.hpp.

template<typename local_index = size_t>
void Mem_fast< local_index >::operator= ( Mem_fast< local_index > &&  mem)
inline

copy an object Mem_fast

Parameters
memMem_fast to copy

Definition at line 120 of file MemFast.hpp.

template<typename local_index = size_t>
void Mem_fast< local_index >::realloc ( )
inlineprivate

realloc the data structures

Definition at line 49 of file MemFast.hpp.

template<typename local_index = size_t>
void Mem_fast< local_index >::remove ( local_index  cell,
local_index  ele 
)
inline

Remove an element in the cell.

Parameters
cellid of the cell
eleelement id to remove

Definition at line 195 of file MemFast.hpp.

template<typename local_index = size_t>
void Mem_fast< local_index >::set_slot ( local_index  slot)
inline

Set the number of slot for each cell.

Parameters
numberof slot

Definition at line 307 of file MemFast.hpp.

template<typename local_index = size_t>
size_t Mem_fast< local_index >::size ( )
inline

return the number of elements

Returns
the number of elements

Definition at line 77 of file MemFast.hpp.

template<typename local_index = size_t>
void Mem_fast< local_index >::swap ( Mem_fast< local_index > &  mem)
inline

swap to Mem_fast object

Parameters
memobject to swap the memory with

Definition at line 218 of file MemFast.hpp.

template<typename local_index = size_t>
void Mem_fast< local_index >::swap ( Mem_fast< local_index > &&  mem)
inline

swap to Mem_fast object

Parameters
memobject to swap the memory with

Definition at line 233 of file MemFast.hpp.

Field Documentation

template<typename local_index = size_t>
base Mem_fast< local_index >::cl_base
private

elements that each cell store (each cell can store a number of elements == slot )

Definition at line 43 of file MemFast.hpp.


The documentation for this class was generated from the following file: