|
Flow
Documentation for the Flow C++ Library
|
A disjoint union set that uses path compression and union by rank. More...
#include <flow_disjoint_set.h>
Classes | |
| struct | Node |
Public Types | |
| using | value_type = T |
| using | reference = T& |
| using | const_reference = const T& |
| using | pointer = T* |
| using | const_pointer = const T* |
| using | iterator = T* |
| using | const_iterator = const T* |
| using | difference_type = std::ptrdiff_t |
| using | allocator_type = std::allocator_traits<Allocator>::template rebind_alloc<Node> |
| using | container_type = Vector<Node, allocator_type> |
Public Member Functions | |
| constexpr | DisjointSet () noexcept(noexcept(container_type())) |
| constexpr | DisjointSet (const allocator_type &allocator) noexcept(noexcept(container_type(allocator))) |
| constexpr | DisjointSet (const DisjointSet &)=default |
| constexpr | DisjointSet (const DisjointSet &rhs, const allocator_type &allocator) |
| constexpr | DisjointSet (DisjointSet &&)=default |
| constexpr | DisjointSet (DisjointSet &&rhs, const allocator_type &allocator) noexcept(noexcept(container_type(std::move(rhs.data_), allocator))) |
| template<std::forward_iterator It> | |
| constexpr | DisjointSet (It first, It last, const allocator_type &allocator={}) |
| Iterator range constructor. | |
| constexpr | DisjointSet (std::initializer_list< T > list, const allocator_type &allocator={}) |
| Initializer list constructor. | |
| ~DisjointSet ()=default | |
| allocator_type | get_allocator () const noexcept |
| constexpr std::size_t | size () const |
| Return the number of input elements. | |
| constexpr std::size_t | groupSize () const |
| Return the number of group. | |
| constexpr bool | empty () const |
| Check if the disjoint set is empty. | |
| void | reserve (std::size_t n) |
| Reserve enough memory for at least n elements. | |
| constexpr void | add (const T &value) |
| Add an element to the disjoint set. | |
| constexpr void | add (T &&value) |
| Add an element to the disjoint set. | |
| constexpr const T & | operator[] (std::size_t i) const |
| Get the value of the i-th element. | |
| constexpr T & | operator[] (std::size_t i) |
| Get the value of the i-th element. | |
| constexpr std::size_t | find (std::size_t i) |
| Find the group id of the i-th node. Perform path compression along the way. | |
| constexpr bool | isSameGroup (std::size_t i, std::size_t j) |
| Check if the i-th element and the j-th element are in the same group. | |
| constexpr bool | merge (std::size_t i, std::size_t j) |
| Merge the i-th element's group with the j-th element's group. Internally, it unions them by ranking. | |
Private Attributes | |
| std::size_t | groupSize_ |
| container_type | data_ |
A disjoint union set that uses path compression and union by rank.
| T | |
| Allocator |
Definition at line 10 of file flow_disjoint_set.h.
| using flow::DisjointSet< T, Allocator >::allocator_type = std::allocator_traits<Allocator>::template rebind_alloc<Node> |
Definition at line 26 of file flow_disjoint_set.h.
| using flow::DisjointSet< T, Allocator >::const_iterator = const T* |
Definition at line 24 of file flow_disjoint_set.h.
| using flow::DisjointSet< T, Allocator >::const_pointer = const T* |
Definition at line 22 of file flow_disjoint_set.h.
| using flow::DisjointSet< T, Allocator >::const_reference = const T& |
Definition at line 20 of file flow_disjoint_set.h.
| using flow::DisjointSet< T, Allocator >::container_type = Vector<Node, allocator_type> |
Definition at line 27 of file flow_disjoint_set.h.
| using flow::DisjointSet< T, Allocator >::difference_type = std::ptrdiff_t |
Definition at line 25 of file flow_disjoint_set.h.
| using flow::DisjointSet< T, Allocator >::iterator = T* |
Definition at line 23 of file flow_disjoint_set.h.
| using flow::DisjointSet< T, Allocator >::pointer = T* |
Definition at line 21 of file flow_disjoint_set.h.
| using flow::DisjointSet< T, Allocator >::reference = T& |
Definition at line 19 of file flow_disjoint_set.h.
| using flow::DisjointSet< T, Allocator >::value_type = T |
Definition at line 18 of file flow_disjoint_set.h.
|
inlineconstexprnoexcept |
Definition at line 34 of file flow_disjoint_set.h.
References data_, and groupSize_.
Referenced by DisjointSet(), DisjointSet(), DisjointSet(), and DisjointSet().
|
inlineexplicitconstexprnoexcept |
Definition at line 39 of file flow_disjoint_set.h.
References data_, and groupSize_.
|
constexprdefault |
References DisjointSet().
|
inlineconstexpr |
Definition at line 45 of file flow_disjoint_set.h.
References data_, DisjointSet(), and groupSize_.
|
constexprdefault |
References DisjointSet().
|
inlineconstexprnoexcept |
Definition at line 50 of file flow_disjoint_set.h.
References data_, DisjointSet(), and groupSize_.
|
inlineexplicitconstexpr |
Iterator range constructor.
| first | Iterator to first element. |
| last | Iterator to one-past-last element. |
| alloc | Allocator. |
Definition at line 80 of file flow_disjoint_set.h.
|
inlineexplicitconstexpr |
Initializer list constructor.
| list | Initializer list. |
| alloc | Allocator. |
Definition at line 92 of file flow_disjoint_set.h.
|
default |
|
inlineconstexpr |
Add an element to the disjoint set.
| value | The element. |
Definition at line 131 of file flow_disjoint_set.h.
References data_, and groupSize_.
|
inlineconstexpr |
Add an element to the disjoint set.
| value | The element. |
Definition at line 138 of file flow_disjoint_set.h.
References data_, and groupSize_.
|
inlineconstexpr |
Check if the disjoint set is empty.
Definition at line 119 of file flow_disjoint_set.h.
References data_.
|
inlineconstexpr |
Find the group id of the i-th node. Perform path compression along the way.
| i | Index |
Definition at line 161 of file flow_disjoint_set.h.
Referenced by find(), isSameGroup(), and merge().
|
inlinenoexcept |
Definition at line 99 of file flow_disjoint_set.h.
References data_.
|
inlineconstexpr |
Return the number of group.
Definition at line 113 of file flow_disjoint_set.h.
References groupSize_.
|
inlineconstexpr |
|
inlineconstexpr |
Merge the i-th element's group with the j-th element's group. Internally, it unions them by ranking.
| i | The first index. |
| j | The second index. |
Definition at line 182 of file flow_disjoint_set.h.
References data_, find(), and groupSize_.
|
inlineconstexpr |
Get the value of the i-th element.
| i | index |
Definition at line 153 of file flow_disjoint_set.h.
References data_.
|
inlineconstexpr |
Get the value of the i-th element.
| i | index |
Definition at line 146 of file flow_disjoint_set.h.
References data_.
|
inline |
Reserve enough memory for at least n elements.
| n | The reserved size. |
Definition at line 125 of file flow_disjoint_set.h.
References data_.
|
inlineconstexpr |
Return the number of input elements.
Definition at line 107 of file flow_disjoint_set.h.
References data_.
|
private |
Definition at line 31 of file flow_disjoint_set.h.
Referenced by add(), add(), DisjointSet(), DisjointSet(), DisjointSet(), DisjointSet(), empty(), find(), get_allocator(), merge(), operator[](), operator[](), reserve(), and size().
|
private |
Definition at line 30 of file flow_disjoint_set.h.
Referenced by add(), add(), DisjointSet(), DisjointSet(), DisjointSet(), DisjointSet(), groupSize(), and merge().