This file is indexed.

/usr/include/casacore/casa/Containers/OrderedMap.h is in casacore-dev 2.2.0-2.

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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
//# OrderedMap.h: Templated associatve array (map) classes with ordered keys
//# Copyright (C) 1993,1994,1995,1996,1999,2000,2001
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library 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 Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//#        Internet email: aips2-request@nrao.edu.
//#        Postal address: AIPS++ Project Office
//#                        National Radio Astronomy Observatory
//#                        520 Edgemont Road
//#                        Charlottesville, VA 22903-2475 USA
//#
//# $Id$

#ifndef CASA_ORDEREDMAP_H
#define CASA_ORDEREDMAP_H

#include <casacore/casa/aips.h>
#include <casacore/casa/Exceptions/Error.h>
#include <casacore/casa/Containers/Block.h>
#include <casacore/casa/BasicSL/String.h>
#include <casacore/casa/Containers/Map.h>
#include <casacore/casa/Containers/OrderedPair.h>
#include <casacore/casa/Utilities/Register.h>
#include <casacore/casa/Utilities/Notice.h>

namespace casacore { //#Begin casa namespace

template<class t, class v> class OrderedMap;
template<class t, class v> class OrderedMapRep;
template<class t, class v> class OrderedMapIterRep;

// <category lib=aips sect="Notice">
// <summary>Message used for OrderedMap notification</summary>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
// </reviewed>
//
// This is the message that flows between the OrderedMap
// and the OrderedMap iterators. It allows OrderedMap
// iterators to react to changes as they occur to the 
// OrderedMap.
//
template<class t,class v> class OrderedMapNotice : public Notice {
friend class OrderedMapRep<t,v>;
friend class OrderedMapIterRep<t,v>;
private:
  enum NoticeType {CLEAR,DEFINE,REMOVE,DELETE} changeType;
  uInt modPos;

  //*display 1
  //
  // This is used to construct a list notice. The parameters are:
  // <list>
  //    <item> the change modification position
  //    <item> the change type
  // </list>
  //
  OrderedMapNotice(uInt pos, NoticeType typ) : changeType(typ), modPos(pos) {}

public:
  //
  // This function returns the "Notice" type, retrieved
  // from the "type registry".
  //
  uInt type() const {return Register(this);}

  //
  // This operator can be used to compare two
  // "OrderedMapNotice"s.
  //
  int operator==(const Notice &op) const {
    if (type() != op.type()) {
      return 0;
    } else {
      const OrderedMapNotice<t,v> &opD = (const OrderedMapNotice<t,v> &) op;
      return (modPos == opD.modPos && changeType == opD.changeType);
    }
  }
};

// <summary> Representation class for an Ordered Map</summary>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
// </reviewed>

template<class key, class value> class OrderedMapRep : public NoticeSource, public MapRep<key,value> {
friend class OrderedMap<key,value>;
public:
  //
  //  Creates a map with the specified default value, "value", and the
  //  internal block size.
  //
  OrderedMapRep (const value&, uInt size);

  //
  //  Creates a map with the specified default value, "value".
  //
  OrderedMapRep (const value&);

  //
  // These functions check to see if a mapping is defined between
  // the specified key and some value. If one is, a pointer to
  // the value is returned, otherwise 0 is returned.
  //
  //+grp
  value *isDefined(const key&);
  const value *isDefined(const key&) const;
  //-grp

  //
  // Returns the number of user defined mappings
  //
  uInt ndefined() const;

  //
  //  Defines a mapping (ie. create a key value mapping)
  //
  value &define (const key&, const value&);

  //
  //  Undefines a mapping (ie. remove a key value mapping).
  //
  void remove (const key&);

  //
  //  Clear the entire map (ie. remove all mappings).
  //
  void clear ();

  MapIterRep<key,value> *getRep(Map<key,value> *) const;

  MapRep<key,value> *Clone() const;

  //
  //  Get the number of mappings.
  //
  uInt nused() const { return nrused; }
  uInt ntot() const { return nrtot; }

  //
  //  Get or set the Block allocation increment.
  //
  //+grp
  uInt incr() const { return nrincr; }
  uInt incr(uInt nri) { return (nrincr = nri); }
  //-grp

  //
  //  Removes a map.
  //
  ~OrderedMapRep ();

  enum {OrderedMapRepVersion = 1};

protected:
    //  The blocks to hold the keys and values
    //  and the total, used and increment size of these blocks.
    PtrBlock<OrderedPair<key,value>*> kvblk;
    uInt nrtot;
    uInt nrused;
    uInt nrincr;

    //  The index of the last key used.
    uInt lastRef;

    //  Binary search for the key.
    Int findKey (const key&, Bool&) const;
};

//
// <category lib=aips sect="Containers">
// <summary>Map with keys ordered</summary>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
// </reviewed>
//
// OrderedMap<key,value> is a template class derived from Map.
// It is similar to ListMap, but the keys are kept in order and
// they have to be unique.
//
// It uses a Block to store an array of pointers to the keys and
// the associated values.
// The keys and values themselves are stored on the heap.
// The keys are kept in order to allow a binary search through
// the keys for rapid access.
//
// This is one (simple) implementation of an ordered map.
// It is not suitable for large arrays of keys, since the overhead
// of keeping the keys in order would get too big.
// For large arrays a red-black tree implementation would be better.
//
// Exceptions are raised when new[] is failing, when the next()
// getKey() or getValue() function is failing or when a duplicate key
// is defined.
//
// The AipsIO >> and << operators are defined in <aips/OrdMapIO.h>.
//
template<class key, class value> class OrderedMap : public Map<key,value> {
friend class OrderedMapIterRep<key,value>;
protected:

  void throwgetKey(uInt) const;
  void throwgetValue(uInt) const;

  value &getVal(uInt inx) {
    if (!this->Rep || inx >= nused())
      throwgetValue(inx);
    return (((OrderedMapRep<key,value> *)(this->Rep))->kvblk[inx]->y());
  }

  const value &getVal(uInt inx) const {
    if (!this->Rep || inx >= nused())
      throwgetValue(inx);
    return (((OrderedMapRep<key,value> *)(this->Rep))->kvblk[inx]->y());
  }

  key &getKey (uInt inx) {
    if (!this->Rep || inx >= nused())
	throwgetKey(inx);
    return (((OrderedMapRep<key,value> *)(this->Rep))->kvblk[inx]->x());
  }

  const key &getKey (uInt inx) const {
    if (!this->Rep || inx >= nused())
	throwgetKey(inx);
    return (((OrderedMapRep<key,value> *)(this->Rep))->kvblk[inx]->x());
  }

public:
  //
  //  Creates a map with the specified default value, "value", and the
  //  internal block size.
  //
  OrderedMap (const value& dflt, uInt size) : Map<key,value>(new OrderedMapRep<key,value>(dflt,size)) { }

  //
  //  Creates a map with the specified default value, "value".
  //
  explicit OrderedMap (const value& dflt) : Map<key,value>(new OrderedMapRep<key,value>(dflt)) { }

  //
  //  Creates a map from another one; use copy semantics.
  //
  OrderedMap (const OrderedMap<key,value>& other) : Map<key,value>(other.Rep->Clone()) { }

  //
  // Does nothing, the destruction is taken care of in the base class, i.e. the
  // letter contains the guts.
  //
  ~OrderedMap();

  //
  //  Assigns this OrderedMap to another with copy semantics.
  //
  OrderedMap<key,value>& operator= (const OrderedMap<key,value>& other) {
    this->SetRep(other.Rep->Clone());
    return *this;
  }

  //
  //  Get the number of mappings.
  //
  uInt nused() const { return ((OrderedMapRep<key,value> *)(this->Rep))->nused(); }
  uInt ntot() const { return ((OrderedMapRep<key,value> *)(this->Rep))->ntot(); }

  //
  //  Get or set the Block allocation increment.
  //
  //+grp
  uInt incr() const { return ((OrderedMapRep<key,value> *)(this->Rep))->incr(); }
  uInt incr(uInt nri) { return ((OrderedMapRep<key,value> *)(this->Rep))->incr(nri);}
  //-grp

  enum {OrderedMapVersion = 1};
};


//
// <category lib=aips sect="Containers">
// <summary>OrderedMap iterator "letter"</summary>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
// </reviewed>
//
// This is the "letter" which when paired (Const)MapIter "envelope"
// allows traversal of "OrderedMap"s.
//
template<class key, class value> class OrderedMapIterRep : virtual public MapIterRep<key,value>, public NoticeTarget {
protected:

  //*display 4
  //
  // Throw exceptions on behalf of inline functions.
  //
  //+grp
  void thrownext() const;
  void throwInvalidIter() const;
  //-grp

  OrderedMap<key,value> *container;

  uInt CurIndex;

public:

  //
  // Checks to see if the iterator is in a valid state.
  //
  Bool isValid() const;

  //
  // Checks to see if the iterator is at one of the
  // map extremes, "atEnd()" or "atStart()".
  //
  //+grp
  Bool atEnd() const;
  Bool atStart() const;
  //-grp

  //
  // Move the iterator to the beginning of the Map.
  //
  void toStart();

  //
  // Advance the iterator to the next key.
  //
  //+grp
  void operator++();
  void operator++(int);
  //-grp

  //
  // Retrieve the key at the current iterator position.
  //
  //+grp
  const key &getKey () const;
  const key &getKey (uInt inx) const {
    if (!container || !isValid())
      throwInvalidIter();
    return ((*container).getKey(inx));
  }
  //-grp

  //
  // Retrieve the value at the given index in the internal block
  // which stores the representation of the OrderedMap.
  //
  // <note> This should typically not be used.</note>
  //
  //+grp
  value &getVal(uInt inx) {
    if (!container || !isValid())
      throwInvalidIter();
    return ((*container).getVal(inx));
  }
  //-grp

  //
  // Retrieve the value at the current iterator position.
  //
  //+grp
  const value &getVal() const;
  const value &getVal(uInt inx) const {
    if (!container || !isValid())
      throwInvalidIter();
    return ((*container).getVal(inx));
  }

  value &getVal() {return  getVal(CurIndex);}
  //-grp


  MapIterRep<key,value> *Clone() {
    OrderedMapIterRep<key,value> *ret = new OrderedMapIterRep<key,value>(container);
    return ret;
  }

  //*display 4
  //
  // This function is the hook through which OrderedMap
  // iterators are notified of changes to the OrderedMap
  // which they observe, i.e. changes which may cause
  // require iterator update.
  //
  void notify(const Notice &);

  //
  // These constructors allow a ListMapIter to be constructed from a
  // ListMap.
  //
  //+grp
  OrderedMapIterRep(OrderedMap<key,value> *st)
    : MapIterRep<key,value>(st),
      NoticeTarget((NoticeSource *)((OrderedMapRep<key,value> *) st->Rep)),
      container(st),
      CurIndex(0)
    {}

  OrderedMapIterRep(OrderedMap<key,value> &st)
    : MapIterRep<key,value>(st),
      NoticeTarget((NoticeSource *)((OrderedMapRep<key,value> *) st.Rep)),
      container(&st),
      CurIndex(0)
    {}
  //-grp

  enum {OrderedMapIterRepVersion = 1};

};

} //#End casa namespace
#ifndef CASACORE_NO_AUTO_TEMPLATES
#include <casacore/casa/Containers/OrderedMap.tcc>
#endif //# CASACORE_NO_AUTO_TEMPLATES
#endif