|
| | 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 &&other) noexcept(std::is_nothrow_move_constructible_v< Array< T > > and std::is_nothrow_move_constructible_v< T > and std::is_nothrow_move_constructible_v< Aleph::plus< T > >) |
| | Take the elements of another tree, which is left empty.
|
| |
| Gen_Segment_Tree & | operator= (const Gen_Segment_Tree &)=default |
| |
| Gen_Segment_Tree & | operator= (Gen_Segment_Tree &&other) noexcept(noexcept(swap(other))) |
| | Exchange this tree with another, which is left with the previous elements of this one.
|
| |
| 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(std::is_nothrow_swappable_v< T > and std::is_nothrow_swappable_v< 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
assert(st.
query(0, 4) == 14);
assert(st.
query(0, 4) == 24);
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).
Sum Segment Tree for range sum queries with point updates.
Definition at line 512 of file tpl_segment_tree.H.