Skip to content

Commit e91cb11

Browse files
committed
simple skeleton struct for priority queue
1 parent 4183a07 commit e91cb11

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
pub use inefficient_sort::*;
2+
pub use priority_queue::*;
23
pub use sample_sort::*;
34
pub use selection::*;
45

56
mod util;
67

78
mod inefficient_sort;
9+
mod priority_queue;
810
mod sample_sort;
911
mod selection;

src/priority_queue.rs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use std::cmp::Reverse;
2+
use std::collections::BinaryHeap;
3+
use mpi::topology::SystemCommunicator;
4+
use rand::{Rng, thread_rng};
5+
use rand::rngs::ThreadRng;
6+
7+
pub struct ParallelPriorityQueue<'a> {
8+
communicator: &'a SystemCommunicator,
9+
bin_heap: BinaryHeap<Reverse<u64>>,
10+
rng: ThreadRng,
11+
}
12+
13+
impl <'a> ParallelPriorityQueue<'a> {
14+
15+
pub fn new(comm: &'a SystemCommunicator) -> ParallelPriorityQueue<'a> {
16+
ParallelPriorityQueue {
17+
communicator: comm,
18+
bin_heap: BinaryHeap::new(),
19+
rng: thread_rng(),
20+
}
21+
}
22+
23+
/// insert an element into the local queue
24+
fn local_insert(&mut self, e: u64) {
25+
self.bin_heap.push(Reverse(e))
26+
}
27+
28+
/// Insert a constant amount of elements per processing unit. Insertion will redistribute the items among
29+
/// processors to ensure uniform data distribution
30+
pub fn insert(&mut self, elements: &[u64]) {
31+
todo!("not yet implemented");
32+
}
33+
34+
/// Delete the p smallest elements in the priority queue and distribute them among all p processing units.
35+
pub fn delete_min(&mut self) -> u64 {
36+
todo!("not yet implemented")
37+
}
38+
}

0 commit comments

Comments
 (0)