/usr/include/JAGS/sarray/SimpleRange.h is in jags 4.2.0-2.
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 122 123 124 125 126 127 128 129 130 131 | #ifndef SIMPLE_RANGE_H_
#define SIMPLE_RANGE_H_
#include <sarray/Range.h>
#include <string>
#include <vector>
namespace jags {
/**
* @short Represents a contiguous ordered collection of array indices
*
* SimpleRange is used for a Range consisting of a contiguous
* block of indices. It is uniquely defined by its lower and upper
* bounds and contains every index in between.
*/
class SimpleRange : public Range {
public:
/**
* Default constructor which constructs a NULL range, with
* zero-length upper and lower limits.
*/
SimpleRange();
/**
* Destructor
*/
~SimpleRange();
/**
* Constructs a simple range given lower and upper limits A
* logic_error is thrown if these are of different lengths
*
* @param lower Lower limits.
*
* @param upper Upper limits. A range_error is thrown if any
* element of upper is smaller than the corresponding
* element of lower.
*
* @exception range_error
*/
SimpleRange(std::vector<int> const &lower,
std::vector<int> const &upper);
/**
* Constructs a scalar range from an index. The upper and lower
* bounds are both equal to the supplied index.
*/
SimpleRange(std::vector<int> const &index);
/**
* Constructs a range from a dimension. For each index, the lower
* limit is 1 and the upper limit is the corresponding element of
* dim (cast to a signed int).
*
* This constructor should not be confused with the constructor
* that creates a scalar range from a vector of signed integers.
*/
SimpleRange(std::vector<unsigned int> const &dim);
/**
* Equality operator. A SimpleRange is uniquely defined by
* its lower and upper limits, so testing for equality is
* much quicker than for a Range object.
*/
bool operator==(SimpleRange const &range) const;
/**
* Inequality operator
*/
bool operator!=(SimpleRange const &range) const;
/**
* Indicates whether the test SimpleRange is completely
* contained inside this SimpleRange.
*
* @param test_range Test SimpleRange
*/
bool contains(SimpleRange const &test_range) const;
/**
* Indicates whether the test Range is completely contained
* inside this SimpleRange.
*
* @param test_range Test Range
*/
bool contains(Range const &test_range) const;
/**
* The inverse of leftIndex. The left offset is the position
* of the given index in the sequence when all indices in the
* Range are written out in column major order (i.e. with the
* left index moving fastest).
*
* @param index Index vector to convert to offset. An out_of_range
* exception is thrown if the index is not contained in the range.
*
* @exception out_of_range
*/
unsigned int leftOffset(std::vector<int> const &index) const;
/**
* The inverse of rightIndex. The right offset is the position
* of the given index in the sequence when all indices in the
* range are given in row major order (i.e. with the right
* index moving fastest).
*
* @param index Index vector to convert to offset. An out_of_range
* exception is thrown if the index is not contained in the range.
*
* @exception out_of_range
*/
unsigned int rightOffset(std::vector<int> const &index) const;
/**
* Less than operator. It defines the same ordering as
* Range#operator< among SimpleRange objects but the
* calculations are more efficient as a SimpleRange is
* uniquely defined by its first and last elements.
*/
bool operator<(SimpleRange const &rhs) const;
/**
* The lower bound of the Range (an alias for Range#first)
*/
inline std::vector<int> const & lower() const { return first(); }
/**
* The upper bound of the Range (an alias for Range#last)
*/
inline std::vector<int> const & upper() const { return last(); }
};
/**
* Returns a string containing a BUGS language representation of
* the given range: e.g. a simple range with lower limit (1,2,3)
* and upper limit (3,3,3) will be printed as "[1:3,2:3,3]"
*/
std::string print(SimpleRange const &range);
} /* namespace jags */
#endif /* SIMPLE_RANGE_H_ */
|