This file is indexed.

/usr/include/trilinos/snl_fei_RaggedTable.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.

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
#ifndef _snl_fei_RaggedTable_hpp_
#define _snl_fei_RaggedTable_hpp_

/*--------------------------------------------------------------------*/
/*    Copyright 2005 Sandia Corporation.                              */
/*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
/*    non-exclusive license for use of this work by or on behalf      */
/*    of the U.S. Government.  Export of this program may require     */
/*    a license from the United States Government.                    */
/*--------------------------------------------------------------------*/

#include <fei_macros.hpp>

#include <snl_fei_SetTraits_specialize.hpp>
#include <snl_fei_MapTraits_specialize.hpp>

#include <fei_IndexTable.hpp>
#include <fei_Pool_alloc.hpp>

namespace snl_fei {

/** Data-structure that accumulates row-column indices into a ragged table,
  useful for building a matrix-graph and other concepts where keys are mapped
  to lists of values. This class can use various maps as the underlying
  data-holders. Useful because specialized maps and sets are defined in fei to
  take advantage of data that contains significant chunks of contiguous indices.
*/
template<typename MAP_TYPE, typename SET_TYPE>
class RaggedTable : public fei::IndexTable {
 public:
  /** Constructor */
  RaggedTable(int firstKey,
	      int lastKey);

  /** Copy constructor */
  RaggedTable(const RaggedTable<MAP_TYPE,SET_TYPE>& src);

  virtual ~RaggedTable();

  /** alias for MAP_TYPE */
  typedef MAP_TYPE map_type;

  /** alias for SET_TYPE */
  typedef SET_TYPE row_type;

  /** add entries to the diagonal of the table */
  void addDiagonals(int numIndices,
		    const int* indices);

  /** add a list of indices to a specified row */
  void addIndices(int row,
                  int numIndices,
                  const int* indices);

  /** add a list of indices to several specified rows */
  void addIndices(int numRows,
                  const int* rows,
                  int numIndices,
                  const int* indices);

  /** obtain internal map attribute */
  MAP_TYPE& getMap();

  /** obtain internal map attribute */
  const MAP_TYPE& getMap() const;

  /** obtain specified row from internal map attribute */
  SET_TYPE* getRow(int row);

  /** let 'iterator' be an alias for MAP_TYPE's iterator
  */
  typedef typename MAP_TYPE::iterator iterator;

  /** 'first' row of table */
  iterator begin();

  /** just past the 'last' row of the table */
  iterator end();

  /** Test for equality of two RaggedTable objects. */
  bool equal(const RaggedTable<MAP_TYPE,SET_TYPE>& rhs, bool quiet=true) const;

