OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
Mem_fast< Memory, local_index > Class Template Reference

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

Detailed Description

template<typename Memory = HeapMemory, typename local_index = size_t>
class Mem_fast< Memory, 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 88 of file MemFast.hpp.

#include <MemFast.hpp>

+ Inheritance diagram for Mem_fast< Memory, local_index >:

Public Types

typedef Mem_fast_ker< Memory, memory_traits_lin, local_index > toKernel_type
 
typedef local_index local_index_type
 
typedef local_index loc_index
 expose the type of the local index
 

Public Member Functions

size_t size () const
 return the number of elements
 
void destroy ()
 Destroy the internal memory including the retained one.
 
void init_to_zero (local_index slot, local_index tot_n_cell)
 Initialize the data to zero.
 
void operator= (const Mem_fast< Memory, local_index > &mem)
 copy an object Mem_fast
 
void operator= (Mem_fast< Memory, local_index > &&mem)
 copy an object Mem_fast
 
template<typename Memory2 >
void copy_general (const Mem_fast< Memory2, local_index > &mem)
 copy an object Mem_fast
 
void addCell (local_index cell_id, local_index ele)
 Add an element to the cell.
 
void add (local_index cell_id, local_index ele)
 Add an element to the cell.
 
auto get (local_index cell, local_index ele) -> decltype(cl_base.template get< 0 >(cell *slot+ele)) &
 Get an element in the cell.
 
auto get (local_index cell, local_index ele) const -> decltype(cl_base.template get< 0 >(cell *slot+ele)) &
 Get an element in the cell.
 
void remove (local_index cell, local_index ele)
 Remove an element in the cell.
 
size_t getNelements (const local_index cell_id) const
 Get the number of elements in the cell.
 
void swap (Mem_fast< Memory, local_index > &mem)
 swap to Mem_fast object
 
void swap (Mem_fast< Memory, local_index > &&mem)
 swap to Mem_fast object
 
void clear ()
 Delete all the elements in the Cell-list.
 
const local_index & getStartId (local_index cell_id) const
 Get the first element of a cell (as reference)
 
const local_index & getStopId (local_index cell_id) const
 Get the last element of a cell (as reference)
 
const local_index & get_lin (const local_index *part_id) const
 Just return the value pointed by part_id.
 
 Mem_fast (local_index slot)
 Constructor.
 
void set_slot (local_index slot)
 Set the number of slot for each cell.
 
const openfpm::vector< aggregate< local_index >, Memory > & private_get_cl_n () const
 Return the private data-structure cl_n.
 
const int & private_get_slot () const
 Return the private slot.
 
const baseprivate_get_cl_base () const
 Return the private data-structure cl_base.
 

Private Types

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

Private Member Functions

void realloc ()
 realloc the data structures
 

Private Attributes

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

Member Typedef Documentation

◆ base

template<typename Memory = HeapMemory, typename local_index = size_t>
typedef openfpm::vector<aggregate<local_index>,Memory> Mem_fast< Memory, local_index >::base
private

base that store the data

Definition at line 97 of file MemFast.hpp.

◆ loc_index

template<typename Memory = HeapMemory, typename local_index = size_t>
typedef local_index Mem_fast< Memory, local_index >::loc_index

expose the type of the local index

Definition at line 376 of file MemFast.hpp.

◆ local_index_type

template<typename Memory = HeapMemory, typename local_index = size_t>
typedef local_index Mem_fast< Memory, local_index >::local_index_type

Definition at line 132 of file MemFast.hpp.

◆ toKernel_type

template<typename Memory = HeapMemory, typename local_index = size_t>
typedef Mem_fast_ker<Memory,memory_traits_lin,local_index> Mem_fast< Memory, local_index >::toKernel_type

Definition at line 130 of file MemFast.hpp.

Constructor & Destructor Documentation

◆ Mem_fast()

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

Constructor.

Parameters
slotnumber of slot for each cell

Definition at line 383 of file MemFast.hpp.

Member Function Documentation

◆ add()

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

Add an element to the cell.

Parameters
cell_idid of the cell
eleelement to add

Definition at line 239 of file MemFast.hpp.

◆ addCell()

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

Add an element to the cell.

Parameters
cell_idid of the cell
eleelement to add

Definition at line 216 of file MemFast.hpp.

◆ clear()

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

Delete all the elements in the Cell-list.

Definition at line 331 of file MemFast.hpp.

◆ copy_general()

template<typename Memory = HeapMemory, typename local_index = size_t>
template<typename Memory2 >
void Mem_fast< Memory, local_index >::copy_general ( const Mem_fast< Memory2, local_index > &  mem)
inline

