Scaffold IndexedQueue and IndexedBinaryHeap
This commit is contained in:
parent
64030bd349
commit
fec9ccffc6
3 changed files with 116 additions and 4 deletions
53
src/backing/indexed/binary_heap.rs
Normal file
53
src/backing/indexed/binary_heap.rs
Normal 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!()
|
||||
}
|
||||
}
|
|
@ -1,4 +1,8 @@
|
|||
/// Data structures for the "indexed" min-queues, supporting priority updates and arbitrary removals, but no duplicates
|
||||
mod binary_heap;
|
||||
|
||||
pub use binary_heap::IndexedBinaryHeap;
|
||||
|
||||
use super::{containers::Pair, pure::PureBacking};
|
||||
|
||||
/// A data structure usable for backing an "indexed" queue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue