9 #ifndef CELLISTMEM_HPP_
10 #define CELLISTMEM_HPP_
12 #include "NN/CellList/CellList.hpp"
33 template<
typename local_index =
size_t>
41 std::unordered_map<local_index,base>
cl_base;
44 typename std::remove_reference<decltype(std::declval<openfpm::vector<local_index>>().
get(0))>::type
invalid;
83 inline void addCell(local_index cell_id,
typename base::value_type ele)
96 inline void add(local_index cell_id,
typename base::value_type ele)
107 inline void remove(local_index cell, local_index ele)
121 auto it =
cl_base.find(cell_id);
125 return it->second.size();
128 inline auto get(local_index cell, local_index ele) -> decltype(
cl_base[0].
get(0)) &
134 return it->second.get(ele);
138 inline auto get(local_index cell, local_index ele)
const -> decltype(
cl_base.find(cell)->second.get(0)) &
144 return it->second.get(ele);
147 inline void swap(
Mem_mw & cl)
152 inline void swap(
Mem_mw && cell)
162 inline const local_index & getStartId(
size_t part_id)
const
164 auto it =
cl_base.find(part_id);
168 return it->second.get(0);
171 inline const local_index & getStopId(
size_t part_id)
const
173 auto it =
cl_base.find(part_id);
177 return *(&it->second.last() + 1);
180 inline const local_index & get_lin(
const local_index * part_id)
const
void init_to_zero(local_index slot, local_index tot_n_cell)
Initialize the data structure to zeros.
Class for MEMORY-WISE cell list implementation.
Mem_mw & operator=(const Mem_mw &cell)
Copy two data-structure.
size_t getNelements(const local_index cell_id) const
Get the number of elements in the cell.
openfpm::vector< local_index > base
Base type storing information.
void add(local_index cell_id, typename base::value_type ele)
Add an element to the cell.
void set_slot(size_t slot)
Set the number of slots.
std::remove_reference< decltype(std::declval< openfpm::vector< local_index >>().get(0))>::type invalid
In case of invalid element return this.
Mem_mw(size_t slot)
constructor
local_index loc_index
expose the type of the local index
void addCell(local_index cell_id, typename base::value_type ele)
Add an element to the cell.
std::unordered_map< local_index, base > cl_base