/usr/include/dcmtk/ofstd/ofsetit.h is in libdcmtk2-dev 3.6.0-15+deb8u1.
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 | /*
*
* Copyright (C) 2003-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 which represents an iterator class for corres-
* ponding set data structures in ofstd.
*
* Last Update: $Author: joergr $
* Update Date: $Date: 2010-10-14 13:15:50 $
* CVS/RCS Revision: $Revision: 1.4 $
* Status: $State: Exp $
*
* CVS/RCS Log at end of file
*
*/
#ifndef OFSETIT_H
#define OFSETIT_H
#include "dcmtk/config/osconfig.h"
#include "dcmtk/ofstd/oftypes.h"
#include "dcmtk/ofstd/ofset.h"
/** This template class represents an iterator class for corresponding set data structures in ofstd.
* Note the following properties of this class:
* - even if the underlying set is unordered, it does have an internal order which can be used for
* iteration purposes
* - a reference to the set which shall be iterated over will be remembered inside an object of
* OFSetIterator<T>; the set will NOT be copied
* - it is possible to iterate from beginning to end or from end to beginning of the underlying set
* using Next() or Prev() (see below)
* - if an element from the set is removed during the iteration, the iteration process has to be
* cancelled and restarted
* - two OFSetIterators can be compared through operators == and !=; two iterators are considered
* to be identical, if and only if they operate on the exact same set (identical memory addresses)
* and they currently refer to the same element
*/
template <class T> class OFSetIterator
{
protected:
/// reference to the set instance
OFSet<T> &ofset;
/// current position in the set
unsigned int pos;
public:
/** Constructor. The iterator will be set to the set's first element.
* @param ofsetv Set to which the created object shall be an iterator.
*/
OFSetIterator( OFSet<T> &ofsetv )
: ofset( ofsetv ), pos( 0 )
{
}
/** Destructor.
*/
virtual ~OFSetIterator()
{
}
/** Resets the iterator to the set's first element.
*/
void ResetBeginning()
{
pos = 0;
}
/** Resets the iterator to the set's last element.
*/
void ResetEnd()
{
unsigned int num = ofset.NumberOfElements();
if( num == 0 )
pos = 0;
else
pos = num - 1;
}
/** Returns the current element.
* @return Pointer to the current original element in the set.
*/
T *Object()
{
if( pos == ofset.NumberOfElements() )
return( NULL );
else
return( &ofset[pos] );
}
/** Sets the iterator to the next element in the set.
*/
void Next()
{
if( pos < ofset.NumberOfElements() )
pos++;
}
/** Sets the iterator to the previous element in the set.
*/
void Prev()
{
unsigned int num = ofset.NumberOfElements();
if( pos == 0 || pos == num )
pos = num;
else
pos--;
}
/** Determines if two iterators are identical.
* @param other Iterator which shall be compared with this.
* @return OFTrue if iterators are identical, OFFalse otherwise.
*/
OFBool operator==( const OFSetIterator<T> &other ) const
{
// two iterators are considered to be identical, if and only if they operate on the
// exact same set (identical addresses) and they currently refer to the same element
if( &ofset == &other.ofset && pos == other.pos )
return( OFTrue );
else
return( OFFalse );
}
/** Determines if two iterators are not identical.
* @param other Iterator which shall be compared with this.
* @return OFTrue if iterators are not identical, OFFalse otherwise.
*/
OFBool operator!=( const OFSetIterator<T> &other ) const
{
return( !( *this == other ) );
}
};
#endif
/*
** CVS/RCS Log:
** $Log: ofsetit.h,v $
** Revision 1.4 2010-10-14 13:15:50 joergr
** Updated copyright header. Added reference to COPYRIGHT file.
**
** Revision 1.3 2010-10-05 08:36:51 joergr
** Fixed various Doxygen API documentation issues.
**
** Revision 1.2 2005/12/08 16:06:02 meichel
** Changed include path schema for all DCMTK header files
**
** Revision 1.1 2003/08/20 14:45:25 wilkens
** Added new class OFSetIterator, an iterator class for OFxxxSet data structures.
**
**
*/
|