fix compare error
This commit is contained in:
@ -82,7 +82,12 @@ class priority_queue {
|
|||||||
*/
|
*/
|
||||||
void push(const T &e) {
|
void push(const T &e) {
|
||||||
Node *new_node = new Node(e);
|
Node *new_node = new Node(e);
|
||||||
|
try {
|
||||||
root = SkewMerge(root, new_node);
|
root = SkewMerge(root, new_node);
|
||||||
|
} catch (...) {
|
||||||
|
delete new_node;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
++node_count;
|
++node_count;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -111,6 +116,7 @@ class priority_queue {
|
|||||||
* clear the other priority_queue.
|
* clear the other priority_queue.
|
||||||
*/
|
*/
|
||||||
void merge(priority_queue &other) {
|
void merge(priority_queue &other) {
|
||||||
|
if (other.root == root) return;
|
||||||
root = SkewMerge(root, other.root);
|
root = SkewMerge(root, other.root);
|
||||||
node_count += other.node_count;
|
node_count += other.node_count;
|
||||||
other.root = nullptr;
|
other.root = nullptr;
|
||||||
|
Reference in New Issue
Block a user