30 #ifndef OFOrderedSet_h 31 #define OFOrderedSet_h 33 #include "dcmtk/config/osconfig.h" 34 #include "dcmtk/ofstd/oftypes.h" 35 #include "dcmtk/ofstd/ofset.h" 112 if( this->
num != other.
num )
116 OFBool result = OFTrue;
119 for(
unsigned int i=0 ; i < this->
num && result == OFTrue ; i++ )
138 return( !( *
this == other ) );
152 T *newItem =
new T( item );
168 for(
unsigned int i=0 ; i<other.
num ; i++ )
180 virtual void InsertAt(
const T &item,
unsigned int idx )
186 if( idx > this->
num - 1 )
195 T *newItem =
new T( item );
198 T **tmp =
new T*[this->
size];
200 for( i=0 ; i<idx ; i++ )
201 tmp[i] = this->
items[i];
205 for( i=idx ; i < this->
size - 1 ; i++ )
208 tmp[i+1] = this->
items[i];
231 OFBool itemDeleted = OFFalse;
234 for(
unsigned int i=0 ; i < this->
num && !itemDeleted ; i++ )
237 if( *this->
items[i] == item )
240 delete this->
items[i];
245 if( i != this->
num - 1 )
248 for( j=i+1 ; j < this->
num ; j++ )
253 this->
items[j-1] = NULL;
256 this->
items[i] = NULL;
262 itemDeleted = OFTrue;
274 if( idx < this->
num )
277 delete this->
items[idx];
282 if( idx != this->num - 1 )
285 for( j=idx+1 ; j < this->
num ; j++ )
290 this->
items[j-1] = NULL;
293 this->
items[idx] = NULL;
307 virtual T *
Find(
const T &item )
const 310 OFBool itemFound = OFFalse;
312 for( i=0 ; i < this->
num && !itemFound ; i++ )
314 if( *this->
items[i] == item )
319 return( this->
items[i-1] );
331 OFBool itemFound = OFFalse;
333 for(
unsigned int i=0 ; i < this->
num && !itemFound ; i++ )
335 if( *this->
items[i] == item )
352 if( this->
num <= other.
num )
356 OFBool result = OFTrue;
362 for(
unsigned int i=0 ; i<other.
num && result == OFTrue ; i++ )
405 resultSet.
Insert( other );
427 for(
unsigned int i=0 ; i < this->
num ; i++ )
461 for(
unsigned int i=0 ; i < this->
num ; i++ )
464 if( !s.
Contains( *this->items[i] ) )
virtual void RemoveByIndex(unsigned int idx)
Removes one item from the set.
unsigned int num
number of entries in the set
This template class provides a data structure and operations for administrating an ordered set of ele...
virtual void Insert(const T &item)
Inserts a new item into the set.
virtual OFBool operator!=(const OFOrderedSet< T > &other) const
Determines if two sets are not identical.
virtual T * Find(const T &item) const
Tries to find a given object in the set.
virtual OFBool operator==(const OFOrderedSet< T > &other) const
Determines if two sets are identical.
OFOrderedSet< T > Union(const OFOrderedSet< T > &other) const
Determines the union of the two sets this and other, i.e.
virtual void Remove(const T &item)
Removes one item from the set.
virtual void InsertAt(const T &item, unsigned int idx)
Inserts a new item at a certain position into the set.
const OFOrderedSet< T > & operator=(const OFOrderedSet< T > &src)
operator=.
OFOrderedSet()
Default constructor.
OFOrderedSet< T > Intersection(const OFOrderedSet< T > &other) const
Determines the intersection of the two sets this and other, i.e.
virtual void Insert(const OFOrderedSet< T > &other)
Inserts all items of another set into this set.
OFOrderedSet(const OFOrderedSet< T > &src)
Copy constructor.
OFOrderedSet< T > Difference(const OFOrderedSet< T > &other) const
Determines the difference this - other, i.e.
virtual void Resize(unsigned int newSize)
Resizes the set.
virtual OFBool Contains(const T &item) const
Determines if a certain item is contained in the set.
T ** items
array containing the entries
unsigned int size
current size of the set (always >= num)
This abstract template class provides a data structure and operations for administrating a set of ele...
const OFOrderedSet< T > & assign(const OFOrderedSet< T > &src)
This function is a workaround for avoiding a compiler warning on Solaris 2.5.1 using compiler SC 2...
OFOrderedSet< T > SymmetricDifference(const OFOrderedSet< T > &other) const
Determines the symmetric difference of this and other, i.e.
virtual OFBool IsSupersetOf(const OFOrderedSet< T > &other) const
Determines if this is an actual superset of other, i.e.
virtual OFBool IsSubsetOf(const OFOrderedSet< T > &other) const
Determines if this is an actual subset of other, i.e.
virtual ~OFOrderedSet()
Destructor.