interval.h
892 Bytes
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
#ifndef SHARED_VALUES_INTERVAL_H
#define SHARED_VALUES_INTERVAL_H
namespace Shared {
class Interval {
public:
Interval();
// Delete the implicit copy constructor: the object is heavy
Interval(const Interval&) = delete;
int numberOfElements();
void deleteElementAtIndex(int index);
double element(int i);
double start();
double end();
double step();
void setStart(double f);
void setEnd(double f);
void setStep(double f);
void setElement(int i, double f);
// TODO: decide the max number of elements after optimization
constexpr static int k_maxNumberOfElements = 100;
private:
void computeElements();
int m_numberOfElements;
double m_intervalBuffer[k_maxNumberOfElements];
double m_start;
double m_end;
double m_step;
bool m_needCompute;
};
typedef void (Interval::*SetterPointer)(double);
typedef double (Interval::*GetterPointer)();
}
#endif