TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
G3D::Set< T, HashFunc, EqualsFunc > Class Template Reference

#include <Set.h>

Classes

class  Iterator
 

Public Member Functions

void clearAndSetMemoryManager (const MemoryManager::Ref &m)
 
virtual ~Set ()
 
int size () const
 
bool contains (const T &member) const
 
bool insert (const T &member)
 
bool remove (const T &member)
 
bool getRemove (const T &member, T &removed)
 
const T * getPointer (const T &member) const
 
Array< T > getMembers () const
 
void getMembers (Array< T > &keyArray) const
 
void clear ()
 
void deleteAll ()
 
Iterator begin () const
 
const Iterator end () const
 

Private Attributes

Table< T, bool, HashFunc,
EqualsFunc > 
memberTable
 

Detailed Description

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
class G3D::Set< T, HashFunc, EqualsFunc >

An unordered data structure that has at most one of each element. Provides O(1) time insert, remove, and member test (contains).

Set uses G3D::Table internally, which means that the template type T must define a hashCode and operator== function. See G3D::Table for a discussion of these functions.

Constructor & Destructor Documentation

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
virtual G3D::Set< T, HashFunc, EqualsFunc >::~Set ( )
inlinevirtual
48 {}

+ Here is the caller graph for this function:

Member Function Documentation

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
Iterator G3D::Set< T, HashFunc, EqualsFunc >::begin ( ) const
inline

C++ STL style iterator method. Returns the first member. Use preincrement (++entry) to get to the next element. Do not modify the set while iterating.

177  {
178  return Iterator(memberTable.begin());
179  }
Iterator begin() const
Definition: Table.h:562
Table< T, bool, HashFunc, EqualsFunc > memberTable
Definition: Set.h:40

+ Here is the caller graph for this function:

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
void G3D::Set< T, HashFunc, EqualsFunc >::clear ( )
inline
101  {
102  memberTable.clear();
103  }
void clear()
Definition: Table.h:578
Table< T, bool, HashFunc, EqualsFunc > memberTable
Definition: Set.h:40

+ Here is the caller graph for this function:

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
void G3D::Set< T, HashFunc, EqualsFunc >::clearAndSetMemoryManager ( const MemoryManager::Ref m)
inline
44  {
46  }
Table< T, bool, HashFunc, EqualsFunc > memberTable
Definition: Set.h:40
void clearAndSetMemoryManager(const MemoryManager::Ref &m)
Definition: Table.h:309
template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
bool G3D::Set< T, HashFunc, EqualsFunc >::contains ( const T &  member) const
inline
54  {
55  return memberTable.containsKey(member);
56  }
Table< T, bool, HashFunc, EqualsFunc > memberTable
Definition: Set.h:40
bool containsKey(const Key &key) const
Definition: Table.h:874

+ Here is the caller graph for this function:

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
void G3D::Set< T, HashFunc, EqualsFunc >::deleteAll ( )
inline
105  {
106  getMembers().deleteAll();
107  clear();
108  }
void clear()
Definition: Set.h:101
void G3D_DEPRECATED deleteAll()
Definition: Array.h:988
Array< T > getMembers() const
Definition: Set.h:93
template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
const Iterator G3D::Set< T, HashFunc, EqualsFunc >::end ( ) const
inline

C++ STL style iterator method. Returns one after the last iterator element.

186  {
187  return Iterator(memberTable.end());
188  }
Table< T, bool, HashFunc, EqualsFunc > memberTable
Definition: Set.h:40
const Iterator end() const
Definition: Table.h:570

+ Here is the caller graph for this function:

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
Array<T> G3D::Set< T, HashFunc, EqualsFunc >::getMembers ( ) const
inline
93  {
94  return memberTable.getKeys();
95  }
Table< T, bool, HashFunc, EqualsFunc > memberTable
Definition: Set.h:40
Array< Key > getKeys() const
Definition: Table.h:907

+ Here is the caller graph for this function:

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
void G3D::Set< T, HashFunc, EqualsFunc >::getMembers ( Array< T > &  keyArray) const
inline
97  {
98  memberTable.getKeys(keyArray);
99  }
Table< T, bool, HashFunc, EqualsFunc > memberTable
Definition: Set.h:40
Array< Key > getKeys() const
Definition: Table.h:907
template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
const T* G3D::Set< T, HashFunc, EqualsFunc >::getPointer ( const T &  member) const
inline

If a value that is EqualsFunc to member is present, returns a pointer to the version stored in the data structure, otherwise returns NULL.

89  {
90  return memberTable.getKeyPointer(member);
91  }
Table< T, bool, HashFunc, EqualsFunc > memberTable
Definition: Set.h:40
const Key * getKeyPointer(const Key &key) const
Definition: Table.h:701
template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
bool G3D::Set< T, HashFunc, EqualsFunc >::getRemove ( const T &  member,
T &  removed 
)
inline

If member is present, sets removed to the element being removed and returns true. Otherwise returns false and does not write to removed. This is useful when building efficient hashed data structures that wrap Set.

81  {
82  bool ignore;
83  return memberTable.getRemove(member, removed, ignore);
84  }
bool getRemove(const Key &key, Key &removedKey, Value &removedValue)
Definition: Table.h:660
Table< T, bool, HashFunc, EqualsFunc > memberTable
Definition: Set.h:40
template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
bool G3D::Set< T, HashFunc, EqualsFunc >::insert ( const T &  member)
inline

Inserts into the table if not already present. Returns true if this is the first time the element was added.

62  {
63  bool isNew = false;
64  memberTable.getCreate(member, isNew) = true;
65  return isNew;
66  }
Table< T, bool, HashFunc, EqualsFunc > memberTable
Definition: Set.h:40
Value & getCreate(const Key &key)
Definition: Table.h:861

+ Here is the caller graph for this function:

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
bool G3D::Set< T, HashFunc, EqualsFunc >::remove ( const T &  member)
inline

Returns true if the element was present and removed. Returns false if the element was not present.

72  {
73  return memberTable.remove(member);
74  }
Table< T, bool, HashFunc, EqualsFunc > memberTable
Definition: Set.h:40
bool remove(const Key &key, Key &removedKey, Value &removedValue, bool updateRemoved)
Definition: Table.h:606

+ Here is the caller graph for this function:

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
int G3D::Set< T, HashFunc, EqualsFunc >::size ( ) const
inline
50  {
51  return (int)memberTable.size();
52  }
size_t size() const
Definition: Table.h:589
Table< T, bool, HashFunc, EqualsFunc > memberTable
Definition: Set.h:40

+ Here is the caller graph for this function:

Member Data Documentation

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
Table<T, bool, HashFunc, EqualsFunc> G3D::Set< T, HashFunc, EqualsFunc >::memberTable
private

If an object is a member, it is contained in this table.


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