This file is indexed.

/usr/include/hmat/tree.hpp is in libhmat-oss-dev 1.0.4-2ubuntu1.

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
/*
  HMat-OSS (HMatrix library, open source software)

  Copyright (C) 2014-2015 Airbus Group SAS

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

  http://github.com/jeromerobert/hmat-oss
*/

/*! \file
  \ingroup HMatrix
  \brief Templated Tree class used by ClusterTree and HMatrix.
*/
#ifndef _TREE_HPP
#define _TREE_HPP
#include <vector>
#include <list>
#include <cstddef> // size_t

/*! \brief Templated tree class.

  This class represents a tree of arity N, holding an instance of NodeData in
  its nodes.
 */
template<int N> class Tree {
public:
  /// depth of the current node in the tree
  int depth;

protected:
  /// NULL for a leaf, pointeur on an array of N sons otherwie.
  Tree** children;
public:
  /// Pointer to the father, NULL if this node is the root
  Tree* father;

public:
  Tree(Tree* _father, int _depth = 0)
    : depth(_depth), children(NULL), father(_father) {}
  virtual ~Tree() {
    if (!children) {
      return;
    }
    for (int i = 0; i < N; i++) {
      if (children[i]) {
        delete children[i];
        children[i] = NULL;
      }
    }
    delete[] children;
  }

  /*! \brief Insert a child in the children array.

    If a child is already present, it is removed but not deleted.

    \param index index in the children array
    \param child pointeur to the child
   */
  void insertChild(int index, Tree *child) {
    if (!children) {
      children = new Tree*[N];
      for (int i = 0; i < N; i++) {
        children[i] = NULL;
      }
    }
    child->father = this;
    children[index] = child;
    child->depth = depth + 1;
  }

  /*! \brief Remove a children, an delete it if necessary.
   */
  void removeChild(int index) {
    delete children[index];
    children[index] = NULL;
  }

  /*! \brief Return the number of nodes in the tree.
   */
  int nodesCount() const {
    int result = 1;
    if (!isLeaf()) {
      for (int i = 0; i < N; i++) {
        if (getChild(i)) {
          result += getChild(i)->nodesCount();
        }
      }
    }
    return result;
  }

  /*! \brief Return the child of index, or NULL.

    \warning Will segfault if used on a leaf.
   */
  inline Tree *getChild(int index) const {
    return children[index];
  }

  /*! \brief Return true if the node is a leaf.
   */
  inline bool isLeaf() const {
    return !children;
  }

  /*! \brief Return a list of nodes.
   */
  virtual std::list<const Tree<N>*> listNodes() const {
    std::list<const Tree<N>*> result;
    result.push_back(this);
    if (!isLeaf()) {
      for (int i = 0; i < N; i++) {
        Tree<N>* child = getChild(i);
        if (child) {
          std::list<const Tree<N>*> childNodes = child->listNodes();
          result.splice(result.end(), childNodes, childNodes.begin(),
                        childNodes.end());
        }
      }
    }
    return result;
  }

 /*! \brief Return a list of leaves.
   */
  void listAllLeaves(std::vector<Tree<N>*>& leaves) const {
    if (!isLeaf()) {
      for (int i = 0; i < N; i++) {
        Tree<N>* child = getChild(i);
        if (child) {
          child->listAllLeaves(leaves);
        }
      }
    } else {
      leaves.push_back(const_cast<Tree<N>*>(this));
    }
  }
};
#endif  // _TREE_HPP