This file is indexed.

/usr/include/gecode/gist/node.hpp is in libgecode-dev 4.4.0-3.

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
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
 *  Main authors:
 *     Guido Tack <tack@gecode.org>
 *
 *  Copyright:
 *     Guido Tack, 2006
 *
 *  Last modified:
 *     $Date: 2013-05-06 09:02:17 +0200 (Mon, 06 May 2013) $ by $Author: tack $
 *     $Revision: 13613 $
 *
 *  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.
 *
 */

namespace Gecode { namespace Gist {

  template<class T>
  void
  NodeAllocatorBase<T>::allocate(void) {
    cur_b++;
    cur_t = 0;
    if (cur_b==n) {
      int oldn = n;
      n = static_cast<int>(n*1.5+1.0);
      b = heap.realloc<Block*>(b,oldn,n);
    }
    b[cur_b] = static_cast<Block*>(heap.ralloc(sizeof(Block)));
  }

  template<class T>
  NodeAllocatorBase<T>::NodeAllocatorBase(bool bab)
    : _bab(bab) {
    b = heap.alloc<Block*>(10);
    n = 10;
    cur_b = -1;
    cur_t = NodeBlockSize-1;
  }

  template<class T>
  NodeAllocatorBase<T>::~NodeAllocatorBase(void) {
    for (int i=cur_b+1; i--;)
      heap.rfree(b[i]);
    heap.free<Block*>(b,n);
  }

  template<class T>
  forceinline int
  NodeAllocatorBase<T>::allocate(int p) {
    cur_t++;
    if (cur_t==NodeBlockSize)
      allocate();
    new (&b[cur_b]->b[cur_t]) T(p);
    b[cur_b]->best[cur_t] = -1;
    return cur_b*NodeBlockSize+cur_t;
  }

  template<class T>
  forceinline int
  NodeAllocatorBase<T>::allocate(Space* root) {
    cur_t++;
    if (cur_t==NodeBlockSize)
      allocate();
    new (&b[cur_b]->b[cur_t]) T(root);
    b[cur_b]->best[cur_t] = -1;
    return cur_b*NodeBlockSize+cur_t;
  }

  template<class T>
  forceinline T*
  NodeAllocatorBase<T>::operator [](int i) const {
    assert(i/NodeBlockSize < n);
    assert(i/NodeBlockSize < cur_b || i%NodeBlockSize <= cur_t);
    return &(b[i/NodeBlockSize]->b[i%NodeBlockSize]);
  }

  template<class T>
  forceinline T*
  NodeAllocatorBase<T>::best(int i) const {
    assert(i/NodeBlockSize < n);
    assert(i/NodeBlockSize < cur_b || i%NodeBlockSize <= cur_t);
    int bi = b[i/NodeBlockSize]->best[i%NodeBlockSize];
    return bi == -1 ? NULL : (*this)[bi];
  }

  template<class T>
  forceinline void
  NodeAllocatorBase<T>::setBest(int i, int best) {
    assert(i/NodeBlockSize < n);
    assert(i/NodeBlockSize < cur_b || i%NodeBlockSize <= cur_t);
    b[i/NodeBlockSize]->best[i%NodeBlockSize] = best;
  }
  
  template<class T>
  forceinline bool
  NodeAllocatorBase<T>::bab(void) const {
    return _bab;
  }

  template<class T>
  forceinline bool
  NodeAllocatorBase<T>::showLabels(void) const {
    return !labels.isEmpty();
  }

  template<class T>
  bool
  NodeAllocatorBase<T>::hasLabel(T* n) const {
    return labels.contains(n);
  }
  
  template<class T>
  void
  NodeAllocatorBase<T>::setLabel(T* n, const QString& l) {
    labels[n] = l;
  }

  template<class T>
  void
  NodeAllocatorBase<T>::clearLabel(T* n) {
    labels.remove(n);
  }

  template<class T>
  QString
  NodeAllocatorBase<T>::getLabel(T* n) const {
    return labels.value(n);
  }
  
  forceinline unsigned int
  Node::getTag(void) const {
    return static_cast<unsigned int>
      (reinterpret_cast<ptrdiff_t>(childrenOrFirstChild) & 3);
  }

  forceinline void
  Node::setTag(unsigned int tag) {
    assert(tag <= 3);
    assert(getTag() == UNDET);
    childrenOrFirstChild = reinterpret_cast<void*>
      ( (reinterpret_cast<ptrdiff_t>(childrenOrFirstChild) & ~(3)) | tag);
  }

  forceinline void*
  Node::getPtr(void) const {
    return reinterpret_cast<void*>
      (reinterpret_cast<ptrdiff_t>(childrenOrFirstChild) & ~(3));
  }

  forceinline int
  Node::getFirstChild(void) const {
    return static_cast<int>
      ((reinterpret_cast<ptrdiff_t>(childrenOrFirstChild) & ~(3)) >> 2);
  }

  forceinline
  Node::Node(int p, bool failed) : parent(p) {
    childrenOrFirstChild = NULL;
    noOfChildren = 0;
    setTag(failed ? LEAF : UNDET);
  }

  forceinline int
  Node::getParent(void) const {
    return parent;
  }

  forceinline VisualNode*
  Node::getParent(const NodeAllocator& na) const {
    return parent < 0 ? NULL : na[parent];
  }

  forceinline bool
  Node::isUndetermined(void) const { return getTag() == UNDET; }

  forceinline int
  Node::getChild(int n) const {
    assert(getTag() != UNDET && getTag() != LEAF);
    if (getTag() == TWO_CHILDREN) {
      assert(n != 1 || noOfChildren <= 0);
      return n == 0 ? getFirstChild() : -noOfChildren;
    }
    assert(n < noOfChildren);
    return static_cast<int*>(getPtr())[n];
  }

  forceinline VisualNode*
  Node::getChild(const NodeAllocator& na, int n) const {
    return na[getChild(n)];
  }

  forceinline bool
  Node::isRoot(void) const { return parent == -1; }

  forceinline unsigned int
  Node::getNumberOfChildren(void) const {
    switch (getTag()) {
    case UNDET: return 0;
    case LEAF:  return 0;
    case TWO_CHILDREN: return 1+(noOfChildren <= 0);
    default: return noOfChildren;
    }
  }

  inline int
  Node::getIndex(const NodeAllocator& na) const {
    if (parent==-1)
      return 0;
    Node* p = na[parent];
    for (int i=p->getNumberOfChildren(); i--;)
      if (p->getChild(na,i) == this)
        return p->getChild(i);
    GECODE_NEVER;
    return -1;
  }

}}

// STATISTICS: gist-any