![]() |
VOOZH | about |
Policy-Based Data Structures (PBDS) are advanced data structures provided by the GNU C++ STL extension. They include structures like ordered sets and maps with extra features - allowing operations like finding the k-th smallest element or the number of elements less than a given value in O(log n ) time.
It adds the element to the container if it doesn't already exist.
PBDS maintains elements in sorted order automatically.
10 20 30
erase() removes element form the container if it exists.
No error occurs if the element is not present.
10 30
Used to check whether an element is present.
20 is found
lower_bound(x) returns iterator to the first element ≥ x.
Similar to lower_bound in std::set.
20
upper_bound(x) returns iterator to the first element >x.
Useful in range queries.
30
It returns the number of elements in the container.
Size: 3
find_by_order(k) returns iterator to the k-th smallest element (0-indexed).
This is not available in std::set.
Size: 3
order_of_key(x) returns the number of elements strictly less than x.
Great for rank-based queries.