This file is indexed.

/usr/include/gecode/kernel/brancher-view-val.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
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
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
 *  Main authors:
 *     Christian Schulte <schulte@gecode.org>
 *
 *  Copyright:
 *     Christian Schulte, 2012
 *
 *  Last modified:
 *     $Date: 2015-03-20 15:37:34 +0100 (Fri, 20 Mar 2015) $ by $Author: schulte $
 *     $Revision: 14471 $
 *
 *  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 {

  /**
   * \defgroup TaskBranchViewVal Generic brancher based on view and value selection
   *
   * Implements view-based brancher for an array of views and value.
   * \ingroup TaskActor
   */

  //@{
  /// %Choice storing position and value
  template<class Val>
  class GECODE_VTABLE_EXPORT PosValChoice : public PosChoice {
  private:
    /// Value to assign to
    const Val _val;
  public:
    /// Initialize choice for brancher \a b, number of alternatives \a a, position \a p, and value \a n
    PosValChoice(const Brancher& b, unsigned int a, const Pos& p, const Val& n);
    /// Return value to branch with
    const Val& val(void) const;
    /// Report size occupied
    virtual size_t size(void) const;
    /// Archive into \a e
    virtual void archive(Archive& e) const;
  };


  /// View-value no-good literal
  template<class View, class Val, PropCond pc>
  class ViewValNGL : public NGL {
  protected:
    /// The stored view
    View x;
    /// The stored value
    Val n;
  public:
    /// Initialize for propagator \a p with view \a x and value \a n
    ViewValNGL(Space& home, View x, Val n);
    /// Constructor for cloning \a ngl
    ViewValNGL(Space& home, bool share, ViewValNGL& ngl);
    /// Create subscription for no-good literal
    virtual void subscribe(Space& home, Propagator& p);
    /// Cancel subscription for no-good literal
    virtual void cancel(Space& home, Propagator& p);
    /// Dispose
    virtual size_t dispose(Space& home);
  };

  /**
   * \brief Generic brancher by view and value selection
   *
   * Implements view-based branching for an array of views (of type
   * \a View) and value (of type \a Val).
   *
   */
  template<class View, int n, class Val, unsigned int a>
  class ViewValBrancher : public ViewBrancher<View,n> {
    typedef typename ViewBrancher<View,n>::BranchFilter BranchFilter;
  protected:
    using ViewBrancher<View,n>::vs;
    using ViewBrancher<View,n>::x;
    /// Value selection and commit object
    ValSelCommitBase<View,Val>* vsc;
    /// Function type for printing variable and value selection
    typedef void (*VarValPrint)(const Space& home, const BrancherHandle& bh,
                                unsigned int b,
                                typename View::VarType x, int i,
                                const Val& m,
                                std::ostream& o);
    /// Print function
    VarValPrint vvp;
    /// Constructor for cloning \a b
    ViewValBrancher(Space& home, bool share, ViewValBrancher& b);
    /// Constructor for creation
    ViewValBrancher(Home home, 
                    ViewArray<View>& x,
                    ViewSel<View>* vs[n], 
                    ValSelCommitBase<View,Val>* vsc,
                    BranchFilter bf,
                    VarValPrint vvp);
  public:
    /// Return choice
    virtual const Choice* choice(Space& home);
    /// Return choice
    virtual const Choice* choice(const Space& home, Archive& e);
    /// Perform commit for choice \a c and alternative \a b
    virtual ExecStatus commit(Space& home, const Choice& c, unsigned int b);
    /// Create no-good literal for choice \a c and alternative \a b
    virtual NGL* ngl(Space& home, const Choice& c, unsigned int b) const;
    /**
     * \brief Print branch for choice \a c and alternative \a b
     *
     * Prints an explanation of the alternative \a b of choice \a c
     * on the stream \a o.
     *
     */
    virtual void print(const Space& home, const Choice& c, unsigned int b,
                       std::ostream& o) const;
    /// Perform cloning
    virtual Actor* copy(Space& home, bool share);
    /// Delete brancher and return its size
    virtual size_t dispose(Space& home);
    /// Brancher post function
    static BrancherHandle post(Home home, 
                               ViewArray<View>& x,
                               ViewSel<View>* vs[n], 
                               ValSelCommitBase<View,Val>* vsc, 
                               BranchFilter bf,
                               VarValPrint vvp);
  };
  //@}

  /*
   * %Choice with position and value
   *
   */
  template<class Val>
  forceinline
  PosValChoice<Val>::PosValChoice(const Brancher& b, unsigned int a,
                                  const Pos& p, const Val& n)
    : PosChoice(b,a,p), _val(n) {}

  template<class Val>
  forceinline const Val&
  PosValChoice<Val>::val(void) const {
    return _val;
  }

  template<class Val>
  forceinline size_t
  PosValChoice<Val>::size(void) const {
    return sizeof(PosValChoice<Val>);
  }

  template<class Val>
  forceinline void
  PosValChoice<Val>::archive(Archive& e) const {
    PosChoice::archive(e);
    e << _val;
  }


  /*
   * View-value no-good literal
   *
   */
  template<class View, class Val, PropCond pc>
  forceinline
  ViewValNGL<View,Val,pc>::ViewValNGL(Space& home, View x0, Val n0)
    : NGL(home), x(x0), n(n0) {}

  template<class View, class Val, PropCond pc>
  forceinline
  ViewValNGL<View,Val,pc>::ViewValNGL(Space& home, bool share, ViewValNGL& ngl)
    : NGL(home,share,ngl), n(ngl.n) {
    x.update(home,share,ngl.x);
  }
  
  template<class View, class Val, PropCond pc>
  void
  ViewValNGL<View,Val,pc>::subscribe(Space& home, Propagator& p) {
    x.subscribe(home,p,pc);
  }
  
  template<class View, class Val, PropCond pc>
  void
  ViewValNGL<View,Val,pc>::cancel(Space& home, Propagator& p) {
    x.cancel(home,p,pc);
  }
  
  template<class View, class Val, PropCond pc>
  size_t
  ViewValNGL<View,Val,pc>::dispose(Space& home) {
    (void) NGL::dispose(home);
    return sizeof(*this);
  }
  


  /*
   * Generic brancher based on variable/value selection
   *
   */
  template<class View, int n, class Val, unsigned int a>
  forceinline
  ViewValBrancher<View,n,Val,a>::
  ViewValBrancher(Home home, 
                  ViewArray<View>& x,
                  ViewSel<View>* vs[n], 
                  ValSelCommitBase<View,Val>* vsc0,
                  BranchFilter bf,
                  VarValPrint vvp0)
    : ViewBrancher<View,n>(home,x,vs,bf), vsc(vsc0), vvp(vvp0) {
    if (vsc->notice())
      home.notice(*this,AP_DISPOSE,true);
  }

  template<class View, int n, class Val, unsigned int a>
  inline BrancherHandle
  ViewValBrancher<View,n,Val,a>::
  post(Home home, ViewArray<View>& x,
       ViewSel<View>* vs[n], ValSelCommitBase<View,Val>* vsc,
       BranchFilter bf,
       VarValPrint vvp) {
    return *new (home) ViewValBrancher<View,n,Val,a>(home,x,vs,vsc,bf,vvp);
  }

  template<class View, int n, class Val, unsigned int a>
  forceinline
  ViewValBrancher<View,n,Val,a>::
  ViewValBrancher(Space& home, bool shared, ViewValBrancher<View,n,Val,a>& b)
    : ViewBrancher<View,n>(home,shared,b), 
      vsc(b.vsc->copy(home,shared)), vvp(b.vvp) {}
  
  template<class View, int n, class Val, unsigned int a>
  Actor*
  ViewValBrancher<View,n,Val,a>::copy(Space& home, bool shared) {
    return new (home) ViewValBrancher<View,n,Val,a>(home,shared,*this);
  }

  template<class View, int n, class Val, unsigned int a>
  const Choice*
  ViewValBrancher<View,n,Val,a>::choice(Space& home) {
    Pos p = ViewBrancher<View,n>::pos(home);
    View v = ViewBrancher<View,n>::view(p);
    return new PosValChoice<Val>(*this,a,p,vsc->val(home,v,p.pos));
  }

  template<class View, int n, class Val, unsigned int a>
  const Choice*
  ViewValBrancher<View,n,Val,a>::choice(const Space& home, Archive& e) {
    (void) home;
    int p; e >> p;
    Val v; e >> v;
    return new PosValChoice<Val>(*this,a,p,v);
  }

  template<class View, int n, class Val, unsigned int a>
  ExecStatus
  ViewValBrancher<View,n,Val,a>
  ::commit(Space& home, const Choice& c, unsigned int b) {
    const PosValChoice<Val>& pvc
      = static_cast<const PosValChoice<Val>&>(c);
    return me_failed(vsc->commit(home,b,
                                 ViewBrancher<View,n>::view(pvc.pos()),
                                 pvc.pos().pos,
                                 pvc.val())) 
      ? ES_FAILED : ES_OK;
  }

  template<class View, int n, class Val, unsigned int a>
  NGL*
  ViewValBrancher<View,n,Val,a>
  ::ngl(Space& home, const Choice& c, unsigned int b) const {
    const PosValChoice<Val>& pvc
      = static_cast<const PosValChoice<Val>&>(c);
    return vsc->ngl(home,b,
                    ViewBrancher<View,n>::view(pvc.pos()),pvc.val());
  }

  template<class View, int n, class Val, unsigned int a>
  void
  ViewValBrancher<View,n,Val,a>
  ::print(const Space& home, const Choice& c, unsigned int b,
          std::ostream& o) const {
    const PosValChoice<Val>& pvc
      = static_cast<const PosValChoice<Val>&>(c);
    View xi = ViewBrancher<View,n>::view(pvc.pos());
    typename View::VarType y(ViewBrancher<View,n>::view(pvc.pos()).varimp());
    if (vvp != NULL)
      vvp(home,*this,b,y,pvc.pos().pos,pvc.val(),o);
    else
      vsc->print(home,b,xi,pvc.pos().pos,pvc.val(),o);
  }

  template<class View, int n, class Val, unsigned int a>
  forceinline size_t
  ViewValBrancher<View,n,Val,a>::dispose(Space& home) {
    if (vsc->notice())
      home.ignore(*this,AP_DISPOSE,true);
    vsc->dispose(home);
    (void) ViewBrancher<View,n>::dispose(home);
    return sizeof(ViewValBrancher<View,n,Val,a>);
  }

}

// STATISTICS: kernel-branch