|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Map from node pointers to their positions, built once and never modified afterwards. More...
#include <Negative_Cycles.H>
Public Member Functions | |
| Node_Index (const size_t n) | |
| void | insert (Node *node, const size_t position) |
Record that node (not yet inserted) is at position. | |
| size_t | find (const Node *node) const |
Position of node. | |
Static Private Member Functions | |
| static size_t | slot_of (const Node *node) noexcept |
Private Attributes | |
| Array< Node * > | keys_ |
| Array< size_t > | positions_ |
| size_t | mask_ = 0 |
Map from node pointers to their positions, built once and never modified afterwards.
Open addressing with linear probing over two Arrays whose capacity is the first power of two not below 2 * n, so the load factor never exceeds one half and a lookup takes about 1.5 probes. Pointers are mixed with the SplitMix64 finalizer, a bijection of the 64-bit pointer, before the low bits select the slot: allocation patterns (nodes at a fixed stride, for instance) cannot cluster. Compared with an AVL map (DynMapTree) it makes four allocations instead of one per node, and a lookup does not chase pointers.
| Node | Node type; pointers to it are the keys and are never null. |
Definition at line 847 of file Negative_Cycles.H.
|
inlineexplicit |
| [in] | n | Number of nodes that will be inserted. |
| std::overflow_error | If the capacity does not fit size_t. |
Definition at line 866 of file Negative_Cycles.H.
References ah_overflow_error_if, Aleph::negative_cycles_detail::Node_Index< Node >::keys_, Aleph::negative_cycles_detail::Node_Index< Node >::mask_, and Aleph::negative_cycles_detail::Node_Index< Node >::positions_.
|
inline |
Position of node.
| std::domain_error | If node is null or was not inserted. A null key has to be rejected before probing: it would match the first free slot and answer with a position of nobody. |
Definition at line 896 of file Negative_Cycles.H.
References ah_domain_error_if, Aleph::negative_cycles_detail::Node_Index< Node >::keys_, Aleph::negative_cycles_detail::Node_Index< Node >::mask_, Aleph::negative_cycles_detail::Node_Index< Node >::positions_, and Aleph::negative_cycles_detail::Node_Index< Node >::slot_of().
Referenced by Aleph::negative_cycles_detail::index_graph().
|
inline |
Record that node (not yet inserted) is at position.
| std::domain_error | If node is null (null marks a free slot). |
Definition at line 881 of file Negative_Cycles.H.
References ah_domain_error_if, Aleph::negative_cycles_detail::Node_Index< Node >::keys_, Aleph::negative_cycles_detail::Node_Index< Node >::mask_, Aleph::negative_cycles_detail::Node_Index< Node >::positions_, and Aleph::negative_cycles_detail::Node_Index< Node >::slot_of().
Referenced by Aleph::negative_cycles_detail::index_graph().
|
inlinestaticprivatenoexcept |
Definition at line 853 of file Negative_Cycles.H.
Referenced by Aleph::negative_cycles_detail::Node_Index< Node >::find(), and Aleph::negative_cycles_detail::Node_Index< Node >::insert().
|
private |
Definition at line 849 of file Negative_Cycles.H.
Referenced by Aleph::negative_cycles_detail::Node_Index< Node >::Node_Index(), Aleph::negative_cycles_detail::Node_Index< Node >::find(), and Aleph::negative_cycles_detail::Node_Index< Node >::insert().
|
private |
Definition at line 851 of file Negative_Cycles.H.
Referenced by Aleph::negative_cycles_detail::Node_Index< Node >::Node_Index(), Aleph::negative_cycles_detail::Node_Index< Node >::find(), and Aleph::negative_cycles_detail::Node_Index< Node >::insert().
|
private |
Definition at line 850 of file Negative_Cycles.H.
Referenced by Aleph::negative_cycles_detail::Node_Index< Node >::Node_Index(), Aleph::negative_cycles_detail::Node_Index< Node >::find(), and Aleph::negative_cycles_detail::Node_Index< Node >::insert().