shz.core.queue.p.ConcurrentMaxPQueue Maven / Gradle / Ivy
package shz.core.queue.p;
import java.util.Comparator;
public final class ConcurrentMaxPQueue extends ConcurrentRBBSTPQueue {
private static final long serialVersionUID = -5074168243264342412L;
public ConcurrentMaxPQueue(Comparator super E> comparator) {
super(comparator);
}
public static ConcurrentMaxPQueue of(Comparator super E> comparator) {
return new ConcurrentMaxPQueue<>(comparator);
}
@Override
protected E peek0() {
if (root == null) return null;
Node h = root;
while (h.right != null) h = h.right;
return h.e;
}
@Override
protected Node delTop(Node h) {
if (isRed(h.left)) h = rotateRight(h);
if (h.right == null) return h.left;
if (!isRed(h.right) && !isRed(h.right.left)) h = moveRedRight(h);
h.right = delTop(h.right);
return balance(h);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy