This file is indexed.

/usr/lib/R/site-library/dplyr/include/tools/SlicingIndex.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
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef dplyr_tools_SlicingIndex_H
#define dplyr_tools_SlicingIndex_H

// A SlicingIndex allows specifying which rows of a data frame are selected in which order, basically a 0:n -> 0:m map.
// It also can be used to split a data frame in groups.
// Important special cases can be implemented without materializing the map.
class SlicingIndex {
public:
  virtual int size() const = 0;
  virtual int operator[](int i) const = 0;
  virtual int group() const = 0;
  virtual bool is_identity(SEXP) const {
    return FALSE;
  };
};

// A GroupedSlicingIndex is the most general slicing index,
// the 0:n -> 0:m map is specified and stored as an IntegerVector.
// A group identifier can be assigned on construction.
// It is used in grouped operations (group_by()).
class GroupedSlicingIndex : public SlicingIndex {
public:
  GroupedSlicingIndex(IntegerVector data_) : data(data_), group_index(-1) {}
  GroupedSlicingIndex(IntegerVector data_, int group_) : data(data_), group_index(group_) {}

  virtual int size() const {
    return data.size();
  }

  virtual int operator[](int i) const {
    return data[i];
  }

  virtual int group() const {
    return group_index;
  }

private:
  IntegerVector data;
  int group_index;
};

// A RowwiseSlicingIndex selects a single row, which is also the group ID by definition.
// It is used in rowwise operations (rowwise()).
class RowwiseSlicingIndex : public SlicingIndex {
public:
  RowwiseSlicingIndex(const int start_) : start(start_) {}

  inline int size() const {
    return 1;
  }

  inline int operator[](int i) const {
    if (i != 0)
      stop("Can only use 0 for RowwiseSlicingIndex, queried %d", i);
    return start;
  }

  inline int group() const {
    return start;
  }

private:
  int start;
};

// A NaturalSlicingIndex selects an entire data frame as a single group.
// It is used when the entire data frame needs to be processed by a processor that expects a SlicingIndex
// to address the rows.
class NaturalSlicingIndex : public SlicingIndex {
public:
  NaturalSlicingIndex(const int n_) : n(n_) {}

  virtual int size() const {
    return n;
  }

  virtual int operator[](int i) const {
    if (i < 0 || i >= n)
      stop("Out of bounds index %d queried for NaturalSlicingIndex", i);
    return i;
  }

  virtual int group() const {
    return -1;
  }

  virtual bool is_identity(SEXP x) const {
    const R_len_t length = Rf_length(x);
    return length == n;
  }

private:
  int n;
};

// An OffsetSlicingIndex selects a consecutive part of a data frame, starting at a specific row.
// It is used for binding data frames vertically (bind_rows()).
class OffsetSlicingIndex : public SlicingIndex {
public:
  OffsetSlicingIndex(const int start_, const int n_) : start(start_), n(n_) {}

  inline int size() const {
    return n;
  }

  inline int operator[](int i) const {
    if (i < 0 || i >= n)
      stop("Out of bounds index %d queried for OffsetSlicingIndex", i);
    return i + start;
  }

  inline int group() const {
    return -1;
  }

private:
  int start, n;
};

#endif