|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Li Chao tree for min line queries on an integral x-domain. More...
#include <DP_Optimizations.H>
Classes | |
| struct | Line |
| Affine line y = m*x + b. More... | |
| struct | Node |
Public Member Functions | |
| Li_Chao_Tree (const T x_left, const T x_right) | |
| Li_Chao_Tree (const Li_Chao_Tree &other)=default | |
| Copy the domain and the lines of another tree. | |
| Li_Chao_Tree (Li_Chao_Tree &&other) noexcept | |
| Take the lines of another tree, which is left empty over the same domain. | |
| Li_Chao_Tree & | operator= (const Li_Chao_Tree &other)=default |
| Copy the domain and the lines of another tree. | |
| Li_Chao_Tree & | operator= (Li_Chao_Tree &&other) noexcept |
| Exchange this tree with another, which is left with the previous domain and lines of this one. | |
| void | swap (Li_Chao_Tree &other) noexcept |
| Exchange in O(1) the domains and the lines of this tree and another. | |
| bool | is_empty () const noexcept |
| size_t | node_count () const noexcept |
| void | clear () |
| void | add_line (const T slope, const T intercept) |
| T | query (const T x) const |
Private Member Functions | |
| size_t | new_node (const Line &line) |
| void | add_line_impl (const size_t idx, const T l, const T r, Line line) |
| T | query_impl (const size_t idx, const T l, const T r, const T x) const |
Private Attributes | |
| T | x_left_ |
| T | x_right_ |
| Array< Node > | nodes_ |
| size_t | root_ = NIL |
Static Private Attributes | |
| static constexpr size_t | NIL = std::numeric_limits<size_t>::max() |
Li Chao tree for min line queries on an integral x-domain.
Supports arbitrary line insertion order and O(log X) min queries where X is the domain length.
| T | Signed integral numeric type for coordinates. |
Definition at line 569 of file DP_Optimizations.H.
|
inline |
Definition at line 659 of file DP_Optimizations.H.
References ah_domain_error_if, Aleph::Li_Chao_Tree< T >::x_left_, and Aleph::Li_Chao_Tree< T >::x_right_.
|
default |
Copy the domain and the lines of another tree.
| other | tree to copy. |
|
inlinenoexcept |
Take the lines of another tree, which is left empty over the same domain.
The implicit move took the nodes but copied the index of the root: the moved-from tree was not empty without nodes, and its add_line() and query() threw out_of_range.
| other | tree to move from. |
Definition at line 679 of file DP_Optimizations.H.
|
inline |
Definition at line 729 of file DP_Optimizations.H.
References Aleph::Li_Chao_Tree< T >::add_line_impl(), Aleph::intercept(), Aleph::Li_Chao_Tree< T >::new_node(), Aleph::Li_Chao_Tree< T >::NIL, Aleph::Li_Chao_Tree< T >::root_, Aleph::Li_Chao_Tree< T >::x_left_, and Aleph::Li_Chao_Tree< T >::x_right_.
Referenced by Moved_From_Case< Li_Chao_Tree< long > >::make(), Aleph::min_weighted_squared_distance_1d(), TEST(), TEST(), and Moved_From_Case< Li_Chao_Tree< long > >::use().
|
inlineprivate |
Definition at line 610 of file DP_Optimizations.H.
References Aleph::Li_Chao_Tree< T >::add_line_impl(), l, Aleph::Li_Chao_Tree< T >::new_node(), Aleph::Li_Chao_Tree< T >::NIL, Aleph::Li_Chao_Tree< T >::nodes_, r, and Aleph::Li_Chao_Tree< T >::Line::value_at().
Referenced by Aleph::Li_Chao_Tree< T >::add_line(), and Aleph::Li_Chao_Tree< T >::add_line_impl().
|
inline |
Definition at line 722 of file DP_Optimizations.H.
References Aleph::Li_Chao_Tree< T >::NIL, Aleph::Li_Chao_Tree< T >::nodes_, Aleph::Li_Chao_Tree< T >::root_, and Aleph::Array< T >::swap().
Referenced by Moved_From_Case< Li_Chao_Tree< long > >::use().
|
inlinenoexcept |
Definition at line 713 of file DP_Optimizations.H.
References Aleph::Li_Chao_Tree< T >::NIL, and Aleph::Li_Chao_Tree< T >::root_.
Referenced by Moved_From_Case< Li_Chao_Tree< long > >::is_empty(), and Moved_From_Case< Li_Chao_Tree< long > >::use().
|
inlineprivate |
Definition at line 604 of file DP_Optimizations.H.
References Aleph::Li_Chao_Tree< T >::NIL, and Aleph::Li_Chao_Tree< T >::nodes_.
Referenced by Aleph::Li_Chao_Tree< T >::add_line(), and Aleph::Li_Chao_Tree< T >::add_line_impl().
|
inlinenoexcept |
Definition at line 717 of file DP_Optimizations.H.
References Aleph::Li_Chao_Tree< T >::nodes_.
Referenced by Moved_From_Case< Li_Chao_Tree< long > >::is_empty().
|
default |
Copy the domain and the lines of another tree.
| other | tree to copy. |
|
inlinenoexcept |
Exchange this tree with another, which is left with the previous domain and lines of this one.
| other | tree to move from. |
Definition at line 695 of file DP_Optimizations.H.
References Aleph::Li_Chao_Tree< T >::swap().
|
inline |
Definition at line 740 of file DP_Optimizations.H.
References ah_out_of_range_error_if, ah_runtime_error_if, Aleph::Li_Chao_Tree< T >::NIL, Aleph::Li_Chao_Tree< T >::query_impl(), Aleph::Li_Chao_Tree< T >::root_, Aleph::Li_Chao_Tree< T >::x_left_, and Aleph::Li_Chao_Tree< T >::x_right_.
Referenced by Aleph::min_weighted_squared_distance_1d(), TEST(), TEST(), and Moved_From_Case< Li_Chao_Tree< long > >::use().
|
inlineprivate |
Definition at line 642 of file DP_Optimizations.H.
References Aleph::and, l, Aleph::Li_Chao_Tree< T >::NIL, Aleph::Li_Chao_Tree< T >::nodes_, Aleph::Li_Chao_Tree< T >::query_impl(), and r.
Referenced by Aleph::Li_Chao_Tree< T >::query(), and Aleph::Li_Chao_Tree< T >::query_impl().
|
inlinenoexcept |
Exchange in O(1) the domains and the lines of this tree and another.
| other | tree to exchange with. |
Definition at line 705 of file DP_Optimizations.H.
References Aleph::Li_Chao_Tree< T >::nodes_, Aleph::Li_Chao_Tree< T >::root_, Aleph::Li_Chao_Tree< T >::x_left_, and Aleph::Li_Chao_Tree< T >::x_right_.
Referenced by Aleph::Li_Chao_Tree< T >::operator=().
|
staticconstexprprivate |
Definition at line 597 of file DP_Optimizations.H.
Referenced by Aleph::Li_Chao_Tree< T >::add_line(), Aleph::Li_Chao_Tree< T >::add_line_impl(), Aleph::Li_Chao_Tree< T >::clear(), Aleph::Li_Chao_Tree< T >::is_empty(), Aleph::Li_Chao_Tree< T >::new_node(), Aleph::Li_Chao_Tree< T >::query(), and Aleph::Li_Chao_Tree< T >::query_impl().
|
private |
|
private |
Definition at line 602 of file DP_Optimizations.H.
Referenced by Aleph::Li_Chao_Tree< T >::add_line(), Aleph::Li_Chao_Tree< T >::clear(), Aleph::Li_Chao_Tree< T >::is_empty(), Aleph::Li_Chao_Tree< T >::query(), and Aleph::Li_Chao_Tree< T >::swap().
|
private |
Definition at line 599 of file DP_Optimizations.H.
Referenced by Aleph::Li_Chao_Tree< T >::Li_Chao_Tree(), Aleph::Li_Chao_Tree< T >::add_line(), Aleph::Li_Chao_Tree< T >::query(), and Aleph::Li_Chao_Tree< T >::swap().
|
private |
Definition at line 600 of file DP_Optimizations.H.
Referenced by Aleph::Li_Chao_Tree< T >::Li_Chao_Tree(), Aleph::Li_Chao_Tree< T >::add_line(), Aleph::Li_Chao_Tree< T >::query(), and Aleph::Li_Chao_Tree< T >::swap().