/* * * 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 a set of elements of an * arbitrary type. * */ #ifndef OFSET_H #define OFSET_H #include "dcmtk/config/osconfig.h" #include "dcmtk/ofstd/oftypes.h" #define INCLUDE_CSTDDEF /* For NULL */ #include "dcmtk/ofstd/ofstdinc.h" #define STARTING_SIZE 8 /** This abstract template class provides a data structure and operations for administrating a * set of elements of an arbitrary type. */ template class OFSet { protected: /// array containing the entries T **items; /// number of entries in the set unsigned int num; /// current size of the set (always >= num) unsigned int size; public: /** Default constructor. */ OFSet() : items( new T*[ STARTING_SIZE ] ), num( 0 ), size( STARTING_SIZE ) { init(); } /** This function is a workaround for avoiding a compiler warning on * Solaris 2.5.1 using compiler SC 2.0.1. */ void init() { for( unsigned i=0 ; i &src ) : items( NULL ), num ( src.num ), size ( src.size ) { init( src ); } /** This function is a workaround for avoiding a compiler warning on * Solaris 2.5.1 using compiler SC 2.0.1. */ void init( const OFSet &src ) { items = new T*[size]; for( unsigned int i=0 ; i &operator=( const OFSet &src ) { if( this == &src ) return( *this ); unsigned int i; for( i=0 ; i= num ) { T **tmp = new T*[newSize]; for( i=0 ; i