This file is indexed.

/usr/include/gecode/gist/spacenode.hh is in libgecode-dev 5.1.0-2build1.

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
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
 *  Main authors:
 *     Guido Tack <tack@gecode.org>
 *
 *  Copyright:
 *     Guido Tack, 2006
 *
 *  Last modified:
 *     $Date: 2016-04-19 17:19:45 +0200 (Tue, 19 Apr 2016) $ by $Author: schulte $
 *     $Revision: 14967 $
 *
 *  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.
 *
 */

#ifndef GECODE_GIST_SPACENODE_HH
#define GECODE_GIST_SPACENODE_HH

#include <gecode/gist/node.hh>
#include <gecode/kernel.hh>

namespace Gecode { namespace Gist {

  /** \brief Status of nodes in the search tree
   */
  enum NodeStatus {
    SOLVED,       ///< Node representing a solution
    FAILED,       ///< Node representing failure
    BRANCH,       ///< Node representing a branch
    UNDETERMINED, ///< Node that has not been explored yet
    STOP,         ///< Node representing stop point
    UNSTOP,       ///< Node representing ignored stop point
  };

  static const unsigned int FIRSTBIT = 24; //< First free bit in status word
  static const unsigned int STATUSMASK = 7<<20; //< Mask for accessing status
  static const unsigned int MAXDISTANCE = (1<<20)-1; //< Maximum representable distance
  static const unsigned int DISTANCEMASK = (1<<20)-1; //< Mask for accessing distance

  /// %Statistics about the search tree
  class Statistics : public StatusStatistics {
  public:
    /// Number of solutions
    int solutions;
    /// Number of failures
    int failures;
    /// Number of choice nodes
    int choices;
    /// Number of open, undetermined nodes
    int undetermined;
    /// Maximum depth of the tree
    int maxDepth;

    /// Constructor
    Statistics(void)
      : solutions(0), failures(0), choices(0), undetermined(1), maxDepth(0) {}
  };

  class SpaceNode;

  /// \brief Static reference to the currently best space
  class BestNode {
  public:
    /// The currently best node found, or NULL
    SpaceNode* s;
    /// Constructor
    BestNode(SpaceNode* s0);
  };

  /// \brief A node of a search tree of %Gecode spaces
  class SpaceNode : public Node {
  protected:
    /** \brief A copy used for recomputation, or NULL
     *
     * If the copy is marked, it is a working copy, i.e.,
     * it does not have to be kept for recomputation.
     */
    Space* copy;
  protected:
    const Choice* choice;

    /** \brief Status of the node
     *
     * If the node has a working copy, the first 20 bits encode the distance
     * to the closest copy. The next 5 bits encode the NodeStatus, and the
     * remaining bits are used by the VisualNode class for further flags.
     */
    unsigned int nstatus;

    /// Set distance from copy
    void setDistance(unsigned int d);

    /// Return distance from copy
    unsigned int getDistance(void) const;

    /// Set status flag
    void setFlag(int flag, bool value);

    /// Return status flag
    bool getFlag(int flag) const;

    /// Flags for SpaceNodes
    enum SpaceNodeFlags {
      HASOPENCHILDREN = FIRSTBIT,
      HASFAILEDCHILDREN,
      HASSOLVEDCHILDREN
    };
    /// Last bit used for SpaceNode flags
    static const int LASTBIT = HASSOLVEDCHILDREN;

  private:
    /// Set whether the node has children that are not fully explored
    void setHasOpenChildren(bool b);
    /// Set whether the subtree of this node is known to contain failure
    void setHasFailedChildren(bool b);
    /// Set whether the subtree of this node is known to contain solutions
    void setHasSolvedChildren(bool b);

    /// Recompute workingSpace from a copy higher up, return distance to copy
    int recompute(NodeAllocator& na,
                  BestNode* curBest, int c_d, int a_d);

    /// Book-keeping of open children
    void closeChild(const NodeAllocator& na,
                    bool hadFailures, bool hadSolutions);
  protected:
    /// Set status to \a s
    void setStatus(NodeStatus s);
    /// Acquire working space, either from parent or by recomputation
    void acquireSpace(NodeAllocator& na,
                      BestNode* curBest, int c_d, int a_d);
  public:
    /// Construct node with parent \a p
    SpaceNode(int p);
    /// Construct root node from Space \a root and branch-and-bound object \a better
    SpaceNode(Space* root);

    /// Return working space.  Receiver must delete the space.
    Space* getSpace(NodeAllocator& na,
                    BestNode* curBest, int c_d, int a_d);

    /// Return working space (if present).
    const Space* getWorkingSpace(void) const;

    /// Clear working space and copy (if present and this is not the root).
    void purge(const NodeAllocator& na);

    /// Free allocated memory
    void dispose(void);

    /// Return whether this node is the currently best solution
    bool isCurrentBest(BestNode* curBest);

    /** \brief Compute and return the number of children
      *
      * On a node whose status is already determined, this function
      * just returns the number of children.  On an undetermined node,
      * it first acquires a Space (possibly through recomputation), and
      * then asks for its status.  If the space is solved or failed, the
      * node's status will be set accordingly, and 0 will be returned.
      * Otherwise, the status is SS_BRANCH, and as many new children will
      * be created as the branch has alternatives, and the number returned.
      */
    int getNumberOfChildNodes(NodeAllocator& na,
                              BestNode* curBest,
                              Statistics& stats,
                              int c_d, int a_d);

    /// Return current status of the node
    NodeStatus getStatus(void) const;

    /// Return whether this node still has open children
    bool isOpen(void);
    /// Return whether the subtree of this node has any failed children
    bool hasFailedChildren(void);
    /// Return whether the subtree of this node has any solved children
    bool hasSolvedChildren(void);
    /// Return whether the subtree of this node has any open children
    bool hasOpenChildren(void);
    /// Return number of open children
    int getNoOfOpenChildren(const NodeAllocator& na);
    /// Set number of open children to \a n
    void setNoOfOpenChildren(int n);
    /// Return whether the node has a copy
    bool hasCopy(void);
    /// Return whether the node has a working space
    bool hasWorkingSpace(void);

    /// Return alternative number of this node
    int getAlternative(const NodeAllocator& na) const;
    /// Return choice of this node
    const Choice* getChoice(void);
  };

}}

#endif

// STATISTICS: gist-any