This file is indexed.

/usr/include/dune/functions/common/reserveddeque.hh is in libdune-functions-dev 2.5.1-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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_FUNCTIONS_COMMON_RESERVEDDEQUE_HH
#define DUNE_FUNCTIONS_COMMON_RESERVEDDEQUE_HH

/** \file
 * \brief An stl-compliant double-ended queue which stores everything on the stack
 */

#include <algorithm>
#include <iostream>
#include <cstddef>
#include <initializer_list>

#include <dune/common/genericiterator.hh>

#ifdef CHECK_RESERVEDDEQUE
#define CHECKSIZE(X) assert(X)
#else
#define CHECKSIZE(X) {}
#endif

namespace Dune {
namespace Functions {

  /**
     \brief A Vector class with statically reserved memory.

     \ingroup Utility

     ReservedDeque is something between Dune::array and std::deque.
     You have a double ended queue which can be extended and shrunk using methods like
     push_back and pop_back at the end, or via push_front and pop_front,
     but reserved memory is predefined.

     This implies that the vector can not grow bigger than the predefined
     maximum size.

     \tparam T The data type ReservedVector stores.
     \tparam n The maximum number of objects the ReservedVector can store.

   */
  template<class T, int n>
  class ReservedDeque
  {
  public:

    /** @{ Typedefs */

    //! The type of object, T, stored in the vector.
    typedef T value_type;
    //! Pointer to T.
    typedef T* pointer;
    //! Reference to T
    typedef T& reference;
    //! Const reference to T
    typedef const T& const_reference;
    //! An unsigned integral type.
    typedef size_t size_type;
    //! A signed integral type.
    typedef std::ptrdiff_t difference_type;
    //! Iterator used to iterate through a vector.
    typedef Dune::GenericIterator<ReservedDeque, value_type> iterator;
    //! Const iterator used to iterate through a vector.
    typedef Dune::GenericIterator<const ReservedDeque, const value_type> const_iterator;

    /** @} */

    /** @{ Constructors */

    //! Constructor
    ReservedDeque() :
      size_(0),
      first_(0)
    {}

    ReservedDeque(std::initializer_list<T> const &l)
    {
      assert(l.size() <= n);// Actually, this is not needed any more!
      size_ = l.size();
      std::copy_n(l.begin(), size_, data_);
    }

    /** @} */

    /** @{ Data access operations */

    //! Erases all elements.
    void clear()
    {
      first_ = 0;
      size_ = 0;
    }

    //! Specifies a new size for the vector.
    void resize(size_t s)
    {
      CHECKSIZE(s<=n);
      size_ = s;
    }

    //! Appends an element to the end of a vector, up to the maximum size n, O(1) time.
    void push_back(const T& t)
    {
      CHECKSIZE(size_<n);
      data_[size_++ % n] = t;
    }

    //! Prepends an element to the begin of a deque if size<capacity, O(1) time.
    void push_front(const T& t)
    {
      CHECKSIZE(size_<n);
      ++size_;
      first_ = (first_+(n-1)) % n;
      data_[first_] = t;
    }

    //! Erases the last element of the vector, O(1) time.
    void pop_back()
    {
      if (! empty())
        size_--;
    }

    //! Erases the first element of the vector, O(1) time.
    void pop_front()
    {
      if (! empty())
      {
        size_--;
        first_ = (++first_) % n;
      }
    }

    //! Returns a iterator pointing to the beginning of the vector.
    iterator begin(){
      return iterator(*this, 0);
    }

    //! Returns a const_iterator pointing to the beginning of the vector.
    const_iterator begin() const {
      return const_iterator(*this, 0);
    }

    //! Returns an iterator pointing to the end of the vector.
    iterator end(){
      return iterator(*this, size_);
    }

    //! Returns a const_iterator pointing to the end of the vector.
    const_iterator end() const {
      return const_iterator(*this, size_);
    }

    //! Returns reference to the i'th element.
    reference operator[] (size_type i)
    {
      CHECKSIZE(size_>i);
      return data_[(first_ + i) % n];
    }

    //! Returns a const reference to the i'th element.
    const_reference operator[] (size_type i) const
    {
      CHECKSIZE(size_>i);
      return data_[(first_ + i) % n];
    }

    //! Returns reference to first element of vector.
    reference front()
    {
      CHECKSIZE(size_>0);
      return data_[first_];
    }

    //! Returns const reference to first element of vector.
    const_reference front() const
    {
      CHECKSIZE(size_>0);
      return data_[first_];
    }

    //! Returns reference to last element of vector.
    reference back()
    {
      CHECKSIZE(size_>0);
      return data_[(first_ + size_-1) % n];
    }

    //! Returns const reference to last element of vector.
    const_reference back() const
    {
      CHECKSIZE(size_>0);
      return data_[(first_ + size_-1) % n];
    }

    /** @} */

    /** @{ Informative Methods */

    //! Returns number of elements in the vector.
    size_type size () const
    {
      return size_;
    }

    //! Returns true if vector has no elements.
    bool empty() const
    {
      return size_==0;
    }

    //! Returns current capacity (allocated memory) of the vector.
    static DUNE_CONSTEXPR size_type capacity()
    {
      return n;
    }

    //! Returns the maximum length of the vector.
    static DUNE_CONSTEXPR size_type max_size()
    {
      return n;
    }

    /** @} */

    //! Send ReservedVector to an output stream
    friend std::ostream& operator<< (std::ostream& s, const ReservedDeque& v)
    {
      for (size_t i=0; i<v.size(); i++)
        s << v[i] << "  ";
      return s;
    }

  private:
    T data_[n];
    size_type first_;
    size_type size_;
  };

} // end namespace Functions
} // end namespace Dune

#undef CHECKSIZE

#endif // DUNE_FUNCTIONS_COMMON_RESERVEDDEQUE_HH