fix compare error

This commit is contained in:
2024-03-10 15:34:52 +00:00
parent 205219ddf3
commit 4bed4fd96a

View File

@ -82,7 +82,12 @@ class priority_queue {
*/
void push(const T &e) {
Node *new_node = new Node(e);
try {
root = SkewMerge(root, new_node);
} catch (...) {
delete new_node;
throw;
}
++node_count;
}
/**
@ -111,6 +116,7 @@ class priority_queue {
* clear the other priority_queue.
*/
void merge(priority_queue &other) {
if (other.root == root) return;
root = SkewMerge(root, other.root);
node_count += other.node_count;
other.root = nullptr;