blob: b023229e4f872e3c6e21a04a085396bda1dc6b76 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#pragma once
#include <cassert>
#include <utility>
#include <vector>
namespace mbgl {
namespace style {
template <typename T>
class Function {
public:
using Stop = std::pair<float, T>;
using Stops = std::vector<Stop>;
Function(Stops stops_, float base_)
: base(base_), stops(std::move(stops_)) {
assert(stops.size() > 0);
}
float getBase() const { return base; }
const std::vector<std::pair<float, T>>& getStops() const { return stops; }
T evaluate(float z) const;
friend bool operator==(const Function& lhs, const Function& rhs) {
return lhs.base == rhs.base && lhs.stops == rhs.stops;
}
friend bool operator!=(const Function& lhs, const Function& rhs) {
return !(lhs == rhs);
}
private:
float base = 1;
std::vector<std::pair<float, T>> stops;
};
} // namespace style
} // namespace mbgl
|