This file is indexed.

/usr/include/vigra/navigator.hxx is in libvigraimpex-dev 1.10.0+dfsg-3ubuntu2.

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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
/************************************************************************/
/*                                                                      */
/*                Copyright 2004 by Ullrich Koethe                      */
/*                                                                      */
/*    This file is part of the VIGRA computer vision library.           */
/*    The VIGRA Website is                                              */
/*        http://hci.iwr.uni-heidelberg.de/vigra/                       */
/*    Please direct questions, bug reports, and contributions to        */
/*        ullrich.koethe@iwr.uni-heidelberg.de    or                    */
/*        vigra@informatik.uni-hamburg.de                               */
/*                                                                      */
/*    Permission is hereby granted, free of charge, to any person       */
/*    obtaining a copy of this software and associated documentation    */
/*    files (the "Software"), to deal in the Software without           */
/*    restriction, including without limitation the rights to use,      */
/*    copy, modify, merge, publish, distribute, sublicense, and/or      */
/*    sell copies of the Software, and to permit persons to whom the    */
/*    Software is furnished to do so, subject to the following          */
/*    conditions:                                                       */
/*                                                                      */
/*    The above copyright notice and this permission notice shall be    */
/*    included in all copies or substantial portions of the             */
/*    Software.                                                         */
/*                                                                      */
/*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND    */
/*    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES   */
/*    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND          */
/*    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT       */
/*    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,      */
/*    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      */
/*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR     */
/*    OTHER DEALINGS IN THE SOFTWARE.                                   */                
/*                                                                      */
/************************************************************************/

#ifndef VIGRA_NAVIGATOR_HXX
#define VIGRA_NAVIGATOR_HXX

#include "multi_shape.hxx"

namespace vigra {

/********************************************************/
/*                                                      */
/*                MultiArrayNavigator                   */
/*                                                      */
/********************************************************/

/** \brief A navigator that provides access to the 1D subranges of an
    n-dimensional range given by a \ref vigra::MultiIterator and an nD shape.

    Normally, the innermost loop of an iteration extends over the innermost
    dimension of a given array. Sometimes, however, it is necessary to have
    some other dimension in the inner loop. For example, instead of iterating over
    the rows, the inner loop should extend over the columns. The class MultiArrayNavigator
    encapsulates the necessary functionality. Given an arbitrary dimensional
    array (represented by a vigra::MultiIterator/shape pair), and the desired
    inner loop dimension <TT>d</TT>, it moves the encapsulated iterator to all possible
    starting points of 1D subsets along the given dimension (e.g. all columns). By calling
    <TT>begin()</TT> and <TT>end()</TT>, one can then obtain an STL-compatible 1-dimensional
    iterator for the current subset.

    The template parameters specify the embedded iterator type and its dimension.

    <b>Usage:</b>

    <b>\#include</b> \<vigra/navigator.hxx\>

    Namespace: vigra

    \code
    typedef vigra::MultiArray<3, int>  Array;

    Array a(Array::size_type(X, Y, Z));

    typedef vigra::MultiArrayNavigator<Array::traverser, 3> Navigator;

    for(int d=0; d<3; ++d)
    {
        // create Navigator for dimension d
        Navigator nav(a.traverser_begin(), a.shape(), d);

        // outer loop: move navigator to all starting points
        // of 1D subsets that run parallel to coordinate axis d
        for(; nav.hasMore(); ++nav)
        {
            // inner loop: linear iteration over current subset
            //             d == {0, 1, 2}: iterate along {x, y, z}-axis respectively
            Navigator::iterator i = nav.begin(), end = nav.end();
            for(; i != end; ++i)
                // do something
        }
    }
    \endcode
*/
template <class MULTI_ITERATOR, unsigned int N>
class MultiArrayNavigator
#ifndef DOXYGEN  // doxygen doesn't understand this inheritance
: public MultiArrayNavigator<MULTI_ITERATOR, N-1>
#endif
{
    typedef MultiArrayNavigator<MULTI_ITERATOR, N-1> base_type;

  public:
    enum { level = N-1 };

        /** The required shape type for the given iterator type.
         */
    typedef typename MULTI_ITERATOR::multi_difference_type shape_type;

        /** The iterator type for the inner loop (result of begin() and end()).
         */
    typedef typename MULTI_ITERATOR::iterator iterator;

        /** Construct navigator for multi-dimensional iterator <TT>i</TT>, array shape <TT>shape</TT>
            and inner loop dimension <TT>inner_dimension</TT>.
         */
    MultiArrayNavigator(MULTI_ITERATOR const & i, shape_type const & shape, unsigned int inner_dimension)
    : base_type(i, shape, inner_dimension)
    {}

    MultiArrayNavigator(MULTI_ITERATOR const & i, shape_type const & start, shape_type const & stop, 
                        unsigned int inner_dimension)
    : base_type(i, start, stop, inner_dimension)
    {}

        /** Advance to next starting location.
         */
    void operator++()
    {
        base_type::operator++();
        if(this->point_[level-1] == this->stop_[level-1])
        {
            base_type::reset();
            ++this->point_[level];
            ++this->i_.template dim<level>();
        }
    }

        /** Advance to next starting location.
         */
    void operator++(int)
    {
        ++*this;
    }

        /** true if there are more elements.
         */
    bool hasMore() const
    {
        return this->point_[level] < this->stop_[level];
    }

        /** true if iterator is exhausted.
         */
    bool atEnd() const
    {
        return this->point_[level] >= this->stop_[level];
    }

  protected:
    void reset()
    {
        this->point_[level] = this->start_[level];
        this->i_.template dim<level>() -= (this->stop_[level] - this->start_[level]);
    }
};

template <class MULTI_ITERATOR>
class MultiArrayNavigator<MULTI_ITERATOR, 1>
{
  public:
    enum { level = 0 };
    typedef typename MULTI_ITERATOR::multi_difference_type shape_type;
    typedef typename MULTI_ITERATOR::iterator iterator;

