use std::{
cmp::{Ordering, Reverse},
collections::BinaryHeap,
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ExpirationQueueEntry {
pub(crate) expiration: i64,
pub(crate) key: Vec<u8>,
}
impl PartialOrd for ExpirationQueueEntry {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for ExpirationQueueEntry {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
self
.expiration
.cmp(&other.expiration)
.then_with(|| self.key.cmp(&other.key))
}
}
pub type ExpirationQueue = BinaryHeap<Reverse<ExpirationQueueEntry>>;