10#define CELLISTMEM_HPP_
12#include "NN/CellList/CellList.hpp"
33template<
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;
48 typedef void toKernel_type;
85 inline void addCell(local_index cell_id,
typename base::value_type
ele)
98 inline void add(local_index cell_id,
typename base::value_type
ele)
123 auto it =
cl_base.find(cell_id);
127 return it->second.size();
130 inline auto get(local_index cell, local_index
ele) ->
decltype(
cl_base[0].get(0)) &
136 return it->second.get(
ele);
140 inline auto get(local_index cell, local_index
ele)
const ->
decltype(
cl_base.find(cell)->second.get(0)) &
146 return it->second.get(
ele);
149 inline void swap(
Mem_mw & cl)
154 inline void swap(
Mem_mw && cell)
164 inline const local_index & getStartId(
size_t part_id)
const
166 auto it =
cl_base.find(part_id);
170 return it->second.get(0);
173 inline const local_index & getStopId(
size_t part_id)
const
175 auto it =
cl_base.find(part_id);
179 return *(&it->second.last() + 1);
182 inline const local_index & get_lin(
const local_index * part_id)
const
Class for MEMORY-WISE cell list implementation.
void init_to_zero(local_index slot, local_index tot_n_cell)
Initialize the data structure to zeros.
Mem_mw(size_t slot)
constructor
void addCell(local_index cell_id, typename base::value_type ele)
Add an element to the cell.
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.
Mem_mw & operator=(const Mem_mw &cell)
Copy two data-structure.
openfpm::vector< local_index > base
Base type storing information.
void remove(local_index cell, local_index ele)
Remove an element from the cell.
std::unordered_map< local_index, base > cl_base
std::remove_reference< decltype(std::declval< openfpm::vector< local_index > >().get(0))>::type invalid
In case of invalid element return this.
size_t getNelements(const local_index cell_id) const
Get the number of elements in the cell.
local_index local_index_type
expose the type of the local index
Implementation of 1-D std::vector like structure.