1#ifndef MULTIDEPTHHASHGRID_H
2#define MULTIDEPTHHASHGRID_H
5#include "../primes/prime.h"
8#include <unordered_map>
9#include "simpleMultiHash.h"
14class MultiDepthHashGrid;
15class MultiLevelVector;
18class SingleDepthHashGrid{
25 friend MultiDepthHashGrid;
26 friend MultiLevelVector;
34 vector<unsigned long> _mapPosToGridPos;
40 bool addPoint(
const IndexDimension &key,
unsigned long pos);
44 bool occupied(
unsigned long &indexOfData,
const IndexDimension &I)
const;
46 bool occupied(
unsigned long &indexOfData,
const IndexDimension &I, Depth& T)
const;
48 Depth getDepth()
const {
return _depth;}
50 bool isDepth(
const Depth & depth)
const {
return _depth == depth;}
52 size_t getNumberOfEntries()
const {
return _map.size();}
54 friend std::ostream& operator<< (std::ostream& stream,
const SingleDepthHashGrid& grid){
55 stream <<
"SingleDepthHashGrid: Depth(";
56 for (
size_t i = 0; i < DimensionSparseGrid-1; i++)
58 stream << grid._depth.at(i) <<
", ";
60 stream << grid._depth.at(DimensionSparseGrid-1) <<
") with " << grid.getNumberOfEntries() <<
" entries";
66class MultiDepthHashGrid{
72 std::unordered_multimap<unsigned long,SingleDepthHashGrid> _map;
87 bool addPoint(
const IndexDimension &key,
unsigned long pos);
88 bool addPoint(
const IndexDimension &key,
unsigned long pos, Depth D);
96 std::vector<unsigned long> reorder(
bool collision =
false);
104 SingleDepthHashGrid& getGridForDepth(
const Depth &D);
111 SingleDepthHashGrid* tryGetGridForDepth(
const Depth &D);
119 vector<SingleDepthHashGrid*> getGridsForDepthInDirection(
const Depth &D,
int d);
126 SingleDepthHashGrid& getGridForDepth(
const IndexDimension &I);
129 unsigned long hash(Depth D);
131 vector<SingleDepthHashGrid*> getAllGrids();
140 for (
auto it = _map.begin(); it != _map.end(); ++it) {
141 SingleDepthHashGrid& res = it->second;
Definition sparseGrid.h:86
A simple multihash implementation. Is able to store multiple elements with the same hash.
Definition simpleMultiHash.h:154