|
| | Sum_Segment_Tree (const size_t num, const T &init_val=T()) |
| | Construct with num elements, all equal to init_val.
|
| |
| | Sum_Segment_Tree (std::initializer_list< T > il) |
| | Construct from an initializer list.
|
| |
| | Sum_Segment_Tree (const Array< T > &values) |
| | Construct from an Array<T>.
|
| |
| | Sum_Segment_Tree (const std::vector< T > &values) |
| | Construct from a std::vector<T>.
|
| |
| | Sum_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, Aleph::plus< T > oper=Aleph::plus< T >()) |
| | Construct a segment tree with num elements, all equal to init_val.
|
| |
| | Gen_Segment_Tree (std::initializer_list< T > il, const T &id, Aleph::plus< T > oper=Aleph::plus< T >()) |
| | Construct from an initializer list.
|
| |
| | Gen_Segment_Tree (const Array< T > &values, const T &id, Aleph::plus< T > oper=Aleph::plus< T >()) |
| | Construct from an Array<T>.
|
| |
| | Gen_Segment_Tree (const std::vector< T > &values, const T &id, Aleph::plus< T > oper=Aleph::plus< T >()) |
| | Construct from a std::vector<T>.
|
| |
| | Gen_Segment_Tree (const DynList< T > &values, const T &id, Aleph::plus< T > oper=Aleph::plus< 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< Aleph::plus< 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< Aleph::plus< 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< Aleph::plus< T > & >(), std::declval< Aleph::plus< T > & >()))) |
| | Swap this tree with other in O(1).
|
| |
template<
typename T>
struct Aleph::Sum_Segment_Tree< T >
Sum Segment Tree for range sum queries with point updates.
Convenient specialisation of Gen_Segment_Tree using plus<T> with identity T() (zero for arithmetic types).
- Template Parameters
-
- Example
T query(const size_t l, const size_t r) const
Range query over [l, r].
void update(const size_t i, const T &delta)
Point update: a[i] = Op(a[i], delta).
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.
Sum Segment Tree for range sum queries with point updates.
Definition at line 463 of file tpl_segment_tree.H.