Scaffold IndexedQueue and IndexedBinaryHeap

This commit is contained in:
Michael Bradley 2025-01-11 22:38:32 +13:00
parent 64030bd349
commit fec9ccffc6
Signed by: MichaelBradley
SSH key fingerprint: SHA256:cj/YZ5VT+QOKncqSkx+ibKTIn0Obg7OIzwzl9BL8EO8
3 changed files with 116 additions and 4 deletions

View file

@ -0,0 +1,53 @@
use std::{collections::HashMap, hash::Hash};
use crate::backing::{containers::Pair, indexed::IndexedBacking, pure::PureBacking};
pub struct IndexedBinaryHeap<D: Hash + Clone + Send + Sync, P: PartialOrd + Clone + Send + Sync> {
data: Vec<Pair<D, P>>,
indices: HashMap<D, usize>,
}
impl<D: Hash + Clone + Send + Sync, P: PartialOrd + Clone + Send + Sync> IndexedBinaryHeap<D, P> {
pub fn new() -> Self {
Self {
data: Vec::new(),
indices: HashMap::new(),
}
}
}
impl<D: Hash + Clone + Send + Sync, P: PartialOrd + Clone + Send + Sync> FromIterator<Pair<D, P>>
for IndexedBinaryHeap<D, P>
{
fn from_iter<T: IntoIterator<Item = Pair<D, P>>>(iter: T) -> Self {
todo!()
}
}
impl<D: Hash + Clone + Send + Sync, P: PartialOrd + Clone + Send + Sync> PureBacking<Pair<D, P>>
for IndexedBinaryHeap<D, P>
{
fn add(&mut self, item: Pair<D, P>) {
todo!()
}
fn pop(&mut self) -> Option<Pair<D, P>> {
todo!()
}
fn len(&self) -> usize {
todo!()
}
}
impl<D: Hash + Clone + Send + Sync, P: PartialOrd + Clone + Send + Sync> IndexedBacking<D, P>
for IndexedBinaryHeap<D, P>
{
fn update(&mut self, data: D, priority: P) -> bool {
todo!()
}
fn remove(&mut self, data: D) -> bool {
todo!()
}
}