Is there a container that when inialized with a key1 at 10 and key2 at 20, when accessed at 15 will call an interpolation callback function with (key1, key2, 0.5) with return value T?
The callback ensures that we can use our preferred S-curve for the interpolation. I'm expecting accesses on each end to pass the same key in both with 1.0 as the factor.
Pseudo-code:
Container<float, MyStruct> container;
container.insert(10, MyStruct{ .x = 1.0f });
container.insert(20, MyStruct{ .x = 2.0f });
auto middlepoint = container.get(15,
[] (const MyStruct& a, const MyStruct& b, float factor) {
return MyStruct{ a.x * factor + b.x * (1.0 - factor) };
});
assert(middlepoint.x ~ 1.5f);
Have you seen this? What is this data structure called?
Thanks