Constant-time set operations. More...
#include <ogdf/basic/RegisteredSet.h>
Public Types | |
using | element_type = typename Registry::key_type |
using | list_type = typename std::conditional< SupportFastSizeQuery, List< element_type >, ListPure< element_type > >::type |
Public Member Functions | |
RegisteredSet () | |
Creates an empty set associated with no registry. More... | |
template<bool OtherSupportsFastSizeQuery> | |
RegisteredSet (const RegisteredSet< Registry, OtherSupportsFastSizeQuery > &other) | |
Copy constructor. More... | |
RegisteredSet (const Registry &R) | |
Creates an empty set associated with registry R . More... | |
list_type::const_iterator | begin () const |
void | clear () |
Removes all elements from this set. More... | |
const list_type & | elements () const |
Returns a reference to the list of elements contained in this set. More... | |
list_type::const_iterator | end () const |
void | init () |
Reinitializes the set. Associates the set with no registry. More... | |
void | init (const Registry &R) |
Reinitializes the set. Associates the set with registry R . More... | |
void | insert (element_type v) |
Inserts element v into this set. More... | |
bool | isMember (element_type v) const |
Returns true iff element v is contained in this set. More... | |
bool | operator() (element_type v) const |
Returns the same as isMember() to use an RegisteredSet instance as filter function. More... | |
template<bool OtherSupportsFastSizeQuery> | |
RegisteredSet & | operator= (const RegisteredSet< Registry, OtherSupportsFastSizeQuery > &other) |
Assignment operator. More... | |
const Registry * | registeredAt () const |
Returns the associated registry. More... | |
bool | remove (element_type v) |
Removes element v from this set and return true iff v was previously present. More... | |
int | size () const |
Returns the number of elements in this set. More... | |
Private Attributes | |
list_type | m_elements |
The list of elements contained in this set. More... | |
RegisteredArray< Registry, ListIterator< element_type >, false > | m_it |
m_it[v] contains the list iterator pointing to v if v is contained in this set, or an invalid list iterator otherwise. More... | |
Constant-time set operations.
Maintains a subset of indexed keys managed by a registry.
Provides efficient operations for testing membership, iteration, insertion, and deletion of elements, as well as clearing the set.
Registry | The class which manages the registered keys. Must provide the functions defined in class RegistryBase. |
SupportFastSizeQuery | Whether this set supports querying its size in constant instead of linear time (in the size). |
Definition at line 55 of file RegisteredSet.h.
using ogdf::RegisteredSet< Registry, SupportFastSizeQuery >::element_type = typename Registry::key_type |
Definition at line 57 of file RegisteredSet.h.
using ogdf::RegisteredSet< Registry, SupportFastSizeQuery >::list_type = typename std::conditional<SupportFastSizeQuery, List<element_type>, ListPure<element_type> >::type |
Definition at line 59 of file RegisteredSet.h.
|
inlineexplicit |
Creates an empty set associated with registry R
.
Definition at line 62 of file RegisteredSet.h.
|
inlineexplicit |
Creates an empty set associated with no registry.
Definition at line 65 of file RegisteredSet.h.
|
inlineexplicit |
Copy constructor.
Definition at line 161 of file RegisteredSet.h.
|
inline |
Definition at line 155 of file RegisteredSet.h.
|
inline |
Removes all elements from this set.
After this operation, this set is empty and still associated with the same registry. The runtime of this operation is linear in the size(). Implementation Detail: If less than 10% of all elements are part of this set, they will be individually cleared. Otherwise, std::vector::assign(...)
will be used to clear all values.
Definition at line 118 of file RegisteredSet.h.
|
inline |
Returns a reference to the list of elements contained in this set.
Definition at line 144 of file RegisteredSet.h.
|
inline |
Definition at line 157 of file RegisteredSet.h.
|
inline |
Reinitializes the set. Associates the set with no registry.
Definition at line 68 of file RegisteredSet.h.
|
inline |
Reinitializes the set. Associates the set with registry R
.
Definition at line 74 of file RegisteredSet.h.
|
inline |
Inserts element v
into this set.
This operation has constant runtime. If the element is already contained in this set, nothing happens.
v
is an element in the associated registry. Definition at line 86 of file RegisteredSet.h.
|
inline |
Returns true
iff element v
is contained in this set.
This operation has constant runtime.
v
is an element in the associated registry. Definition at line 138 of file RegisteredSet.h.
|
inline |
Returns the same as isMember() to use an RegisteredSet instance as filter function.
Definition at line 141 of file RegisteredSet.h.
|
inline |
Assignment operator.
Definition at line 167 of file RegisteredSet.h.
|
inline |
Returns the associated registry.
Definition at line 147 of file RegisteredSet.h.
|
inline |
Removes element v
from this set and return true
iff v
was previously present.
This operation has constant runtime. If the element is not contained in this set, nothing happens and false
is returned.
v
is an element in the associated registry. Definition at line 100 of file RegisteredSet.h.
|
inline |
Returns the number of elements in this set.
This operation has either linear or constant runtime, depending on SupportFastSizeQuery.
Definition at line 153 of file RegisteredSet.h.
|
private |
The list of elements contained in this set.
Definition at line 181 of file RegisteredSet.h.
|
private |
m_it[v] contains the list iterator pointing to v if v is contained in this set, or an invalid list iterator otherwise.
Definition at line 178 of file RegisteredSet.h.