This file is indexed.

/usr/include/casacore/casa/Containers/SimOrdMap.tcc 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
//# SimOrdMap.cc: Simple map with ordered keys
//# Copyright (C) 1993,1994,1995
//# 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_SIMORDMAP_TCC
#define CASA_SIMORDMAP_TCC

#include <casacore/casa/Containers/SimOrdMap.h>
#include <casacore/casa/Exceptions/Error.h>

namespace casacore { //# NAMESPACE CASACORE - BEGIN

template<class K, class V>
SimpleOrderedMap<K,V>::SimpleOrderedMap (const V& dflt, uInt incr)
: kvblk(incr),
  nrused(0),
  nrincr(incr),
  DefaultVal(dflt)
{
    if (nrincr < 16) {
	nrincr = 16;
    }
}

template<class K, class V>
SimpleOrderedMap<K,V>::SimpleOrderedMap (const V& dflt)
: kvblk (16),
  nrused(0),
  nrincr(16),
  DefaultVal(dflt)
{}

template<class K, class V>
SimpleOrderedMap<K,V>::SimpleOrderedMap
                           (const SimpleOrderedMap<K,V>& that)
: kvblk (that.kvblk.nelements()),
  nrused(that.nrused),
  nrincr(that.nrincr),
  DefaultVal(that.DefaultVal)
{
    copyBlock (that);
}

template<class K, class V>
SimpleOrderedMap<K,V>::~SimpleOrderedMap ()
{
    clear();
}

template<class K, class V>
void SimpleOrderedMap<K,V>::clear ()
{
    for (uInt i=0; i<nrused; i++) {
        delete KVBLKpair(i);
    }
    nrused = 0;
}

template<class K, class V>
void SimpleOrderedMap<K,V>::copyBlock (const SimpleOrderedMap<K,V>& that)
{
    for (uInt i=0; i<nrused; i++) {
        kvblk[i] = new OrderedPair<K,V> (that.getKey(i), that.getVal(i));
    }
}


template<class K, class V>
SimpleOrderedMap<K,V>& SimpleOrderedMap<K,V>::operator=
                                   (const SimpleOrderedMap<K,V>& that)
{
    if (&that == this) {
        return *this;
    }
    clear();
    if (kvblk.nelements() < that.nrused) {
        kvblk.resize (that.nrused, False, False);
    }
    nrused = that.nrused;
    copyBlock (that);
    return *this;
}


template<class K, class V>
uInt SimpleOrderedMap<K,V>::findKey (const K& k, Bool& defined) const
{
    //  Do a binary search for the key. Return the index of the first
    //  key which is >= the key searched for.
    //  In case of insertion this gives the index where to insert.
    Int st = 0;
    Int ent= nrused-1;
    Int i  = 0;
    defined = False;
    while (st<=ent) {
        i = (st+ent)/2;
        if (k < KVBLKpair(i)->x()) {
            ent = i-1;
        }else{
	    if (k > KVBLKpair(i)->x()) {
                i++;
                st = i;
            }else{
                defined = True;
                ent     = -1;
            }
        }
    }
    return (i);
}


template<class K, class V>
V *SimpleOrderedMap<K,V>::isDefined (const K& k)
{
    //  Locate the key. Error if the key already exists.
    Bool defined;
    uInt inx = findKey (k, defined);
    if (defined) {
        return(&(KVBLKpair(inx)->y()));
    } else {
        return 0;
    }
}

template<class K, class V>
V &SimpleOrderedMap<K,V>::operator()(const K &ky)
{
    V *vptr = isDefined(ky);
    return vptr  ?  *vptr : define(ky,DefaultVal);
}

template<class K, class V>
const V &SimpleOrderedMap<K,V>::operator()(const K &ky) const
{
    const V *vptr = isDefined(ky);
    if (! vptr)
	throw(indexError<K>(ky, "SimpleOrderedMap-operator()"));
    return *vptr;
}

template<class K, class V>
V &SimpleOrderedMap<K,V>::define (const K& k, const V& v)
{
    //  Locate the key. Error if the key already exists.
    Bool defined;
    uInt inx = findKey (k, defined);
    if (defined) {
        delete KVBLKpair(inx);
    }else{
        //  Extend the blocks if full.
        if (nrused==kvblk.nelements()) {
	    kvblk.resize (kvblk.nelements()+nrincr);
        }
        //  Shift the keys and values to the right and insert the new ones.
        for (uInt i=nrused; i>inx; i--) {
	    kvblk[i] = kvblk[i-1];
        }
        nrused++;
    }
    kvblk[inx] = new OrderedPair<K,V> (k,v);
    return(KVBLKpair(inx)->y());
}

template<class K, class V>
void SimpleOrderedMap<K,V>::remove (const K& k)
{
    //  Locate the key. Error if the key does not exist.
    Bool defined;
    uInt inx = findKey (k, defined);
    if (!defined) {
	throw(indexError<K>(k, "SimpleOrderedMap-remove"));
    }else{
        //  Remove the key and value and shift the others to the left.
        delete KVBLKpair(inx);
        nrused--;
        for (uInt i=inx; i<nrused; i++) {
            kvblk[i] = kvblk[i+1];
        }
    }
}

template<class K, class V>
void SimpleOrderedMap<K,V>::rename (const K& keynew, const K& keyold)
{
    //  Locate the old key. Error if the key does not exist.
    Bool defined;
    uInt inxold = findKey (keyold, defined);
    if (!defined) {
	throw(indexError<K>(keyold, "SimpleOrderedMap-rename"));
    }
    //  Locate the new key.
    //  Exit if the keys are equal.
    //  Remove if the key already exists (adjust index if needed).
    uInt inxnew = findKey (keynew, defined);
    if (defined) {
	if (inxold == inxnew)
	    return;
	remove (keynew);
	if (inxold >= inxnew)
	    inxold--;
    }
    // Save pointer to key/value.
    // If the new key is right of the old key, make index one less
    // (since the old key will be removed).
    OrderedPair<K,V>* p = KVBLKpair(inxold);
    if (inxnew > inxold)
	inxnew--;
    // Shift key/value pointers to the right or left (as far as needed).
    uInt i;
    for (i=inxold; i>inxnew; i--)
	kvblk[i] = kvblk[i-1];
    for (i=inxold; i<inxnew; i++)
	kvblk[i] = kvblk[i+1];
    // Now insert the new key value and the pointer.
    p->x() = keynew;
    kvblk[inxnew] = p;
}


//# Check if the invariants still hold.
template<class K, class V>
Bool SimpleOrderedMap<K,V>::ok() const
{
    if (ntot() < nrused)
	return False;
    for (uInt i=1; i<nrused; i++) {
	if (KVBLKpair(i)->x() <= KVBLKpair(i-1)->x())
	    return False;
    }
    return True;
}

} //# NAMESPACE CASACORE - END


#endif