/usr/lib/R/site-library/dplyr/include/tools/ShrinkableVector.h is in r-cran-dplyr 0.7.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #ifndef dplyr_ShrinkableVector_H
#define dplyr_ShrinkableVector_H
#include <tools/encoding.h>
#include <tools/utils.h>
namespace Rcpp {
template <int RTYPE>
class ShrinkableVector {
public:
typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE;
ShrinkableVector(int n, SEXP origin) :
data(no_init(n)), max_size(n), start(internal::r_vector_start<RTYPE>(data)), gp(LEVELS(data))
{
copy_most_attributes(data, origin);
SET_DPLYR_SHRINKABLE_VECTOR((SEXP)data);
}
inline void resize(int n) {
SETLENGTH(data, n);
}
inline operator SEXP() const {
return data;
}
inline void borrow(const SlicingIndex& indices, STORAGE* begin) {
int n = indices.size();
for (int i = 0; i < n; i++) {
start[i] = begin[indices[i]];
}
SETLENGTH(data, n);
}
~ShrinkableVector() {
// restore the initial length so that R can reclaim the memory
SETLENGTH(data, max_size);
UNSET_DPLYR_SHRINKABLE_VECTOR((SEXP)data);
}
private:
Rcpp::Vector<RTYPE> data;
int max_size;
STORAGE* start;
unsigned short gp;
};
inline bool is_ShrinkableVector(SEXP x) {
return IS_DPLYR_SHRINKABLE_VECTOR(x);
}
}
#endif
|