 private:
  MAP_TYPE map_;
  fei_Pool_alloc<SET_TYPE> poolAllocatorSet_;
  SET_TYPE dummy;
}; //class RaggedTable

template<typename MAP_TYPE, typename SET_TYPE>
inline RaggedTable<MAP_TYPE,SET_TYPE>::RaggedTable(int firstKey,
                                          int lastKey)
  : map_(),
  poolAllocatorSet_(),
  dummy()
{
}

template<typename MAP_TYPE, typename SET_TYPE>
inline RaggedTable<MAP_TYPE,SET_TYPE>::RaggedTable(const RaggedTable<MAP_TYPE,SET_TYPE>& src)
  : map_(src.map_),
    poolAllocatorSet_()
{
}

template<typename MAP_TYPE, typename SET_TYPE>
RaggedTable<MAP_TYPE,SET_TYPE>::~RaggedTable()
{
  iterator it = begin();
  iterator it_end = end();
  for(; it!=it_end; ++it) {
    poolAllocatorSet_.destroy( it->second );
    poolAllocatorSet_.deallocate( it->second, 1 );
  }
}

template<typename MAP_TYPE, typename SET_TYPE>
inline void RaggedTable<MAP_TYPE,SET_TYPE>::addIndices(int row,
                                              int numIndices,
                                              const int* indices)
{
  iterator m_end = map_.end();
  iterator m_iter = MapTraits<MAP_TYPE>::lower_bound(map_, row);

  SET_TYPE* mapped_indices = NULL;

  bool found_row = false;
  if (m_iter != m_end) {
    if ((*m_iter).first == row) {
      mapped_indices = (*m_iter).second;
      found_row = true;
    }
  }

  if (!found_row) {
    mapped_indices = poolAllocatorSet_.allocate(1);
    poolAllocatorSet_.construct(mapped_indices, dummy);
    typename MAP_TYPE::value_type val(row, mapped_indices);
    MapTraits<MAP_TYPE>::insert(map_, m_iter, val);
  }

  for(int i=0; i<numIndices; ++i) {
    SetTraits<SET_TYPE>::insert(mapped_indices, indices[i]);
  }
}

template<typename MAP_TYPE, typename SET_TYPE>
inline void RaggedTable<MAP_TYPE,SET_TYPE>::addIndices(int numRows,
                             const int* rows,
                             int numIndices,
                             const int* indices)
{
  iterator m_end = map_.end();
  iterator m_iter;
  SET_TYPE* mapped_indices = NULL;

  for(int i=0; i<numRows; ++i) {
    int row = rows[i];
    m_iter = MapTraits<MAP_TYPE>::lower_bound(map_, row);

    bool found_row = false;
    if (m_iter != m_end) {
      const typename MAP_TYPE::value_type& m_pair = *m_iter;
      if (m_pair.first == row) {
        mapped_indices = m_pair.second;
        found_row = true;
      }
    }

    if (!found_row) {
      mapped_indices = poolAllocatorSet_.allocate(1);
      poolAllocatorSet_.construct(mapped_indices, dummy);
      typename MAP_TYPE::value_type val(row, mapped_indices);
      MapTraits<MAP_TYPE>::insert(map_, m_iter, val);
    }

    for(int j=0; j<numIndices; ++j) {
      SetTraits<SET_TYPE>::insert(mapped_indices, indices[j]);
    }
  }
}

template<typename MAP_TYPE, typename SET_TYPE>
inline MAP_TYPE& RaggedTable<MAP_TYPE,SET_TYPE>::getMap()
{
  return(map_);
}

template<typename MAP_TYPE, typename SET_TYPE>
inline const MAP_TYPE& RaggedTable<MAP_TYPE,SET_TYPE>::getMap() const
{
  return(map_);
}

template<typename MAP_TYPE, typename SET_TYPE>
inline typename RaggedTable<MAP_TYPE,SET_TYPE>::row_type*
RaggedTable<MAP_TYPE,SET_TYPE>::getRow(int row)
{
  iterator m_end = map_.end();
  iterator m_iter = map_.find(row);
  return( m_end == m_iter ? NULL : (*m_iter).second );
}

template<typename MAP_TYPE, typename SET_TYPE>
inline typename RaggedTable<MAP_TYPE,SET_TYPE>::iterator
RaggedTable<MAP_TYPE,SET_TYPE>::begin()
{
  return(map_.begin());
}

template<typename MAP_TYPE, typename SET_TYPE>
inline typename RaggedTable<MAP_TYPE,SET_TYPE>::iterator
RaggedTable<MAP_TYPE,SET_TYPE>::end()
{
  return(map_.end());
}

template<typename MAP_TYPE, typename SET_TYPE>
inline void RaggedTable<MAP_TYPE,SET_TYPE>::addDiagonals(int numIndices,
                                                const int* indices)
{
  for(int i=0; i<numIndices; ++i) {
    int ind = indices[i];
    addIndices(ind, 1, &ind);
  }
}

template<typename MAP_TYPE, typename SET_TYPE>
bool RaggedTable<MAP_TYPE,SET_TYPE>::equal(const RaggedTable<MAP_TYPE,SET_TYPE>& rhs, bool quiet) const
{
  if (map_.size() != rhs.getMap().size()) {
    if (!quiet) {
      FEI_COUT << "RaggedTable::equal sizes don't match." << FEI_ENDL;
    }
    return(false);
  }

  typename map_type::const_iterator
   m_iter = map_.begin(),
   m_end  = map_.end();

  typename map_type::const_iterator
   rhs_iter = rhs.getMap().begin(),
   rhs_end  = rhs.getMap().end();

  for(; m_iter != m_end; ++m_iter, ++rhs_iter) {
    if (rhs_iter->first != m_iter->first) {
      if (!quiet) {
        FEI_COUT << "RaggedTable::equal keys don't match." << FEI_ENDL;
      }
      return(false);
    }

    if (*(rhs_iter->second) != *(m_iter->second)) {
      if (!quiet) {
        FEI_COUT << "RaggedTable::equal row-values don't match." << FEI_ENDL;
      }
      return(false);
    }
  }

  return(true);
}

}//namespace snl_fei

#endif