    MultiArrayNavigator(MULTI_ITERATOR const & i, shape_type const & shape, unsigned int inner_dimension)
    : start_(), stop_(shape), point_(start_),
      inner_dimension_(inner_dimension),
      inner_shape_(stop_[inner_dimension] - start_[inner_dimension]),
      i_(i + start_)
    {
        if(stop_[inner_dimension] > start_[inner_dimension])
            stop_[inner_dimension] = start_[inner_dimension] + 1;
    }

    MultiArrayNavigator(MULTI_ITERATOR const & i, shape_type const & start, shape_type const & stop, 
                        unsigned int inner_dimension)
    : start_(start), stop_(stop), point_(start_),
      inner_dimension_(inner_dimension),
      inner_shape_(stop_[inner_dimension] - start_[inner_dimension]),
      i_(i + start_)
    {
        if(stop_[inner_dimension] > start_[inner_dimension])
            stop_[inner_dimension] = start_[inner_dimension] + 1;
    }

    void operator++()
    {
        ++point_[level];
        ++i_.template dim<level>();
    }

    void operator++(int)
    {
        ++*this;
    }

    iterator begin() const
    {
        return i_.iteratorForDimension(inner_dimension_);
    }

    iterator end() const
    {
        return begin() + inner_shape_;
    }

    bool hasMore() const
    {
        return point_[level] < stop_[level];
    }

    bool atEnd() const
    {
        return point_[level] >= stop_[level];
    }
    
    shape_type const & point() const
    {
        return point_;
    }

  protected:
    void reset()
    {
        point_[level] = start_[level];
        i_.template dim<level>() -= (stop_[level] - start_[level]);
   }

