|
|
| SegmentTree ()=default |
| | Construct an empty segment tree.
|
| |
| | SegmentTree (std::span< const T > values, Compare compare=Compare()) |
| | Build an iterative segment tree over values.
|
| |
| std::size_t | size_impl () const |
| | Return the number of indexed values.
|
| |
| T | value_at_impl (std::size_t position) const |
| | Return the value at an indexed position.
|
| |
| std::size_t | arg_min_impl (std::size_t left, std::size_t right) const |
| | Return the first minimum position in [left, right).
|
| |
| std::size_t | memory_usage_bytes_impl () const |
| | Return owned auxiliary memory usage in bytes.
|
| |
| std::size_t | size () const |
| | Number of indexed values.
|
| |
| bool | empty () const |
| | Whether the indexed array is empty.
|
| |
| std::size_t | arg_min (std::size_t left, std::size_t right) const |
| | Return the first minimum position in [left, right).
|
| |
| Value | range_min (std::size_t left, std::size_t right) const |
| | Return the minimum value in [left, right).
|
| |
| std::size_t | memory_usage_bytes () const |
| | Return owned auxiliary memory usage in bytes when implemented.
|
| |
template<class T, class Compare = std::less<T>, class Index = std::size_t>
class pixie::rmq::SegmentTree< T, Compare, Index >
Static iterative segment-tree RMQ baseline.
Stores the index of the first minimum for each segment in a flat binary tree. Query time is O(log n), build time is O(n), and storage is O(n) indices. The indexed values are not owned and must outlive this object.
- Template Parameters
-
| T | Value type in the indexed array. |
| Compare | Strict weak ordering used to choose minima. |
| Index | Unsigned integer type used for stored positions. |
template<class T, class Compare = std::less<T>, class Index = std::size_t>
| std::size_t pixie::rmq::SegmentTree< T, Compare, Index >::arg_min_impl |
( |
std::size_t | left, |
|
|
std::size_t | right ) const |
|
inline |
Return the first minimum position in [left, right).
Answers in O(log n) by walking the flat iterative segment tree. Ties return the smaller position.
- Parameters
-
| left | First position in the query range. |
| right | One past the last position in the query range. |
- Returns
- Zero-based position of the first range minimum, or
npos.