/usr/include/opengm/utilities/vector_view.hxx is in libopengm-dev 2.3.6+20160905-1build2.
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 | #ifndef OPENGM_VECTOR_VIEW
#define OPENGM_VECTOR_VIEW
namespace opengm{
template<class VECTOR,class INDEX_TYPE>
class VectorView{
public:
typedef VECTOR VectorType;
typedef INDEX_TYPE IndexType;
typedef typename VectorType::value_type ValueType;
typedef typename VectorType::const_iterator const_iterator;
typedef typename VectorType::iterator iterator;
VectorView(){}
VectorView(
const VectorType & vector
) : vectorPtr_(&vector),
start_(0),
size_(0){
}
VectorView(
const VectorType & vector,
const IndexType start,
const IndexType size
) : vectorPtr_(&vector),
start_(start),
size_(size){
}
void assign(
const VectorType & vector,
const IndexType start,
const IndexType size
){
vectorPtr_=&vector;
start_=start;
size_=size;
}
void assignPtr(
const VectorType & vector
){
vectorPtr_=&vector;
}
iterator begin(){
return vectorPtr_->begin()+start_;
}
iterator end(){
return vectorPtr_->begin()+start_+size_;
}
const_iterator begin()const{
return vectorPtr_->begin()+start_;
}
const_iterator end()const{
return vectorPtr_->begin()+start_+size_;
}
const IndexType size()const{
return size_;
}
const ValueType & operator[](const IndexType i)const{
return (*vectorPtr_)[start_+i];
}
ValueType & operator[](const IndexType i){
return (*vectorPtr_)[start_+i];
}
private:
const VectorType * vectorPtr_;
IndexType start_;
IndexType size_;
};
}
#endif
|