Source: classlib/include/classlib/sets.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
    sets.h  -  set di oggetti
                             -------------------
    begin                : ven dic  7 17:40:01 CET 2001
    copyright            : (C) 2001 by Nicola De Nisco
    email                : nicola@winada.it
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#if !defined( __CLASSLIB_SETS_H )
#define __CLASSLIB_SETS_H

#if !defined( __CHECKS_H )
#include 
#endif  // __CHECKS_H

#if !defined( __CLASSLIB_DEFS_H )
#include "classlib/defs.h"
#endif  // __CLASSLIB_DEFS_H

#if !defined( __CLASSLIB_BAGS_H )
#include "classlib/bags.h"
#endif  // __CLASSLIB_BAGS_H

template  class TMSetAsVectorIterator;

/**

  template  class TMSetAsVector
  template  class TMSetAsVectorIterator

  Implements a managed set of objects of type T, using a vector as
  the underlying implementation.

*/

template  class TMSetAsVector :
    private TMBagAsVector
{

    typedef TMBagAsVector Parent;

public:

    friend class TMSetAsVectorIterator;

    TMSetAsVector( unsigned sz = DEFAULT_SET_SIZE ) :
        TMBagAsVector(sz)
        {
        }

    int Add( const T& );

    Parent::Detach;
    Parent::HasMember;
    Parent::Find;
    Parent::IsEmpty;
    Parent::IsFull;
    Parent::GetItemsInContainer;
    Parent::ForEach;
    Parent::FirstThat;
    Parent::LastThat;
    Parent::Flush;
};

template  class TMSetAsVectorIterator :
    public TMBagAsVectorIterator
{

public:

    TMSetAsVectorIterator( const TMSetAsVector& s ) :
        TMBagAsVectorIterator(s)
        {
        }

};

template  int TMSetAsVector::Add( const T& t )
{
    if( HasMember(t) )
        return 0;
    else
        return TMBagAsVector::Add(t);
}

/**

  template  class TSetAsVector
  template  class TSetAsVectorIterator

  Implements a set of objects of type T, using a vector as
  the underlying implementation and TStandardAllocator as its
  memory manager.

*/

template  class TSetAsVector :
    public TMSetAsVector
{

public:

    TSetAsVector( unsigned sz = DEFAULT_SET_SIZE ) :
        TMSetAsVector(sz)
        {
        }

};

template  class TSetAsVectorIterator :
    public TMSetAsVectorIterator
{

public:

    TSetAsVectorIterator( const TSetAsVector& s ) :
        TMSetAsVectorIterator(s)
        {
        }

};

template  class TMISetAsVectorIterator;

/**

  template  class TMISetAsVector
  template  class TMISetAsVectorIterator

  Implements a managed set of pointers to objects of type T,
  using a vector as the underlying implementation.

*/

template  class TMISetAsVector :
    private TMIBagAsVector
{

    typedef TMIBagAsVector Parent;

public:

    friend class TMISetAsVectorIterator;

    TMISetAsVector( unsigned sz = DEFAULT_SET_SIZE ) :
        TMIBagAsVector(sz)
        {
        }

    int Add( T * );

    typedef void (*IterFunc)(T&, void *);
    typedef int  (*CondFunc)(const T&, void *);
    Parent::Detach;
    Parent::HasMember;
    Parent::Find;
    Parent::IsEmpty;
    Parent::IsFull;
    Parent::GetItemsInContainer;

    Parent::ForEach;
    Parent::FirstThat;
    Parent::LastThat;
    Parent::Flush;
    Parent::OwnsElements;
};

template 
int TMISetAsVector::Add( T *t )
{
    if( HasMember(t) )
        return 0;
    else
        return TMIBagAsVector::Add(t);
}

template  class TMISetAsVectorIterator :
    public TMIBagAsVectorIterator
{

public:

    TMISetAsVectorIterator( const TMISetAsVector& s ) :
        TMIBagAsVectorIterator(s) {}

};

/**

  template  class TISetAsVector
  template  class TISetAsVectorIterator

  Implements a set of pointers to objects of type T,
  using a vector as the underlying implementation and
  TStandardAllocator as its memory manager.

*/

template  class TISetAsVector :
    public TMISetAsVector
{

public:

    TISetAsVector( unsigned sz = DEFAULT_SET_SIZE ) :
        TMISetAsVector(sz)
        {
        }

};

template  class TISetAsVectorIterator :
    public TMISetAsVectorIterator
{

public:

    TISetAsVectorIterator( const TISetAsVector& s ) :
        TMISetAsVectorIterator(s)
        {
        }

};

/////////////////////////////////////////////////////////////////////////////

/**

  template  class TSet
  template  class TSetIterator

  Easy names for TSetAsVector and TSetAsVectorIterator.

*/

template  class TSet :
    public TSetAsVector
{

public:

    TSet( unsigned sz = DEFAULT_SET_SIZE ) :
        TSetAsVector( sz )
        {
        }

};

/**

  template  class TSet
  template  class TSetIterator

  Easy names for TSetAsVector and TSetAsVectorIterator.

*/

template  class TSetIterator :
    public TSetAsVectorIterator
{

public:


    TSetIterator( const TSet& a ) :
        TSetAsVectorIterator(a)
        {
        }

};

/////////////////////////////////////////////////////////////////////////////

/**

  template  class TISet
  template  class TISetIterator

  Easy names for TISetAsVector and TISetAsVectorIterator.

*/

template  class TISet :
    public TISetAsVector
{

public:

    TISet( unsigned sz = DEFAULT_SET_SIZE ) :
        TISetAsVector( sz )
        {
        }

};

/**

  template  class TISet
  template  class TISetIterator

  Easy names for TISetAsVector and TISetAsVectorIterator.

*/

template  class TISetIterator :
    public TISetAsVectorIterator
{

public:


    TISetIterator( const TISet& a ) :
        TISetAsVectorIterator(a)
        {
        }

};

#endif  // __CLASSLIB_SETS_H


Generated by: nicola on gulliver.wadahome.it on Sun May 25 13:54:34 2003, using kdoc 2.0a53.