This file is indexed.

/usr/include/dcmtk/ofstd/ofoset.h is in libdcmtk2-dev 3.6.0-9.

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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
/*
 *
 *  Copyright (C) 2002-2010, OFFIS e.V.
 *  All rights reserved.  See COPYRIGHT file for details.
 *
 *  This software and supporting documentation were developed by
 *
 *    OFFIS e.V.
 *    R&D Division Health
 *    Escherweg 2
 *    D-26121 Oldenburg, Germany
 *
 *
 *  Module:  ofstd
 *
 *  Author:  Thomas Wilkens
 *
 *  Purpose: Template class for administrating an ordered set of elements
 *           of an arbitrary type.
 *
 *  Last Update:      $Author: joergr $
 *  Update Date:      $Date: 2010-10-14 13:15:50 $
 *  CVS/RCS Revision: $Revision: 1.11 $
 *  Status:           $State: Exp $
 *
 *  CVS/RCS Log at end of file
 *
 */

#ifndef OFOrderedSet_h
#define OFOrderedSet_h

#include "dcmtk/config/osconfig.h"
#include "dcmtk/ofstd/oftypes.h"
#include "dcmtk/ofstd/ofset.h"

/** This template class provides a data structure and operations for administrating an
 *  ordered set of elements of an arbitrary type. Note the following properties of this
 *  class:
 *   - an element which is inserted into the set will be copied
 *   - the datatype of the set's elements has to support operator== so that it is possible
 *     to find a certain element
 *   - it is allowed to insert identical elements into the set
 *   - if a user requires to remove a certain element and if there are several elements
 *     which are identical to this element, only one element will be removed from the set
 *   - when removing an element, the indeces of the elements behind the removed element will
 *     be reduced by one
 *   - the set will be ordered according to the point in time at which an element is inserted
 *     into the set; a new element will always be inserted at the end of the set
 */
