FbxSet< Type, Compare, Allocator > Class Template Reference

FbxSet< Type, Compare, Allocator > Class Template Reference

#include <fbxset.h>

Class Description

template<typename Type, typename Compare = FbxLessCompare<Type>, typename Allocator = FbxBaseAllocator>
class FbxSet< Type, Compare, Allocator >

This class implements an efficient set based on value comparison, which stores values.

It executes insertion, deletion and query operations in O(log(n)) time.

Definition at line 25 of file fbxset.h.

Classes

class  Value
 This class defines the value type used by the set. More...
 

Public Types

typedef Type ValueType
 
typedef StorageType::RecordType RecordType
 
typedef StorageType::IteratorType Iterator
 
typedef StorageType::ConstIteratorType ConstIterator
 

Public Member Functions

void Reserve (unsigned int pRecordCount)
 Preallocate memory. More...
 
int GetSize () const
 Retrieve the number of values it holds. More...
 
FbxPair< RecordType *, bool > Insert (const ValueType &pValue)
 Insert a value. More...
 
int Remove (const ValueType &pValue)
 Delete a value. More...
 
void Clear ()
 Clear the set. More...
 
bool Empty () const
 Query whether the set is empty. More...
 
Iterator Begin ()
 Retrieve the begin iterator of the set. More...
 
Iterator End ()
 Retrieve the end iterator of the set. More...
 
ConstIterator Begin () const
 Retrieve the begin iterator of the set. More...
 
ConstIterator End () const
 Retrieve the end iterator of the set. More...
 
const RecordTypeFind (const ValueType &pValue) const
 Find a given value in the set. More...
 
RecordTypeFind (const ValueType &pValue)
 Find a given value in the set. More...
 
const RecordTypeMinimum () const
 Retrieve the minimum value in the set. More...
 
RecordTypeMinimum ()
 Retrieve the minimum value in the set. More...
 
const RecordTypeMaximum () const
 Retrieve the maximum value in the set. More...
 
RecordTypeMaximum ()
 Retrieve the maximum value in the set. More...
 
bool operator== (const FbxSet< Type, Compare, Allocator > &pOther) const
 Equality operator. More...
 
bool operator!= (const FbxSet< Type, Compare, Allocator > &pOther) const
 Inequality operator. More...
 
FbxSet Intersect (const FbxSet &pOther) const
 Intersect with another set. More...
 
FbxSet Union (const FbxSet &pOther) const
 Unite with another set. More...
 

Protected Types

typedef FbxRedBlackTree< Value, Compare, Allocator > StorageType
 Declaration of the storage type used by the set. More...
 

Member Typedef Documentation

typedef FbxRedBlackTree<Value, Compare, Allocator> StorageType
protected

Declaration of the storage type used by the set.

Definition at line 56 of file fbxset.h.

typedef Type ValueType

Definition at line 59 of file fbxset.h.

typedef StorageType::RecordType RecordType

Definition at line 60 of file fbxset.h.

typedef StorageType::IteratorType Iterator

Definition at line 61 of file fbxset.h.

typedef StorageType::ConstIteratorType ConstIterator

Definition at line 62 of file fbxset.h.

Member Function Documentation

void Reserve ( unsigned int  pRecordCount)
inline

Preallocate memory.

Parameters
pRecordCountThe number of elements.

Definition at line 67 of file fbxset.h.

68  {
69  mTree.Reserve(pRecordCount);
70  }
int GetSize ( ) const
inline

Retrieve the number of values it holds.

Definition at line 73 of file fbxset.h.

74  {
75  return mTree.GetSize();
76  }
FbxPair<RecordType*, bool> Insert ( const ValueType pValue)
inline

Insert a value.

Parameters
pValueThe value.
Returns
If the value is already present in the map, returns the existing value and false; else returns the pointer to the new value and true.

Definition at line 81 of file fbxset.h.

82  {
83  return mTree.Insert(Value(pValue));
84  }
int Remove ( const ValueType pValue)
inline

Delete a value.

Parameters
pValueThe value.
Returns
true if success, false if value is not found.

Definition at line 89 of file fbxset.h.

90  {
91  return mTree.Remove(pValue);
92  }
void Clear ( )
inline

Clear the set.

Definition at line 95 of file fbxset.h.

96  {
97  mTree.Clear();
98  }
bool Empty ( ) const
inline

Query whether the set is empty.

Definition at line 101 of file fbxset.h.

102  {
103  return mTree.Empty();
104  }
Iterator Begin ( )
inline

Retrieve the begin iterator of the set.

Definition at line 107 of file fbxset.h.

108  {
109  return Iterator(Minimum());
110  }
const RecordType * Minimum() const
Retrieve the minimum value in the set.
Definition: fbxset.h:147
StorageType::IteratorType Iterator
Definition: fbxset.h:61
Iterator End ( )
inline

Retrieve the end iterator of the set.

