RefSet< T > Class Template Reference

A reference-counted set. More...

#include <RefSet.h++>

Inheritance diagram for RefSet< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 RefSet ()
 Construct a new RefSet.
 ~RefSet () throw ()
 Destructor.
bool add (T value)
 Add a value to the set.
bool remove (T value)
 Remove a value from the set.
bool contains (T value) const
 Determine if a value is present in the set.
int refCount (T value) const
 Get the reference count for a given value.

Detailed Description

template<typename T>
class ccxx::RefSet< T >

A reference-counted set.

The set allows duplicate values, but it reference counts them, so that a value must be removed the same number of times that it was added in order to actually be removed from the set. RefSet is a subclass of std::map<T, int>.

Author:
Mark Lindner

Constructor & Destructor Documentation

RefSet (  ) 

Construct a new RefSet.

~RefSet (  )  throw ()

Destructor.


Member Function Documentation

bool add ( value  ) 

Add a value to the set.

If the value is already in the set, its reference count is incremented.

Parameters:
value The value to add.
Returns:
true if the value was added for the first time, false if value was already in the set.
bool contains ( value  )  const

Determine if a value is present in the set.

Parameters:
value The value.
Returns:
true if the value is in the set, false otherwise.
int refCount ( value  )  const

Get the reference count for a given value.

Parameters:
value The value.
Returns:
The reference count for the value, or 0 if the value is not in the set.
bool remove ( value  ) 

Remove a value from the set.

Decrements the reference count for the value, and removes the value from the set if the reference count has reached 0.

Parameters:
value The value to remove.
Returns:
true if the value was removed from the set, false if the value was not in the set or if the reference count for the value has not reached 0.

The documentation for this class was generated from the following file:
Generated on Sat Nov 26 16:49:09 2011 for libcommonc++ by  doxygen 1.6.3