template <class T> class OFOrderedSet : public OFSet<T>
{
  protected:

  public:
      /** Default constructor.
       */
    OFOrderedSet()
        : OFSet<T>()
      {
      }


      /** Copy constructor.
       *  @param src Source object of which this will be a copy.
       */
    OFOrderedSet( const OFOrderedSet<T> &src )
        : OFSet<T>( src )
      {
      }


      /** Destructor.
       */
    virtual ~OFOrderedSet()
      {
      }


      /** operator=.
       *  @param src Source object whose values will be assigned to this.
       *  @return Reference to this.
       */
    const OFOrderedSet<T> &operator=( const OFOrderedSet<T> &src )
      {
        return( assign( src ) );
      }


      /** This function is a workaround for avoiding a compiler warning on
       *  Solaris 2.5.1 using compiler SC 2.0.1.
       */
    const OFOrderedSet<T> &assign( const OFOrderedSet<T> &src )
      {
        if( this != &src )
          this->operator=( src );

        return( *this );
      }


      /** Determines if two sets are identical. Note that for ordered sets
       *  not only their elements have to be identical, but also the order
       *  of their elements has to be identical.
       *  @param other Set which shall be compared with this.
       *  @return OFTrue if sets are identical, OFFalse otherwise.
       */
    virtual OFBool operator==( const OFOrderedSet<T> &other ) const
      {
        // check if both sets contain the same
        // amount of items; if not, return OFFalse
        if( this->num != other.num )
          return( OFFalse );

        // initialize result with OFTrue
        OFBool result = OFTrue;

        // as long as result is OFTrue go through all items in this
        for( unsigned int i=0 ; i < this->num && result == OFTrue ; i++ )
        {
          // in case the current element does not equal the current
          // element in other, result shall be set to OFFalse
          if( *this->items[i] != *other.items[i] )
            result = OFFalse;
        }

        // return result
        return( result );
      }


      /** Determines if two sets are not identical.
       *  @param other Set which shall be compared with this.
       *  @return OFTrue if sets are not identical, OFFalse otherwise.
       */
    virtual OFBool operator!=( const OFOrderedSet<T> &other ) const
      {
        return( !( *this == other ) );
      }


      /** Inserts a new item into the set.
       *  @param item Item which shall be inserted into the set.
       */
    virtual void Insert( const T &item )
      {
        // if size equals num, we need more space
        if( this->size == this->num )
          Resize( this->size * 2 );

        // copy item
        T *newItem = new T( item );

        // insert copy into array
        this->items[this->num] = newItem;

        // increase counter
        this->num++;
      }


      /** Inserts all items of another set into this set.
       *  @param other set whose items shall be inserted into the set.
       */
    virtual void Insert( const OFOrderedSet<T> &other )
      {
        // go through all items in other and insert each item into this
        for( unsigned int i=0 ; i<other.num ; i++ )
          Insert( *other.items[i] );
      }


      /** Inserts a new item at a certain position into the set.
       *  @param item Item which shall be inserted into the set.
       *  @param idx  Index of the position at which the item shall be inserted.
       *              The first position has index 0. Note that in case index
       *              is greater than the index of the last item, the new item will
       *              be inserted right behind the last item of the set.
       */
    virtual void InsertAt( const T &item, unsigned int idx )
      {
        unsigned int i;

        // in case index is greater than the index of the last item,
        // insert the new item right behind the last item of the set
        if( idx > this->num - 1 )
          Insert( item );
        else
        {
          // if size equals num, we need more space
          if( this->size == this->num )
            Resize( this->size * 2 );

          // copy item
          T *newItem = new T( item );

          // create a new temporary array and assign all pointers correspondingly
          T **tmp = new T*[this->size];

          for( i=0 ; i<idx ; i++ )
            tmp[i] = this->items[i];

          tmp[idx] = newItem;

          for( i=idx ; i < this->size - 1 ; i++ )
          {
            if( i < this->num )
              tmp[i+1] = this->items[i];
            else
              tmp[i+1] = NULL;
          }

          // delete old array
          delete this->items;

          // assign new array to member variable
          this->items = tmp;

          // increase counter
          this->num++;
        }
      }


      /** Removes one item from the set.
       *  @param item Item which shall be inserted into the set.
       */
    virtual void Remove( const T &item )
      {
        // so far, nothing was deleted
        OFBool itemDeleted = OFFalse;

        // go through all items
        for( unsigned int i=0 ; i < this->num && !itemDeleted ; i++ )
        {
          // if current item is the one which shall be deleted
          if( *this->items[i] == item )
          {
            // delete item
            delete this->items[i];

            // and - so that there are no holes in the array - move all elements
            // behind the current element up one array field; only do so in case
            // we did _not_ delete the last item
            if( i != this->num - 1 )
            {
              unsigned int j;
              for( j=i+1 ; j < this->num ; j++ )
              {
                this->items[j-1] = this->items[j];
              }

              this->items[j-1] = NULL;
            }
            else
              this->items[i] = NULL;

            // reduce counter
            this->num--;

            // remember that an item was deleted (so that always only one item will be deleted)
            itemDeleted = OFTrue;
          }
        }
      }


      /** Removes one item from the set.
       *  @param idx Index of the item which shall be removed from the set.
       */
    virtual void RemoveByIndex( unsigned int idx )
      {
        // do something only if the given index is not out of range
        if( idx < this->num )
        {
          // delete item with given index
          delete this->items[idx];

          // and - so that there are no holes in the array - move all elements
          // behind the current element up one array field; only do so in case
          // we did _not_ delete the last item
          if( idx != this->num - 1 )
          {
            unsigned int j;
            for( j=idx+1 ; j < this->num ; j++ )
            {
              this->items[j-1] = this->items[j];
            }

            this->items[j-1] = NULL;
          }
          else
            this->items[idx] = NULL;

          // reduce counter
          this->num--;
        }
      }


      /** Tries to find a given object in the set. In case the specified object could
       *  be found, a pointer to the corresponding element within the set is returned;
       *  in case the specified object could not be found, NULL will be returned.
       *  @param item Search pattern.
       *  @return Pointer to the corresponding element within the set or NULL.
       */
    virtual T *Find( const T &item ) const
      {
        unsigned int i;
        OFBool itemFound = OFFalse;

        for( i=0 ; i < this->num && !itemFound ; i++ )
        {
          if( *this->items[i] == item )
            itemFound = OFTrue;
        }

        if( itemFound )
          return( this->items[i-1] );
        else
          return( NULL );
      }


      /** Determines if a certain item is contained in the set.
       *  @param item - Item which shall be looked for.
       *  @return OFTrue, if item is contained in the set, OFFalse otherwise.
       */
    virtual OFBool Contains( const T &item ) const
      {
        OFBool itemFound = OFFalse;

        for( unsigned int i=0 ; i < this->num && !itemFound ; i++ )
        {
          if( *this->items[i] == item )
            itemFound = OFTrue;
        }

        return( itemFound );
      }


      /** Determines if this is an actual superset of other, i.e.
       *  if this completely contains other and furthermore has
       *  additional elements.
       *  @param other - Set which shall be compared with this.
       *  @return OFTrue if this is a superset of other, OFFalse otherwise.
       */
    virtual OFBool IsSupersetOf( const OFOrderedSet<T> &other ) const
      {
        // if this contains less or the same amount of items than other, return OFFalse
        if( this->num <= other.num )
          return( OFFalse );

        // initialize result with OFTrue
        OFBool result = OFTrue;

        // make a copy of this
        OFOrderedSet<T> s = *this;

        // as long as result is OFTrue go through all items in other
        for( unsigned int i=0 ; i<other.num && result == OFTrue ; i++ )
        {
          // in case s contains the current item of other
          if( s.Contains( *other.items[i] ) )
          {
            // remove this item from s so that it will not be
            // considered again in a later call to s.Contains()
            s.Remove( *other.items[i] );
          }
          // in case s does not contain the current item of other the result is OFFalse
          else
            result = OFFalse;
        }

        // return result
        return( result );
      }


      /** Determines if this is an actual subset of other, i.e.
       *  if this is completely contained in other and other
       *  furthermore has additional elements.
       *  @param other - Set which shall be compared with this.
       *  @return OFTrue if this is a subset of other, OFFalse otherwise.
       */
    virtual OFBool IsSubsetOf( const OFOrderedSet<T> &other ) const
      {
        return( other.IsSupersetOf( *this ) );
      }


      /** Determines the union of the two sets this and other, i.e. the set
       *  containing all items which can be found either in this or in other,
       *  and returns the resulting new set.
       *  @param other Second parameter for union.
       *  @return New set.
       */
    OFOrderedSet<T> Union( const OFOrderedSet<T> &other ) const
      {
        // initialize result set
        OFOrderedSet<T> resultSet = *this;

        // insert other set into result set
        resultSet.Insert( other );

        // return result set
        return( resultSet );
      }


      /** Determines the intersection of the two sets this and other, i.e. the set
       *  containing all items which can be found in both this and other, and
       *  returns the resulting new set.
       *  @param other Second parameter for intersection.
       *  @return New set.
       */
    OFOrderedSet<T> Intersection( const OFOrderedSet<T> &other ) const
      {
        // initialize result set
        OFOrderedSet<T> resultSet;

        // make a copy of other
        OFOrderedSet<T> s = other;

        // go through all items in this
        for( unsigned int i=0 ; i < this->num ; i++ )
        {
          // if s contains the current item
          if( s.Contains( *this->items[i] ) )
          {
            // insert the item into the result set
            resultSet.Insert( *this->items[i] );

            // and remove the item from s so that it will not be
            // considered again in a later call to s.Contains()
            s.Remove( *this->items[i] );
          }
        }

        // return result set
        return( resultSet );
      }


      /** Determines the difference this - other, i.e. the set containing all
       *  the items found in this but not in other, and returns the resulting
       *  new set.
       *  @param other Second parameter for difference.
       *  @return New set.
       */
    OFOrderedSet<T> Difference( const OFOrderedSet<T> &other ) const
      {
        // initialize result set
        OFOrderedSet<T> resultSet;

        // make a copy of other
        OFOrderedSet<T> s = other;

        // go through all items in this
        for( unsigned int i=0 ; i < this->num ; i++ )
        {
          // if s does not contain the current item
          if( !s.Contains( *this->items[i] ) )
          {
            // insert the item into the result set
            resultSet.Insert( *this->items[i] );
          }
          else
          {
            // else remove the item from s so that it will not be
            // considered again in a later call to s.Contains()
            s.Remove( *this->items[i] );
          }
        }

        // return result set
        return( resultSet );
      }


      /** Determines the symmetric difference of this and other, i.e. the set
       *  containing all the items which can be found either in this or in other
       *  but not in the intersection of this and other, and returns the resulting
       *  new set.
       *  @param other Second parameter for symmetric difference.
       *  @return New set.
       */
    OFOrderedSet<T> SymmetricDifference( const OFOrderedSet<T> &other ) const
      {
        // determine s1 = this - other
        OFOrderedSet<T> s1 = (*this).Difference( other );

        // determine s2 = other - this
        OFOrderedSet<T> s2 = other.Difference( *this );

        // determine the union of s1 and s2
        OFOrderedSet<T> resultSet = s1.Union( s2 );

        // return result set
        return( resultSet );
      }
};


