tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
ArrayView.hpp
Go to the documentation of this file.
1#ifndef TATAMI_ARRAY_VIEW_HPP
2#define TATAMI_ARRAY_VIEW_HPP
3
4#include <cstddef>
5
11namespace tatami {
12
22template<typename Type_>
23class ArrayView {
24public:
30 ArrayView(const Type_* const ptr, const std::size_t number) : my_ptr(ptr), my_number(number) {}
31
35 ArrayView() : ArrayView(NULL, 0) {}
36
40 std::size_t size() const { return my_number; }
41
45 const Type_* data() const { return my_ptr; }
46
50 const Type_* begin() const { return my_ptr; }
51
55 const Type_* end() const { return my_ptr + my_number; }
56
61 Type_ operator[](std::size_t i) const {
62 return my_ptr[i];
63 }
64
65private:
66 const Type_* my_ptr;
67 std::size_t my_number;
68};
69
70}
71
72#endif
View into a pre-allocated array.
Definition ArrayView.hpp:23
const Type_ * end() const
Definition ArrayView.hpp:55
Type_ operator[](std::size_t i) const
Definition ArrayView.hpp:61
ArrayView(const Type_ *const ptr, const std::size_t number)
Definition ArrayView.hpp:30
const Type_ * begin() const
Definition ArrayView.hpp:50
ArrayView()
Definition ArrayView.hpp:35
const Type_ * data() const
Definition ArrayView.hpp:45
std::size_t size() const
Definition ArrayView.hpp:40
Flexible representations for matrix data.
Definition Extractor.hpp:15