Memoizer.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <functional>
4
#include <Eigen/Core>
5
#include <vector>
6
#include <string>
7
#include <map>
8
#include <iostream>
9
10
using
TaggedPoints
= std::pair<std::string, std::vector<Eigen::Vector3f>>;
11
12
template
<
typename
R>
13
std::function<R(
TaggedPoints
)>
memoized
(R(*fn)(
const
std::vector<Eigen::Vector3f>&))
14
{
15
/*static*/
std::map<std::string, R> table;
16
return
[table, fn](
const
TaggedPoints
& points)
mutable
-> R
17
{
18
auto
argt = points.first;
19
auto
memoized
= table.find(argt);
20
21
if
(
memoized
== table.end())
22
{
23
auto
result = fn(points.second);
24
table[argt] = result;
25
return
result;
26
}
27
else
28
{
29
return
memoized
->second;
30
}
31
};
32
}
33
memoized
std::function< R(TaggedPoints)> memoized(R(*fn)(const std::vector< Eigen::Vector3f > &))
Definition:
Memoizer.hpp:13
TaggedPoints
std::pair< std::string, std::vector< Eigen::Vector3f > > TaggedPoints
Definition:
Memoizer.hpp:10
VisionX
components
pointcloud_processor
ObjectShapeClassification
Features
Memoizer.hpp
Generated on Sat Oct 12 2024 09:14:17 for armarx_documentation by
1.8.17