# PSet< T > Class Template Reference

This template class maps the `PAbstractSet` to a specific object type. More...

`#include <dict.h>`

Inheritance diagram for PSet< T >:

List of all members.

## Public Member Functions

Construction
| PSet (PBoolean initialDeleteObjects=false)
| Create a new, empty, dictionary.
Overrides from class PObject
virtual PObject * | Clone () const
| Make a complete duplicate of the set.
New functions for class
void | Include (const T *obj)
| Include the specified object into the set.
PSet & | operator+= (const T &obj)
| Include the specified objects value into the set.
void | Exclude (const T *obj)
| Remove the object from the set.
PSet & | operator-= (const T &obj)
| Remove the objects value from the set.
PBoolean | Contains (const T &key) const
| Determine if the value of the object is contained in the set.
PBoolean | operator[] (const T &key) const
| Determine if the value of the object is contained in the set.
virtual const T & | GetKeyAt (PINDEX index) const
| Get the key in the set at the ordinal index position.

## Protected Member Functions

| PSet (int dummy, const PSet *c)

## Detailed Description

### template<class T>
class PSet< T >

This template class maps the `PAbstractSet` to a specific object type.

The functions in this class primarily do all the appropriate casting of types.

By default, objects placed into the set will not be deleted when removed or when all references to the set are destroyed. This is different from the default on most collection classes.

Note that if templates are not used the `PDECLARE_SET` macro will simulate the template instantiation.

## Constructor & Destructor Documentation

template<class T>

PSet< T >::PSet | ( | PBoolean | initialDeleteObjects = `false` | ) | `[inline]`

Create a new, empty, dictionary.

The parameter indicates whether to delete objects that are removed from the set.

Note that by default, objects placed into the set will not be deleted when removed or when all references to the set are destroyed. This is different from the default on most collection classes.

template<class T>

PSet< T >::PSet | ( | int | dummy,
|  | const PSet< T > * | c |
| ) |  |  | `[inline, protected]`

## Member Function Documentation

template<class T>

virtual PObject* PSet< T >::Clone | ( |  | ) | const`[inline, virtual]`

Make a complete duplicate of the set.

Note that all objects in the array are also cloned, so this will make a complete copy of the set.

Reimplemented from PObject.

template<class T>

PBoolean PSet< T >::Contains | ( | const T & | key | ) | const`[inline]`

Determine if the value of the object is contained in the set.

The object values are compared, not the pointers. So the objects in the collection must correctly implement the `PObject::Compare()` function. The hash table is used to locate the entry.

Returns:
  true if the object value is in the set.

Parameters:

  key | Key to look for in the set.

template<class T>

void PSet< T >::Exclude | ( | const T * | obj | ) | `[inline]`

Remove the object from the set.

If the `AllowDeleteObjects` option is set then the object is also deleted.

The object values are compared, not the pointers. So the objects in the collection must correctly implement the `PObject::Compare()` function. The hash table is used to locate the entry.

template<class T>

virtual const T& PSet< T >::GetKeyAt | ( | PINDEX | index | ) | const`[inline, virtual]`

Get the key in the set at the ordinal index position.

The ordinal position in the set is determined by the hash values of the keys and the order of insertion.

The last key/data pair is remembered by the class so that subseqent access is very fast.

Returns:
  reference to key at the index position.

Parameters:

  index | Index of value to get.

template<class T>

void PSet< T >::Include | ( | const T * | obj | ) | `[inline]`

Include the specified object into the set.

If the objects value is already in the set then the object is not included. If the `AllowDeleteObjects` option is set then the `obj` parameter is also deleted.

The object values are compared, not the pointers. So the objects in the collection must correctly implement the `PObject::Compare()` function. The hash table is used to locate the entry.

template<class T>

PSet& PSet< T >::operator+= | ( | const T & | obj | ) | `[inline]`

Include the specified objects value into the set.

If the objects value is already in the set then the object is not included.

The object values are compared, not the pointers. So the objects in the collection must correctly implement the `PObject::Compare()` function. The hash table is used to locate the entry.

template<class T>

PSet& PSet< T >::operator-= | ( | const T & | obj | ) | `[inline]`

Remove the objects value from the set.

If the `AllowDeleteObjects` option is set then the object is also deleted.

The object values are compared, not the pointers. So the objects in the collection must correctly implement the `PObject::Compare()` function. The hash table is used to locate the entry.

template<class T>

PBoolean PSet< T >::operator[] | ( | const T & | key | ) | const`[inline]`

Determine if the value of the object is contained in the set.

The object values are compared, not the pointers. So the objects in the collection must correctly implement the `PObject::Compare()` function. The hash table is used to locate the entry.

Returns:
  true if the object value is in the set.

Parameters:

  key | Key to look for in the set.

The documentation for this class was generated from the following file:

- dict.h