Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Struct representation of the treap. More...
Public Member Functions | |
Treap () | |
Initialization. | |
void | update (int x) |
Update the subtree size of the node. | |
void | rotate (int &x, int t) |
Rotate without breaking the property of BST. | |
void | _insert (int &x, int k) |
Insert a value into the specified subtree (internal method) | |
void | _erase (int &x, int k) |
Erase a value from the specified subtree (internal method) | |
int | _get_k_th (int &x, int k) |
Find the KTH largest value (internal method) | |
int | _get_rank (int x, int k) |
Query the rank of specified element (internal method) | |
int | get_predecessor (int k) |
Get the predecessor node of element k. | |
int | get_next (int k) |
Get the successor node of element k. | |
void | insert (int k) |
Insert element (External method) | |
void | erase (int k) |
Erase element (External method) | |
int | get_k_th (int k) |
Get the KTH largest value (External method) | |
int | get_rank (int k) |
Get the rank of specified element (External method) | |
Public Attributes | |
int | root = 0 |
root of the treap | |
int | treapCnt = 0 |
Total number of current nodes in the treap. | |
std::array< int, maxNode > | key = {} |
Node identifier. | |
std::array< int, maxNode > | priority = {} |
Random priority. | |
std::array< std::array< int, 2 >, maxNode > | childs |
std::array< int, maxNode > | cnt |
Maintains the subtree size for ranking query. | |
std::array< int, maxNode > | size = {} |
The number of copies per node. | |
Struct representation of the treap.
|
inline |
Initialization.
|
inline |
Erase a value from the specified subtree (internal method)
x | Erase from the subtree of node x (Usually x=root) |
k | Key to erase |
|
inline |
Find the KTH largest value (internal method)
x | Query the subtree of node x (Usually x=root) |
k | The queried rank |
|
inline |
Query the rank of specified element (internal method)
x | Query the subtree of node x (Usually x=root) |
k | The queried element |
|
inline |
Insert a value into the specified subtree (internal method)
x | Insert into the subtree of node x (Usually x=root) |
k | Key to insert |
|
inline |
Erase element (External method)
k | Key to erase |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
std::array<std::array<int, 2>, maxNode> data_structures::treap::Treap::childs |
[i][0] represents the left child of node i, and [i][1] represents the right
std::array<int, maxNode> data_structures::treap::Treap::cnt |
Maintains the subtree size for ranking query.
std::array<int, maxNode> data_structures::treap::Treap::key = {} |
Node identifier.
std::array<int, maxNode> data_structures::treap::Treap::priority = {} |
Random priority.
std::array<int, maxNode> data_structures::treap::Treap::size = {} |
The number of copies per node.