⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ofoset.h

📁 转化为DIB位图再显示出来的dicom文件C++代码
💻 H
📖 第 1 页 / 共 2 页
字号:
       */    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.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.*****/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -