Public Member Functions | Protected Member Functions | Protected Attributes

TypeSet< T > Class Template Reference

Set of (small) copyable elements. More...

Inheritance diagram for TypeSet< T >:
OD::Set

List of all members.

Public Member Functions

 TypeSet ()
 TypeSet (int nr, T typ)
 TypeSet (const T *, int nr)
 TypeSet (const TypeSet< T > &)
virtual ~TypeSet ()
TypeSet< T > & operator= (const TypeSet< T > &)
int size () const
virtual int nrItems () const
virtual bool setSize (int, T val=T())
virtual bool setCapacity (int sz)
T & operator[] (int)
const T & operator[] (int) const
T & first ()
const T & first () const
T & last ()
const T & last () const
virtual bool validIdx (int) const
virtual int indexOf (T, bool forward=true, int start=-1) const
bool isPresent (const T &t) const
TypeSet< T > & operator+= (const T &)
TypeSet< T > & operator-= (const T &)
virtual TypeSet< T > & copy (const T *, unsigned int)
virtual TypeSet< T > & copy (const TypeSet< T > &)
virtual bool append (const T *, unsigned int)
virtual bool append (const TypeSet< T > &)
bool add (const T &)
virtual void swap (int, int)
virtual void reverse ()
virtual void createUnion (const TypeSet< T > &)
virtual void createIntersection (const TypeSet< T > &)
 Only keeps common items.
virtual void createDifference (const TypeSet< T > &, bool must_preserve_order=false)
 Removes all items present in other set.
virtual bool addIfNew (const T &)
virtual void fillWith (const T &)
virtual void erase ()
virtual void remove (int, bool preserve_order=true)
virtual void remove (int from, int to)
virtual void insert (int, const T &)
virtual T * arr ()
 3rd party access
virtual const T * arr () const
std::vector< T > & vec ()
const std::vector< T > & vec () const

Protected Member Functions

virtual T * gtArr () const

Protected Attributes

VectorAccess< T > vec_

Detailed Description

template<class T>
class TypeSet< T >

Set of (small) copyable elements.

The TypeSet is meant for simple types or small objects that have a copy constructor. The `-=' function will only remove the first occurrence that matches using the `==' operator. The requirement of the presence of that operator is actually not that bad: at least you can't forget it.

Do not make TypeSet<bool> (don't worry, it won't compile). Use the BoolTypeSet typedef just after the class definition. See vectoraccess.h for details on why.


Constructor & Destructor Documentation

template<class T >
TypeSet< T >::TypeSet (  )  [inline]
template<class T>
TypeSet< T >::TypeSet ( int  nr,
typ 
) [inline]
template<class T>
TypeSet< T >::TypeSet ( const T *  tarr,
int  nr 
) [inline]
template<class T>
TypeSet< T >::TypeSet ( const TypeSet< T > &  t  )  [inline]
template<class T >
TypeSet< T >::~TypeSet (  )  [inline, virtual]

Member Function Documentation

template<class T>
bool TypeSet< T >::add ( const T &  t  )  [inline]
template<class T>
bool TypeSet< T >::addIfNew ( const T &  typ  )  [inline, virtual]
template<class T>
bool TypeSet< T >::append ( const T *  tarr,
unsigned int  sz 
) [inline, virtual]
template<class T>
bool TypeSet< T >::append ( const TypeSet< T > &  ts  )  [inline, virtual]
template<class T>
virtual T* TypeSet< T >::arr (  )  [inline, virtual]

3rd party access

template<class T>
virtual const T* TypeSet< T >::arr (  )  const [inline, virtual]
template<class T>
TypeSet< T > & TypeSet< T >::copy ( const TypeSet< T > &  ts  )  [inline, virtual]
template<class T>
TypeSet< T > & TypeSet< T >::copy ( const T *  tarr,
unsigned int  sz 
) [inline, virtual]
template<class T>
void TypeSet< T >::createDifference ( const TypeSet< T > &  ts,
bool  must_preserve_order = false 
) [inline, virtual]

Removes all items present in other set.

template<class T>
void TypeSet< T >::createIntersection ( const TypeSet< T > &  ts  )  [inline, virtual]

Only keeps common items.

template<class T>
void TypeSet< T >::createUnion ( const TypeSet< T > &  ts  )  [inline, virtual]

Adds items not already there

template<class T >
void TypeSet< T >::erase (  )  [inline, virtual]

Implements OD::Set.

template<class T>
void TypeSet< T >::fillWith ( const T &  t  )  [inline, virtual]
template<class T >
T & TypeSet< T >::first (  )  [inline]
template<class T >
const T & TypeSet< T >::first (  )  const [inline]
template<class T >
T * TypeSet< T >::gtArr (  )  const [inline, protected, virtual]
template<class T>
int TypeSet< T >::indexOf ( typ,
bool  forward = true,
int  start = -1 
) const [inline, virtual]
template<class T>
void TypeSet< T >::insert ( int  idx,
const T &  typ 
) [inline, virtual]
template<class T>
bool TypeSet< T >::isPresent ( const T &  t  )  const [inline]
template<class T >
T & TypeSet< T >::last (  )  [inline]
template<class T >
const T & TypeSet< T >::last (  )  const [inline]
template<class T>
virtual int TypeSet< T >::nrItems (  )  const [inline, virtual]

Implements OD::Set.

template<class T>
TypeSet< T > & TypeSet< T >::operator+= ( const T &  typ  )  [inline]
template<class T>
TypeSet< T > & TypeSet< T >::operator-= ( const T &  typ  )  [inline]
template<class T>
TypeSet< T > & TypeSet< T >::operator= ( const TypeSet< T > &  ts  )  [inline]
template<class T >
T & TypeSet< T >::operator[] ( int  idx  )  [inline]
template<class T >
const T & TypeSet< T >::operator[] ( int  idx  )  const [inline]
template<class T >
void TypeSet< T >::remove ( int  from,
int  to 
) [inline, virtual]

Implements OD::Set.

template<class T >
void TypeSet< T >::remove ( int  idx,
bool  preserve_order = true 
) [inline, virtual]
template<class T >
void TypeSet< T >::reverse (  )  [inline, virtual]
template<class T >
bool TypeSet< T >::setCapacity ( int  sz  )  [inline, virtual]

Allocates mem only, no size() change

template<class T>
bool TypeSet< T >::setSize ( int  sz,
val = T() 
) [inline, virtual]
Parameters:
val value assigned to new items
template<class T>
int TypeSet< T >::size (  )  const [inline]
template<class T >
void TypeSet< T >::swap ( int  idx0,
int  idx1 
) [inline, virtual]

Implements OD::Set.

template<class T >
bool TypeSet< T >::validIdx ( int  idx  )  const [inline, virtual]

Implements OD::Set.

template<class T >
const std::vector< T > & TypeSet< T >::vec (  )  const [inline]
template<class T >
std::vector< T > & TypeSet< T >::vec (  )  [inline]

Member Data Documentation

template<class T>
VectorAccess<T> TypeSet< T >::vec_ [protected]