tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
FixedOracle.hpp
Go to the documentation of this file.
1#ifndef TATAMI_FIXED_ORACLE_HPP
2#define TATAMI_FIXED_ORACLE_HPP
3
4#include "../base/Oracle.hpp"
5#include <vector>
6#include <cstddef>
7
14namespace tatami {
15
21template<typename Index_>
22class FixedViewOracle final : public Oracle<Index_> {
23public:
29 FixedViewOracle(const Index_* ptr, std::size_t number) : my_reference(ptr), my_length(number) {}
30
31 std::size_t total() const {
32 return my_length;
33 }
34
35 Index_ get(std::size_t i) const {
36 return my_reference[i];
37 }
38
39private:
40 const Index_* my_reference;
41 std::size_t my_length;
42};
43
49template<typename Index_>
50class FixedVectorOracle final : public Oracle<Index_> {
51public:
55 FixedVectorOracle(std::vector<Index_> vector) : my_sequence(std::move(vector)) {}
56
57 std::size_t total() const {
58 return my_sequence.size();
59 }
60
61 Index_ get(std::size_t i) const {
62 return my_sequence[i];
63 }
64
65private:
66 std::vector<Index_> my_sequence;
67};
68
69}
70
71#endif
Oracle for data access.
Predict future accesses from a vector containing a fixed sequence.
Definition FixedOracle.hpp:50
FixedVectorOracle(std::vector< Index_ > vector)
Definition FixedOracle.hpp:55
Index_ get(std::size_t i) const
Definition FixedOracle.hpp:61
std::size_t total() const
Definition FixedOracle.hpp:57
Predict future accesses from a view on a fixed sequence.
Definition FixedOracle.hpp:22
FixedViewOracle(const Index_ *ptr, std::size_t number)
Definition FixedOracle.hpp:29
std::size_t total() const
Definition FixedOracle.hpp:31
Index_ get(std::size_t i) const
Definition FixedOracle.hpp:35
Predict future access requests on the target dimension.
Definition Oracle.hpp:23
Flexible representations for matrix data.
Definition Extractor.hpp:15