tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
ConsecutiveOracle.hpp
Go to the documentation of this file.
1#ifndef TATAMI_CONSECUTIVE_ORACLE_HPP
2#define TATAMI_CONSECUTIVE_ORACLE_HPP
3
4#include "../base/Oracle.hpp"
6
7#include "sanisizer/sanisizer.hpp"
8
15namespace tatami {
16
22template<typename Index_>
23class ConsecutiveOracle final : public Oracle<Index_> {
24public:
29 ConsecutiveOracle(const Index_ start, const Index_ length) :
30 my_offset(start),
31 my_length(sanisizer::cast<PredictionIndex>(attest_for_Index(length)))
32 {}
33
35 return my_length;
36 }
37
38 Index_ get(PredictionIndex i) const {
39 return my_offset + i;
40 }
41
42private:
43 Index_ my_offset;
44 PredictionIndex my_length;
45};
46
55template<typename Index_>
56std::shared_ptr<ConsecutiveOracle<Index_> > make_ConsecutiveOracle(Index_ start, Index_ length) {
57 return std::make_shared<ConsecutiveOracle<Index_> >(start, length);
58}
59
60}
61
62#endif
Convert index type to container size.
Oracle for data access.
Predict future accesses along a consecutive sequence.
Definition ConsecutiveOracle.hpp:23
PredictionIndex total() const
Definition ConsecutiveOracle.hpp:34
ConsecutiveOracle(const Index_ start, const Index_ length)
Definition ConsecutiveOracle.hpp:29
Index_ get(PredictionIndex i) const
Definition ConsecutiveOracle.hpp:38
Predict future access requests on the target dimension.
Definition Oracle.hpp:29
Flexible representations for matrix data.
Definition Extractor.hpp:15
std::shared_ptr< ConsecutiveOracle< Index_ > > make_ConsecutiveOracle(Index_ start, Index_ length)
Definition ConsecutiveOracle.hpp:56
std::size_t PredictionIndex
Definition Oracle.hpp:18