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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#ifndef __RCPP_PARALLEL_RVECTOR__
#define __RCPP_PARALLEL_RVECTOR__
#include <cstddef>
namespace RcppParallel {
template <typename T>
class RVector {
public:
typedef T* iterator;
typedef const T* const_iterator;
template <typename Source>
inline explicit RVector(const Source& source)
: begin_(const_cast<Source&>(source).begin()),
end_(begin_ + source.length())
{
}
inline RVector(std::size_t begin, std::size_t end)
: begin_(begin), end_(end)
{
}
inline RVector(const RVector& other)
: begin_(other.begin_), end_(other.end_)
{
}
inline RVector& operator=(const RVector& rhs) {
begin_ = rhs.begin_;
end_ = rhs.end_;
return *this;
}
inline iterator begin() { return begin_; }
inline iterator end() { return end_; }
inline const_iterator begin() const { return begin_; }
inline const_iterator end() const { return end_; }
inline std::size_t size() const { return end_ - begin_; }
inline std::size_t length() const { return end_ - begin_; }
inline T& operator[](std::size_t i) {
return *(begin_ + i);
}
inline const T& operator[](std::size_t i) const {
return *(begin_ + i);
}
private:
T* begin_;
T* end_;
};
} // namespace RcppParallel
#endif // __RCPP_PARALLEL_RVECTOR__
|