    shape_type start_, stop_, point_;
    unsigned int inner_dimension_, inner_shape_;
    MULTI_ITERATOR i_;
};

/********************************************************/
/*                                                      */
/*               MultiCoordinateNavigator               */
/*                                                      */
/********************************************************/

/** \brief A navigator that provides access to the 1D subranges of an
    n-dimensional range given by an nD shape.

    This class works similarly to \ref MultiArrayNavigator, but instead of a 
    1-dimensional iterator pair, it returns a pair of shapes whose difference
    specifies a 1-dimensional range along the desired dimension. That is, when
    the navigator refers to dimension <tt>d</tt>, the difference between
    <tt>end()</tt> and <tt>begin()</tt> is <tt>1</tt> along all dimensions
    except <tt>d</tt>.

    The template parameters specifies the dimension of the shape.

    <b>Usage:</b>

    <b>\#include</b> \<vigra/navigator.hxx\>

    Namespace: vigra

    \code
    typedef vigra::MultiArrayShape<3>::type Shape;
    typedef vigra::MultiArray<3, int>  Array;
    typedef vigra::MultiCoordinateNavigator<3> Navigator;

    Array a(Shape(X, Y, Z));

    for(int d=0; d<3; ++d)
    {
        // create Navigator for dimension d
        Navigator nav(a.shape(), d);

        // outer loop: move navigator to all starting points
        // of 1D subsets that run parallel to coordinate axis d
        for(; nav.hasMore(); ++nav)
        {
            // inner loop: linear iteration over current subset
            //             d == {0, 1, 2}: iterate along {x, y, z}-axis respectively
            Shape point = nav.begin(), end = nav.end();
            for(; point[d] != end[d]; ++point[d])
                a[point] = 5;
        }
    }
    \endcode
*/
template <unsigned int Dimensions, unsigned int N = Dimensions>
class MultiCoordinateNavigator
#ifndef DOXYGEN  // doxygen doesn't understand this inheritance
: public MultiCoordinateNavigator<Dimensions, N-1>
#endif
{
    typedef MultiCoordinateNavigator<Dimensions, N-1> base_type;

  public:
    enum { level = N-1 };

        /** The shape type for the given iterator type.
         */
    typedef typename MultiArrayShape<Dimensions>::type value_type;


        /** Construct navigator for multi-dimensional iterator <TT>i</TT>, array shape <TT>shape</TT>
            and inner loop dimension <TT>inner_dimension</TT>.
         */
    MultiCoordinateNavigator(value_type const & shape, unsigned int inner_dimension)
    : base_type(shape, inner_dimension)
    {
        this->end_[level] = (this->inner_dimension_ == level)
                                 ? 1
                                 : this->shape_[level];
    }

        /** Advance to next starting location.
         */
    void operator++()
    {
        base_type::operator++();
        if(base_type::atEnd() && this->i_[level] < this->end_[level])
        {
            ++this->i_[level];
            if(this->i_[level] < this->end_[level])
                base_type::reset();
        }
    }

        /** Advance to next starting location.
         */
    void operator++(int)
    {
        ++*this;
    }

        /** true if there are more elements.
         */
    bool hasMore() const
    {
        return this->inner_dimension_ == level 
                     ? base_type::hasMore() 
                     : this->i_[level] < this->end_[level];
    }

        /** true if iterator is exhausted.
         */
    bool atEnd() const
    {
        return !hasMore();
        // return this->inner_dimension_ == level 
                     // ? base_type::atEnd()
                     // : !(this->i_[level] < this->end_[level]);
    }

  protected:
    void reset()
    {
        this->i_[level] = 0;
        this->end_[level] = (this->inner_dimension_ == level)
                                 ? 1
                                 : this->shape_[level];
        base_type::reset();
    }
};

template <unsigned int Dimensions>
class MultiCoordinateNavigator<Dimensions, 1>
{
  public:
    enum { level = 0 };
    typedef typename MultiArrayShape<Dimensions>::type value_type;
 
    MultiCoordinateNavigator(value_type const & shape, unsigned int inner_dimension)
    : shape_(shape),
      inner_dimension_(inner_dimension)
    {
        end_[level] = (inner_dimension_ == level)
                         ? 1
                         : shape_[level];
    }

    void operator++()
    {
        ++i_[level];
    }

    void operator++(int)
    {
        ++*this;
    }

    value_type const & begin() const
    {
        return i_;
    }

    value_type end() const
    {
        value_type res = i_ + value_type(MultiArrayIndex(1));
        res[inner_dimension_] = shape_[inner_dimension_];
        return res;
    }

    bool hasMore() const
    {
        return i_[level] < end_[level];
    }

    bool atEnd() const
    {
      return !hasMore();
    }

  protected:
    void reset()
    {
        i_[level] = 0;
        end_[level] = (inner_dimension_ == level)
                         ? 1
                         : shape_[level];
    }

    value_type shape_, i_, end_;
    unsigned int inner_dimension_;
};

} // namespace vigra

#endif /* VIGRA_NAVIGATOR_HXX */