Definition at line 113 of file fbxset.h.

114  {
115  return Iterator();
116  }
StorageType::IteratorType Iterator
Definition: fbxset.h:61
ConstIterator Begin ( ) const
inline

Retrieve the begin iterator of the set.

Definition at line 119 of file fbxset.h.

120  {
121  return ConstIterator(Minimum());
122  }
const RecordType * Minimum() const
Retrieve the minimum value in the set.
Definition: fbxset.h:147
StorageType::ConstIteratorType ConstIterator
Definition: fbxset.h:62
ConstIterator End ( ) const
inline

Retrieve the end iterator of the set.

Definition at line 125 of file fbxset.h.

126  {
127  return ConstIterator();
128  }
StorageType::ConstIteratorType ConstIterator
Definition: fbxset.h:62
const RecordType* Find ( const ValueType pValue) const
inline

Find a given value in the set.

Parameters
pValueThe value to find.
Returns
The value in the set, or NULL if the value is not found in the set.

Definition at line 133 of file fbxset.h.

134  {
135  return mTree.Find(pValue);
136  }
RecordType* Find ( const ValueType pValue)
inline

Find a given value in the set.

Parameters
pValueThe value to find.
Returns
The value in the set, or NULL if the value is not found in the set.

Definition at line 141 of file fbxset.h.

142  {
143  return mTree.Find(pValue);
144  }
const RecordType* Minimum ( ) const
inline

Retrieve the minimum value in the set.

Definition at line 147 of file fbxset.h.

148  {
149  return mTree.Minimum();
150  }
RecordType* Minimum ( )
inline

Retrieve the minimum value in the set.

Definition at line 153 of file fbxset.h.

154  {
155  return mTree.Minimum();
156  }
const RecordType* Maximum ( ) const
inline

Retrieve the maximum value in the set.

Definition at line 159 of file fbxset.h.

160  {
161  return mTree.Maximum();
162  }
RecordType* Maximum ( )
inline

Retrieve the maximum value in the set.

Definition at line 165 of file fbxset.h.

166  {
167  return mTree.Maximum();
168  }
bool operator== ( const FbxSet< Type, Compare, Allocator > &  pOther) const
inline

Equality operator.

Definition at line 171 of file fbxset.h.

172  {
173  return (this == &pOther) || (mTree == pOther.mTree);
174  }
bool operator!= ( const FbxSet< Type, Compare, Allocator > &  pOther) const
inline

Inequality operator.

Definition at line 177 of file fbxset.h.

178  {
179  return !(*this == pOther);
180  }
FbxSet Intersect ( const FbxSet< Type, Compare, Allocator > &  pOther) const
inline

Intersect with another set.

Parameters
pOtherThe other set.
Returns
The intersection set of the two sets.

Definition at line 185 of file fbxset.h.

186  {
187  FbxSet lReturn;
188  ConstIterator lBegin = Begin();
189  for (; lBegin != End(); ++lBegin)
190  {
191  if (pOther.Find(lBegin->GetValue()) != NULL)
192  lReturn.Insert(lBegin->GetValue());
193  }
194  return lReturn;
195  }
Iterator Begin()
Retrieve the begin iterator of the set.
Definition: fbxset.h:107
FbxPair< RecordType *, bool > Insert(const ValueType &pValue)
Insert a value.
Definition: fbxset.h:81
#define NULL
Definition: fbxarch.h:210
const RecordType * Find(const ValueType &pValue) const
Find a given value in the set.
Definition: fbxset.h:133
This class implements an efficient set based on value comparison, which stores values.
Definition: fbxset.h:25
StorageType::ConstIteratorType ConstIterator
Definition: fbxset.h:62
Iterator End()
Retrieve the end iterator of the set.
Definition: fbxset.h:113
FbxSet Union ( const FbxSet< Type, Compare, Allocator > &  pOther) const
inline

Unite with another set.

Parameters
pOtherThe other set.
Returns
The union set of the two sets (no duplicated items).

Definition at line 200 of file fbxset.h.

201  {
202  FbxSet lReturn(*this);
203  ConstIterator lBegin = pOther.Begin();
204  for (; lBegin != End(); ++lBegin)
205  {
206  if (Find(lBegin->GetValue()) == NULL)
207  lReturn.Insert(lBegin->GetValue());
208  }
209  return lReturn;
210  }
Iterator Begin()
Retrieve the begin iterator of the set.
Definition: fbxset.h:107
#define NULL
Definition: fbxarch.h:210
const RecordType * Find(const ValueType &pValue) const
Find a given value in the set.
Definition: fbxset.h:133
This class implements an efficient set based on value comparison, which stores values.
Definition: fbxset.h:25
StorageType::ConstIteratorType ConstIterator
Definition: fbxset.h:62
Iterator End()
Retrieve the end iterator of the set.
Definition: fbxset.h:113

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