#endif

/*
** CVS/RCS Log:
** $Log: ofoset.h,v $
** Revision 1.11  2010-10-14 13:15:50  joergr
** Updated copyright header. Added reference to COPYRIGHT file.
**
** Revision 1.10  2005/12/08 16:06:00  meichel
** Changed include path schema for all DCMTK header files
**
** Revision 1.9  2004/04/21 10:00:52  meichel
** Minor modifications for compilation with gcc 3.4.0
**
** Revision 1.8  2002/12/17 17:01:33  wilkens
** Modified code again to keep Sun CC 2.0.1 happy on Solaris 2.5.1 (template
** errors).
**
** Revision 1.7  2002/12/16 10:40:24  wilkens
** Removed superfluous implementation files and modified header and make files.
**
** Revision 1.6  2002/12/13 12:26:50  wilkens
** Modified code to keep Sun CC 2.0.1 happy on Solaris 2.5.1 (template errors).
**
** Revision 1.5  2002/12/09 13:03:55  joergr
** Renamed parameter to avoid name clash with global function index().
**
** Revision 1.4  2002/07/09 18:29:45  wilkens
** Added some more functionality.
**
** Revision 1.2  2002/07/02 15:41:33  wilkens
** Made some modifications to keep gcc version egcs-2.91.66 quiet.
**
** Revision 1.1  2002/07/02 15:19:54  wilkens
** Added container classes OFOrderedSet and OFUnorderedSet which
** are based on the new abstract class OFSet.
**
**
*/