copy an object Mem_fast

Parameters
memMem_fast to copy

Definition at line 202 of file MemFast.hpp.

◆ destroy()

template<typename Memory = HeapMemory, typename local_index = size_t>
void Mem_fast< Memory, local_index >::destroy ( )
inline

Destroy the internal memory including the retained one.

Definition at line 147 of file MemFast.hpp.

◆ get() [1/2]

template<typename Memory = HeapMemory, typename local_index = size_t>
auto Mem_fast< Memory, local_index >::get ( local_index  cell,
local_index  ele 
) -> decltype(cl_base.template get<0>(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 254 of file MemFast.hpp.

◆ get() [2/2]

template<typename Memory = HeapMemory, typename local_index = size_t>
auto Mem_fast< Memory, local_index >::get ( local_index  cell,
local_index  ele 
) const -> decltype(cl_base.template get<0>(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 268 of file MemFast.hpp.

◆ get_lin()

template<typename Memory = HeapMemory, typename local_index = size_t>
const local_index & Mem_fast< Memory, 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 368 of file MemFast.hpp.

◆ getNelements()

template<typename Memory = HeapMemory, typename local_index = size_t>
size_t Mem_fast< Memory, 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 292 of file MemFast.hpp.

◆ getStartId()

template<typename Memory = HeapMemory, typename local_index = size_t>
const local_index & Mem_fast< Memory, 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 344 of file MemFast.hpp.

◆ getStopId()

template<typename Memory = HeapMemory, typename local_index = size_t>
const local_index & Mem_fast< Memory, 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 356 of file MemFast.hpp.

◆ init_to_zero()

template<typename Memory = HeapMemory, typename local_index = size_t>
void Mem_fast< Memory, 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 159 of file MemFast.hpp.

◆ operator=() [1/2]

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

copy an object Mem_fast

Parameters
memMem_fast to copy

Definition at line 178 of file MemFast.hpp.

◆ operator=() [2/2]

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

copy an object Mem_fast

Parameters
memMem_fast to copy

Definition at line 191 of file MemFast.hpp.

◆ private_get_cl_base()

template<typename Memory = HeapMemory, typename local_index = size_t>
const base & Mem_fast< Memory, local_index >::private_get_cl_base ( ) const
inline

Return the private data-structure cl_base.

Returns
cl_base

Definition at line 444 of file MemFast.hpp.

◆ private_get_cl_n()

template<typename Memory = HeapMemory, typename local_index = size_t>
const openfpm::vector< aggregate< local_index >, Memory > & Mem_fast< Memory, local_index >::private_get_cl_n ( ) const
inline

Return the private data-structure cl_n.

Returns
cl_n

Definition at line 424 of file MemFast.hpp.

◆ private_get_slot()

template<typename Memory = HeapMemory, typename local_index = size_t>
const int & Mem_fast< Memory, local_index >::private_get_slot ( ) const
inline

Return the private slot.

Returns
slot

Definition at line 434 of file MemFast.hpp.

◆ realloc()

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

realloc the data structures

Definition at line 107 of file MemFast.hpp.

◆ remove()

template<typename Memory = HeapMemory, typename local_index = size_t>
void Mem_fast< Memory, 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 280 of file MemFast.hpp.

◆ set_slot()

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

Set the number of slot for each cell.

Parameters
numberof slot

Definition at line 392 of file MemFast.hpp.

◆ size()

template<typename Memory = HeapMemory, typename local_index = size_t>
size_t Mem_fast< Memory, local_index >::size ( ) const
inline

return the number of elements

Returns
the number of elements

Definition at line 139 of file MemFast.hpp.

◆ swap() [1/2]

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

swap to Mem_fast object

Parameters
memobject to swap the memory with

Definition at line 318 of file MemFast.hpp.

◆ swap() [2/2]

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

swap to Mem_fast object

Parameters
memobject to swap the memory with

Definition at line 303 of file MemFast.hpp.

Field Documentation

◆ cl_base

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

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

Definition at line 101 of file MemFast.hpp.

◆ cl_n

template<typename Memory = HeapMemory, typename local_index = size_t>
openfpm::vector<aggregate<local_index>,Memory> Mem_fast< Memory, local_index >::cl_n
private

number of particle in each cell list

Definition at line 94 of file MemFast.hpp.

◆ slot

template<typename Memory = HeapMemory, typename local_index = size_t>
local_index Mem_fast< Memory, local_index >::slot
private

Number of slot for each cell.

Definition at line 91 of file MemFast.hpp.


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