libcommonc++  0.7
RefSet< T > Class Template Reference

A reference-counted set. More...

#include <RefSet.h++>

Inheritance diagram for RefSet< T >:
Collaboration diagram for RefSet< T >:

Public Member Functions

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

Public Attributes

keys
 STL member. More...
 
elements
 STL member. More...
 

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()

RefSet ( )

Construct a new RefSet.

◆ ~RefSet()

~RefSet ( )

Destructor.

Member Function Documentation

◆ add()

bool add ( value)

Add a value to the set.

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

Parameters
valueThe value to add.
Returns
true if the value was added for the first time, false if value was already in the set.

◆ contains()

bool contains ( value) const

Determine if a value is present in the set.

Parameters
valueThe value.
Returns
true if the value is in the set, false otherwise.

◆ refCount()

int refCount ( value) const

Get the reference count for a given value.

Parameters
valueThe value.
Returns
The reference count for the value, or 0 if the value is not in the set.

◆ remove()

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
valueThe 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.

Member Data Documentation

◆ elements

T elements
inherited

STL member.

◆ keys

K keys
inherited

STL member.


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