MCPcopy Create free account
hub / github.com/apple/ml-pointersect / idxmap

Class idxmap

pointersect/pr/cpp/pr.cpp:18–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17
18struct idxmap {
19 Table table; // grid_idx -> set of point_idx
20 // ray_idx -> set of grid_idx
21
22 idxmap() {}
23
24 // reserve n capacity in the table
25 idxmap(size_t n) {
26 table.reserve(n);
27 }
28
29 // initialize with table
30 idxmap(const Table& t) {
31 table = t;
32 }
33
34 // associate pidx with gidx
35 void insert(int64_t gidx, int64_t pidx) {
36 auto iter = table.find(gidx);
37 if (iter == table.end()) {
38 table[gidx] = std::unordered_set<int64_t>({pidx});
39 }
40 else {
41 table[gidx].insert(pidx);
42 }
43 }
44
45 // get the pointer to the point index set
46 std::unordered_set<int64_t> * get_pidx(int64_t gidx) {
47 auto iter = table.find(gidx);
48 if (iter == table.end()) {
49 return nullptr;
50 }
51 else {
52 return &(table[gidx]);
53 }
54 }
55
56 // get the underlying table
57 Table get_table() {
58 return table;
59 }
60};
61
62
63

Callers 1

gather_pointsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected