/usr/include/linbox/vector/reverse.h is in liblinbox-dev 1.1.6~rc0-4.1.
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 132 133 134 135 136 137 138 139 | /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* linbox/vector/reverse.h
* Copyright (C) 2002 Bradford Hovinen
*
* ------------------------------------
*
* See COPYING for license information.
*/
#ifndef __REVERSE_H
#define __REVERSE_H
#include "vector-traits.h"
#include <iterator>
#include <vector>
#include <stdexcept>
namespace LinBox
{
/** Reverse vector class
* This class wraps an existing vector type and reverses its
* direction. It is used as an adaptor to allow VectorDomain dot
* products to be used for the Massy implementation.
\ingroup vector
*/
template <class Vector>
class ReverseVector
{
public:
typedef typename Vector::value_type value_type;
typedef typename Vector::size_type size_type;
typedef typename Vector::difference_type difference_type;
typedef typename Vector::pointer pointer;
typedef typename Vector::reference reference;
typedef typename Vector::const_reference const_reference;
typedef typename Vector::reverse_iterator iterator;
typedef typename Vector::const_reverse_iterator const_iterator;
typedef typename Vector::iterator reverse_iterator;
typedef typename Vector::const_iterator const_reverse_iterator;
ReverseVector (Vector& v)
: _v (v) {}
// Copy constructor
ReverseVector (const ReverseVector<Vector> &v)
: _v (v._v) {}
~ReverseVector () {}
// Iterators
inline iterator begin (void) { return _v.rbegin (); }
inline const_iterator begin (void) const { return _v.rbegin (); }
inline iterator end (void) { return _v.rend (); }
inline const_iterator end (void) const { return _v.rend (); }
inline reverse_iterator rbegin (void) { return _v.begin (); }
inline const_reverse_iterator rbegin (void) const { return _v.begin (); }
inline reverse_iterator rend (void) { return _v.end (); }
inline const_reverse_iterator rend (void) const { return _v.end (); }
// Element access
inline reference operator[] (size_type n) { return (begin ())[n]; }
inline const_reference operator[] (size_type n) const { return (begin ())[n]; }
// the method "at" does appear to be implemented
// in the gnu implementation of the STL
reference at (size_type n) // validity is relative to valid _begin, _end
{
iterator p = begin () + n;
if (begin () <= p && p < end ())
return *p;
else
throw std::out_of_range(); //out of range error message.
}
const_reference at(size_type n) const
{
const_iterator p = begin () + n;
if (begin () <= p && p < end ())
return *p;
else
throw std::out_of_range(); //out of range error message
}
inline reference front (void) { return *begin (); }
inline const_reference front (void) const { return *begin (); }
inline reference back (void) { return *(end () - 1); }
inline const_reference back (void) const { return *(end () - 1); }
template<class Container>
/** assign the elements of Container one by one to *this.
* Container must be at least as long as this.
*/
ReverseVector &operator= (const Container& x)
{
typename Container::const_iterator q = x.begin ();
for (iterator p = begin (); p != end (); ++p, ++q)
*p = *q;
return *this;
}
// template <class In> void assign(In first, In last);
// void assign(size_type n, const T& val);
// Stack operations:
// not implemented because they invalidate iterators
// List operations:
// not implemented because they invalidate iterators
// Capacity
// resize, reserve: not implemented because they
// invalidate iterators
inline size_type size (void) const { return _v.size (); }
inline bool empty (void) const { return _v.empty (); }
inline size_type max_size (void) const { return _v.size (); }
protected:
Vector &_v;
}; // template <class Vector> class ReverseVector
// Vector traits for ReverseVector wrapper
template <class Vector>
struct VectorTraits<ReverseVector<Vector> >
{
typedef typename VectorTraits<Vector>::VectorCategory VectorCategory;
};
} // namespace LinBox
#endif
|