|
| | Max_Segment_Tree (const size_t num, const T &init_val=std::numeric_limits< T >::lowest()) |
| | Construct with num elements, all equal to init_val.
|
| |
| | Max_Segment_Tree (std::initializer_list< T > il) |
| | Construct from an initializer list.
|
| |
| | Max_Segment_Tree (const Array< T > &values) |
| | Construct from an Array<T>.
|
| |
| | Max_Segment_Tree (const std::vector< T > &values) |
| | Construct from a std::vector<T>.
|
| |
| | Max_Segment_Tree (const DynList< T > &values) |
| | Construct from a DynList<T>.
|
| |
| | Gen_Segment_Tree (const size_t num, const T &init_val, const T &id, Max_Op< T > oper=Max_Op< T >()) |
| | Construct a segment tree with num elements, all equal to init_val.
|
| |
| | Gen_Segment_Tree (std::initializer_list< T > il, const T &id, Max_Op< T > oper=Max_Op< T >()) |
| | Construct from an initializer list.
|
| |
| | Gen_Segment_Tree (const Array< T > &values, const T &id, Max_Op< T > oper=Max_Op< T >()) |
| | Construct from an Array<T>.
|
| |
| | Gen_Segment_Tree (const std::vector< T > &values, const T &id, Max_Op< T > oper=Max_Op< T >()) |
| | Construct from a std::vector<T>.
|
| |
| | Gen_Segment_Tree (const DynList< T > &values, const T &id, Max_Op< T > oper=Max_Op< T >()) |
| | Construct from a DynList<T>.
|
| |
| | Gen_Segment_Tree (const Gen_Segment_Tree &)=default |
| |
| | Gen_Segment_Tree (Gen_Segment_Tree &&) noexcept(std::is_nothrow_move_constructible_v< Array< T > > and std::is_nothrow_move_constructible_v< Max_Op< T > >)=default |
| |
| Gen_Segment_Tree & | operator= (const Gen_Segment_Tree &)=default |
| |
| Gen_Segment_Tree & | operator= (Gen_Segment_Tree &&) noexcept(std::is_nothrow_move_assignable_v< Array< T > > and std::is_nothrow_move_assignable_v< Max_Op< T > >)=default |
| |
| void | update (const size_t i, const T &delta) |
| | Point update: a[i] = Op(a[i], delta).
|
| |
| void | set (const size_t i, const T &val) |
| | Set a[i] = val.
|
| |
| T | query (const size_t l, const size_t r) const |
| | Range query over [l, r].
|
| |
| T | get (const size_t i) const |
| | Retrieve the value a[i].
|
| |
| constexpr size_t | size () const noexcept |
| | Number of logical elements.
|
| |
| constexpr bool | is_empty () const noexcept |
| | True if the tree contains no elements.
|
| |
| Array< T > | values () const |
| | Reconstruct all original values into an Array.
|
| |
| void | swap (Gen_Segment_Tree &other) noexcept(noexcept(std::swap(std::declval< T & >(), std::declval< T & >())) and noexcept(std::swap(std::declval< Max_Op< T > & >(), std::declval< Max_Op< T > & >()))) |
| | Swap this tree with other in O(1).
|
| |
template<std::totally_ordered T>
struct Aleph::Max_Segment_Tree< T >
Max Segment Tree for range maximum queries with point updates.
Convenient specialisation of Gen_Segment_Tree using Max_Op<T> with identity numeric_limits<T>::lowest().
- Template Parameters
-
| T | a totally ordered type with numeric_limits support. |
- Note
- This structure supports point updates and range maximum queries. For static range max queries with O(1) queries, prefer
Max_Sparse_Table.
- Example
void set(const size_t i, const T &val)
Set a[i] = val.
T query(const size_t l, const size_t r) const
Range query over [l, r].
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Max Segment Tree for range maximum queries with point updates.
Definition at line 611 of file tpl_segment_tree.H.