This file is indexed.

/usr/include/gecode/iter/ranges-inter.hpp is in libgecode-dev 4.4.0-5.

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
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
 *  Main authors:
 *     Christian Schulte <schulte@gecode.org>
 *
 *  Copyright:
 *     Christian Schulte, 2004
 *
 *  Last modified:
 *     $Date: 2012-09-07 17:42:21 +0200 (Fri, 07 Sep 2012) $ by $Author: schulte $
 *     $Revision: 13069 $
 *
 *  This file is part of Gecode, the generic constraint
 *  development environment:
 *     http://www.gecode.org
 *
 *  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.
 *
 */

#include <algorithm>

namespace Gecode { namespace Iter { namespace Ranges {

  /**
   * \brief Range iterator for computing intersection (binary)
   *
   * \ingroup FuncIterRanges
   */
  template<class I, class J>
  class Inter : public MinMax {
  protected:
    /// First iterator
    I i;
    /// Second iterator
    J j;
  public:
    /// \name Constructors and initialization
    //@{
    /// Default constructor
    Inter(void);
    /// Initialize with iterator \a i and \a j
    Inter(I& i, J& j);
    /// Initialize with iterator \a i and \a j
    void init(I& i, J& j);
    //@}

    /// \name Iteration control
    //@{
    /// Move iterator to next range (if possible)
    void operator ++(void);
    //@}
  };


  /**
   * \brief Range iterator for intersection of iterators
   *
   * \ingroup FuncIterRanges
   */
  class NaryInter : public RangeListIter {
  protected:
    /// Freelist
    RangeList* f;
  public:
    /// \name Constructors and initialization
    //@{
    /// Default constructor
    NaryInter(void);
    /// Initialize with single iterator \a i
    template<class I>
    NaryInter(Region& r, I& i);
    /// Initialize with iterators \a i and \a j
    template<class I, class J>
    NaryInter(Region& r, I& i, J& j);
    /// Initialize with \a n iterators in \a i
    template<class I>
    NaryInter(Region& r, I* i, int n);
    /// Initialize with single iterator \a i
    template<class I>
    void init(Region& r, I& i);
    /// Initialize with iterators \a i and \a j
    template<class I, class J>
    void init(Region& r, I& i, J& j);
    /// Initialize with \a n iterators in \a i
    template<class I>
    void init(Region& r, I* i, int n);
    /// Add iterator \a i
    template<class I>
    void operator &=(I& i);
    /// Assignment operator (both iterators must be allocated from the same region)
    NaryInter& operator =(const NaryInter& m);
    //@}
  };



  /*
   * Binary intersection
   *
   */

  template<class I, class J>
  inline void
  Inter<I,J>::operator ++(void) {
    if (!i() || !j()) goto done;
    do {
      while (i() && (i.max() < j.min())) ++i;
      if (!i()) goto done;
      while (j() && (j.max() < i.min())) ++j;
      if (!j()) goto done;
    } while (i.max() < j.min());
    // Now the intervals overlap: consume the smaller interval
    ma = std::min(i.max(),j.max());
    mi = std::max(i.min(),j.min());
    if (i.max() < j.max()) ++i; else ++j;
    return;
  done:
    finish();
  }

  template<class I, class J>
  forceinline
  Inter<I,J>::Inter(void) {}

  template<class I, class J>
  forceinline
  Inter<I,J>::Inter(I& i0, J& j0)
    : i(i0), j(j0) {
    operator ++();
  }

  template<class I, class J>
  forceinline void
  Inter<I,J>::init(I& i0, J& j0) {
    i = i0; j = j0;
    operator ++();
  }


  /*
   * Nary intersection
   *
   */

  forceinline
  NaryInter::NaryInter(void) {}

  template<class I>
  forceinline void
  NaryInter::init(Region& r, I& i) {
    RangeListIter::init(r);
    f = NULL;
    set(copy(i));
  }

  template<class I, class J>
  forceinline void
  NaryInter::init(Region& r, I& i, J& j) {
    RangeListIter::init(r);
    f = NULL;
    RangeList*  h;
    RangeList** c = &h;
    while (i() && j()) {
      do {
        while (i() && (i.max() < j.min())) ++i;
        if (!i()) goto done;
        while (j() && (j.max() < i.min())) ++j;
        if (!j()) goto done;
      } while (i.max() < j.min());
      // Now the intervals overlap: consume the smaller interval
      RangeList* t = range(std::max(i.min(),j.min()),
                           std::min(i.max(),j.max()));
      *c = t; c = &t->next;
      if (i.max() < j.max()) ++i; else ++j;
    }
  done:
    *c = NULL;
    set(h);
  }

  template<class I>
  forceinline void
  NaryInter::init(Region& r, I* i, int n) {
    RangeListIter::init(r);
    f = NULL;
    if ((n > 0) && i[0]()) {
      RangeList*  h;
      RangeList** c = &h;

      int min = i[0].min();
      while (i[0]()) {
        // Initialize with last interval
        int max = i[0].max();
        // Intersect with all other intervals
      restart:
        for (int j=n; j--;) {
          // Skip intervals that are too small
          while (i[j]() && (i[j].max() < min))
            ++i[j];
          if (!i[j]())
            goto done;
          if (i[j].min() > max) {
            min=i[j].min();
            max=i[j].max();
            goto restart;
          }
          // Now the intervals overlap
          if (min < i[j].min())
            min = i[j].min();
          if (max > i[j].max())
            max = i[j].max();
        }
        RangeList* t = range(min,max);
        *c = t; c = &t->next;
        // The next interval must be at least two elements away
        min = max + 2;
      }
    done:
      *c = NULL;
      set(h);
    }
  }

  template<class I>
  forceinline
  NaryInter::NaryInter(Region& r, I& i) {
    init(r, i);
  }
  template<class I, class J>
  forceinline
  NaryInter::NaryInter(Region& r, I& i, J& j) {
    init(r, i, j);
  }
  template<class I>
  forceinline
  NaryInter::NaryInter(Region& r, I* i, int n) {
    init(r, i, n);
  }

  template<class I>
  forceinline void
  NaryInter::operator &=(I& i) {
    RangeList* j = get();
    // The new rangelist
    RangeList* h;
    RangeList** c = &h;
    while (i() && (j != NULL)) {
      do {
        while (i() && (i.max() < j->min))
          ++i;
        if (!i()) goto done;
        while ((j != NULL) && (j->max < i.min())) {
          RangeList* t = j->next;
          j->next = f; f = j;
          j = t;
        }
        if (j == NULL) goto done;
      } while (i.max() < j->min);
      // Now the intervals overlap: consume the smaller interval
      RangeList* t = range(std::max(i.min(),j->min),
                           std::min(i.max(),j->max),f);
      *c = t; c = &t->next;
      if (i.max() < j->max) {
        ++i; 
      } else {
        RangeList* t = j->next;
        j->next = f; f = j;
        j = t;
      }
    }
  done:
    // Put remaining elements into freelist
    while (j != NULL) {
      RangeList* t = j->next;
      j->next = f; f = j;
      j = t;
    }
    *c = NULL;
    set(h);
  }

  forceinline NaryInter&
  NaryInter::operator =(const NaryInter& m) {
    f = NULL;
    return static_cast<NaryInter&>(RangeListIter::operator =(m));
  }

}}}

// STATISTICS: iter-any