Constant-time set operations. More...
#include <ogdf/basic/RegisteredSet.h>
Public Types | |
using | element_type = typename Registry::key_type |
using | list_type = List< element_type > |
using | registry_type = Registry |
Public Member Functions | |
RegisteredSet () | |
Creates an empty set associated with no registry. More... | |
RegisteredSet (const RegisteredSet ©) | |
RegisteredSet (const Registry &R) | |
Creates an empty set associated with registry R . More... | |
RegisteredSet (const Registry *R) | |
Creates an empty set associated with registry R . More... | |
RegisteredSet (RegisteredSet &&move) noexcept | |
list_type::const_iterator | begin () const |
void | clear () |
Removes all elements from this set. More... | |
bool | contains (element_type v) const |
Returns the same as isMember() 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... | |
RegisteredSet & | operator= (const RegisteredSet ©) |
RegisteredSet & | operator= (RegisteredSet &&move) noexcept |
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... | |
Protected Member Functions | |
void | keyAdded (typename Registry::key_type v) override |
Called by watched registry after a key has been added. More... | |
void | keyRemoved (typename Registry::key_type v) override |
Called by watched registry just before a key is deleted. More... | |
void | keysCleared () override |
Called by watched registry when its clear function is called, just before things are removed. More... | |
void | keysCopied (int toIndex, int fromIndex) override |
Called when an entry is copied from fromIndex to toIndex in all registered arrays. More... | |
void | keysSwapped (int index1, int index2) override |
Called when an entry is swapped between index1 and index2 in all registered arrays. More... | |
void | registrationChanged (const Registry *old) override |
Called after reregister() changed the observed instance. More... | |
Private Types | |
using | Obs = RegisteredObserver< Registry > |
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... | |
Friends | |
bool | operator!= (const RegisteredSet &lhs, const RegisteredSet &rhs) |
bool | operator== (const RegisteredSet &lhs, const RegisteredSet &rhs) |
Additional Inherited Members | |
![]() | |
RegisteredObserver ()=default | |
Constructs instance of RegisteredObserver class. More... | |
RegisteredObserver (const Registry *R) | |
const Registry * | getRegistry () const |
![]() | |
Observer ()=default | |
Constructs unregistered instance of Observer class. More... | |
Observer (const Observer ©)=delete | |
If you want to copy a subclass of Observer, call the default Observer() constructor and optionally also call reregister if it makes sense. More... | |
Observer (const Registry *R) | |
Observer (Observer &&move)=delete | |
If you want to move a subclass of Observer, call the default Observer() constructor and optionally also call reregister if it makes sense. More... | |
virtual | ~Observer () |
Destroys the instance, unregisters it from watched instance. More... | |
const Registry * | getObserved () const |
Observer & | operator= (const Observer ©)=delete |
Observer & | operator= (Observer &&move)=delete |
void | reregister (const Registry *obs) |
Associates observer instance with instance obs . 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. |
Definition at line 53 of file RegisteredSet.h.
using ogdf::RegisteredSet< Registry >::element_type = typename Registry::key_type |
Definition at line 58 of file RegisteredSet.h.
using ogdf::RegisteredSet< Registry >::list_type = List<element_type> |
Definition at line 59 of file RegisteredSet.h.
|
private |
Definition at line 54 of file RegisteredSet.h.
using ogdf::RegisteredSet< Registry >::registry_type = Registry |
Definition at line 57 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 registry R
.
Definition at line 69 of file RegisteredSet.h.
|
inlineexplicit |
Creates an empty set associated with no registry.
Definition at line 72 of file RegisteredSet.h.
|
inline |
Definition at line 74 of file RegisteredSet.h.
|
inlinenoexcept |
Definition at line 85 of file RegisteredSet.h.
|
inline |
Definition at line 183 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 143 of file RegisteredSet.h.
|
inline |
Returns the same as isMember()
Definition at line 166 of file RegisteredSet.h.
|
inline |
Returns a reference to the list of elements contained in this set.
Definition at line 172 of file RegisteredSet.h.
|
inline |
Definition at line 185 of file RegisteredSet.h.
|
inline |
Reinitializes the set. Associates the set with no registry.
Definition at line 96 of file RegisteredSet.h.
|
inline |
Reinitializes the set. Associates the set with registry R
.
Definition at line 102 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 111 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 163 of file RegisteredSet.h.
|
inlineoverrideprotectedvirtual |
Called by watched registry after a key has been added.
Implements ogdf::RegisteredObserver< Registry >.
Definition at line 217 of file RegisteredSet.h.
|
inlineoverrideprotectedvirtual |
Called by watched registry just before a key is deleted.
Implements ogdf::RegisteredObserver< Registry >.
Definition at line 215 of file RegisteredSet.h.
|
inlineoverrideprotectedvirtual |
Called by watched registry when its clear function is called, just before things are removed.
Implements ogdf::RegisteredObserver< Registry >.
Definition at line 227 of file RegisteredSet.h.
|
inlineoverrideprotectedvirtual |
Called when an entry is copied from fromIndex
to toIndex
in all registered arrays.
Implements ogdf::RegisteredObserver< Registry >.
Definition at line 223 of file RegisteredSet.h.
|
inlineoverrideprotectedvirtual |
Called when an entry is swapped between index1
and index2
in all registered arrays.
Implements ogdf::RegisteredObserver< Registry >.
Definition at line 219 of file RegisteredSet.h.
|
inline |
Returns the same as isMember() to use an RegisteredSet instance as filter function.
Definition at line 169 of file RegisteredSet.h.
|
inline |
Definition at line 76 of file RegisteredSet.h.
|
inlinenoexcept |
Definition at line 87 of file RegisteredSet.h.
|
inline |
Returns the associated registry.
Definition at line 175 of file RegisteredSet.h.
|
inlineoverrideprotectedvirtual |
Called after reregister() changed the observed instance.
Reimplemented from ogdf::Observer< Registry, RegisteredObserver< Registry > >.
Definition at line 229 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 125 of file RegisteredSet.h.
|
inline |
Returns the number of elements in this set.
This operation has constant runtime.
Definition at line 181 of file RegisteredSet.h.
|
friend |
Definition at line 202 of file RegisteredSet.h.
|
friend |
Definition at line 187 of file RegisteredSet.h.
|
private |
The list of elements contained in this set.
Definition at line 212 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 209 of file RegisteredSet.h.