Support Forum       G3D Web Page     
Classes | Public Member Functions | List of all members
G3D::Set< T, HashFunc, EqualsFunc > Class Template Reference

An unordered data structure that has at most one of each element. More...

Classes

class  Iterator
 
C++ STL style iterator variable. More...
 

Public Member Functions

virtual ~Set ()
 
Iterator begin () const
 
C++ STL style iterator method. More...
 
void clear ()
 
void clearAndSetMemoryManager (const shared_ptr< MemoryManager > &m)
 
bool contains (const T &member) const
 
void deleteAll ()
 
const Iterator end () const
 
C++ STL style iterator method. More...
 
Array< T > getMembers () const
 
void getMembers (Array< T > &keyArray) const
 
const T * getPointer (const T &member) const
 If a value that is EqualsFunc to member is present, returns a pointer to the version stored in the data structure, otherwise returns nullptr. More...
 
bool getRemove (const T &member, T &removed)
 If member is present, sets removed to the element being removed and returns true. More...
 
bool insert (const T &member)
 
Inserts into the table if not already present. More...
 
bool remove (const T &member)
 
Returns true if the element was present and removed. More...
 
int size () const
 

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

◆ ~Set()

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

Member Function Documentation

◆ begin()

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.

◆ clear()

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
void G3D::Set< T, HashFunc, EqualsFunc >::clear ( )
inline

◆ clearAndSetMemoryManager()

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
void G3D::Set< T, HashFunc, EqualsFunc >::clearAndSetMemoryManager ( const shared_ptr< MemoryManager > &  m)
inline

◆ contains()

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

◆ deleteAll()

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
void G3D::Set< T, HashFunc, EqualsFunc >::deleteAll ( )
inline

◆ end()

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.

◆ getMembers() [1/2]

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

◆ getMembers() [2/2]

template<class T, class HashFunc = HashTrait<T>, class EqualsFunc = EqualsTrait<T>>
void G3D::Set< T, HashFunc, EqualsFunc >::getMembers ( Array< T > &  keyArray) const
inline

◆ getPointer()

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

◆ getRemove()

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.

◆ insert()

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.

Referenced by G3D::BlockPoolMemoryManager::alloc(), G3D::AnyTableReader::get(), G3D::AnyTableReader::operator[](), and G3D::AnyTableReader::setReadStatus().

◆ remove()

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.

Referenced by G3D::AnyTableReader::setReadStatus().

◆ size()

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

documentation generated on Wed Nov 24 2021 08:02:00 using doxygen 1.8.15