Skip to content

Commit

Permalink
Merge pull request #21 from orxfun/type-alias-quaternary
Browse files Browse the repository at this point in the history
type alias quaternary
  • Loading branch information
orxfun authored Aug 29, 2024
2 parents d2c91ea + 2f3d416 commit 1adc3de
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "orx-priority-queue"
version = "1.3.0"
version = "1.4.0"
edition = "2021"
authors = ["orxfun <[email protected]>"]
description = "Priority queue traits and high performance d-ary heap implementations."
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ test_priority_queue(DaryHeap::<usize, f64, D>::default());
test_priority_queue(DaryHeapWithMap::<usize, f64, D>::default());
test_priority_queue(DaryHeapOfIndices::<usize, f64, D>::with_index_bound(100));

// type aliases for common heaps: Binary or Quarternary
// type aliases for common heaps: Binary or Quaternary
test_priority_queue(BinaryHeap::default());
test_priority_queue(QuarternaryHeapWithMap::default());
test_priority_queue(QuaternaryHeapWithMap::default());
test_priority_queue(BinaryHeapOfIndices::with_index_bound(100));
```

Expand Down Expand Up @@ -163,9 +163,9 @@ const D: usize = 4;
test_priority_queue_deckey(DaryHeapOfIndices::<usize, f64, D>::with_index_bound(100));
test_priority_queue_deckey(DaryHeapWithMap::<usize, f64, D>::default());

// type aliases for common heaps: Binary or Quarternary
// type aliases for common heaps: Binary or Quaternary
test_priority_queue_deckey(BinaryHeapOfIndices::with_index_bound(100));
test_priority_queue_deckey(QuarternaryHeapWithMap::default());
test_priority_queue_deckey(QuaternaryHeapWithMap::default());
```

### C.2. Usage in Dijkstra's Shortest Path
Expand Down Expand Up @@ -280,7 +280,7 @@ let mut pq = BinaryHeap::new();
assert_eq!(Some(5), dijkstras_with_basic_pq(&graph, &mut pq, 0, 3));
assert_eq!(None, dijkstras_with_basic_pq(&graph, &mut pq, 3, 1));

let mut pq = QuarternaryHeap::new();
let mut pq = QuaternaryHeap::new();
assert_eq!(Some(5), dijkstras_with_basic_pq(&graph, &mut pq, 0, 3));
assert_eq!(None, dijkstras_with_basic_pq(&graph, &mut pq, 3, 1));

Expand Down
12 changes: 6 additions & 6 deletions src/dary/daryheap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{positions::none::HeapPositionsNone, PriorityQueue};
/// Type alias for `DaryHeap<N, K, 2>`; see [`DaryHeap`] for details.
pub type BinaryHeap<N, K> = DaryHeap<N, K, 2>;
/// Type alias for `DaryHeap<N, K, 4>`; see [`DaryHeap`] for details.
pub type QuarternaryHeap<N, K> = DaryHeap<N, K, 4>;
pub type QuaternaryHeap<N, K> = DaryHeap<N, K, 4>;

/// A d-ary heap which implements `PriorityQueue`, but not `PriorityQueueDecKey`.
///
Expand Down Expand Up @@ -50,10 +50,10 @@ pub type QuarternaryHeap<N, K> = DaryHeap<N, K, 4>;
/// // using type aliases to simplify signatures
/// test_priority_queue(BinaryHeap::default());
/// test_priority_queue(BinaryHeap::with_capacity(16));
/// test_priority_queue(QuarternaryHeap::default());
/// test_priority_queue(QuarternaryHeap::with_capacity(16));
/// test_priority_queue(QuarternaryHeap::default());
/// test_priority_queue(QuarternaryHeap::with_capacity(16));
/// test_priority_queue(QuaternaryHeap::default());
/// test_priority_queue(QuaternaryHeap::with_capacity(16));
/// test_priority_queue(QuaternaryHeap::default());
/// test_priority_queue(QuaternaryHeap::with_capacity(16));
/// ```
#[derive(Clone, Debug)]
pub struct DaryHeap<N, K, const D: usize = 2>
Expand Down Expand Up @@ -133,7 +133,7 @@ where
/// ```
/// use orx_priority_queue::*;
///
/// let mut queue = QuarternaryHeapWithMap::default();
/// let mut queue = QuaternaryHeapWithMap::default();
/// queue.push("x", 42);
/// queue.push("y", 7);
/// queue.push("z", 99);
Expand Down
12 changes: 6 additions & 6 deletions src/dary/daryheap_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
/// Type alias for `DaryHeapOfIndices<N, K, 2>`; see [`DaryHeapOfIndices`] for details.
pub type BinaryHeapOfIndices<N, K> = DaryHeapOfIndices<N, K, 2>;
/// Type alias for `DaryHeapOfIndices<N, K, 4>`; see [`DaryHeapOfIndices`] for details.
pub type QuarternaryHeapOfIndices<N, K> = DaryHeapOfIndices<N, K, 4>;
pub type QuaternaryHeapOfIndices<N, K> = DaryHeapOfIndices<N, K, 4>;

/// A d-ary heap which implements both `PriorityQueue` and `PriorityQueueDecKey`.
///
Expand Down Expand Up @@ -86,8 +86,8 @@ pub type QuarternaryHeapOfIndices<N, K> = DaryHeapOfIndices<N, K, 4>;
/// test_priority_queue(DaryHeapOfIndices::<_, _, 4>::with_index_bound(32));
/// // using type aliases to simplify signatures
/// test_priority_queue(BinaryHeapOfIndices::with_index_bound(16));
/// test_priority_queue(QuarternaryHeapOfIndices::with_index_bound(16));
/// test_priority_queue(QuarternaryHeapOfIndices::with_index_bound(16));
/// test_priority_queue(QuaternaryHeapOfIndices::with_index_bound(16));
/// test_priority_queue(QuaternaryHeapOfIndices::with_index_bound(16));
/// ```
///
/// ## Heap as a `PriorityQueueDecKey`
Expand Down Expand Up @@ -130,8 +130,8 @@ pub type QuarternaryHeapOfIndices<N, K> = DaryHeapOfIndices<N, K, 4>;
/// test_priority_queue_deckey(DaryHeapOfIndices::<_, _, 3>::with_index_bound(32));
/// // using type aliases to simplify signatures
/// test_priority_queue_deckey(BinaryHeapOfIndices::with_index_bound(16));
/// test_priority_queue_deckey(QuarternaryHeapOfIndices::with_index_bound(16));
/// test_priority_queue_deckey(QuarternaryHeapOfIndices::with_index_bound(16));
/// test_priority_queue_deckey(QuaternaryHeapOfIndices::with_index_bound(16));
/// test_priority_queue_deckey(QuaternaryHeapOfIndices::with_index_bound(16));
/// ```
#[derive(Clone, Debug)]
pub struct DaryHeapOfIndices<N, K, const D: usize = 2>
Expand Down Expand Up @@ -205,7 +205,7 @@ where
/// ```
/// use orx_priority_queue::*;
///
/// let mut queue = QuarternaryHeapWithMap::default();
/// let mut queue = QuaternaryHeapWithMap::default();
/// queue.push("x", 42);
/// queue.push("y", 7);
/// queue.push("z", 99);
Expand Down
20 changes: 10 additions & 10 deletions src/dary/daryheap_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
/// Type alias for `DaryHeapWithMap<N, K, 2>`; see [`DaryHeapWithMap`] for details.
pub type BinaryHeapWithMap<N, K> = DaryHeapWithMap<N, K, 2>;
/// Type alias for `DaryHeapWithMap<N, K, 4>`; see [`DaryHeapWithMap`] for details.
pub type QuarternaryHeapWithMap<N, K> = DaryHeapWithMap<N, K, 4>;
pub type QuaternaryHeapWithMap<N, K> = DaryHeapWithMap<N, K, 4>;

/// A d-ary heap which implements both `PriorityQueue` and `PriorityQueueDecKey`.
///
Expand Down Expand Up @@ -66,10 +66,10 @@ pub type QuarternaryHeapWithMap<N, K> = DaryHeapWithMap<N, K, 4>;
/// // using type aliases to simplify signatures
/// test_priority_queue(BinaryHeapWithMap::default());
/// test_priority_queue(BinaryHeapWithMap::with_capacity(16));
/// test_priority_queue(QuarternaryHeapWithMap::default());
/// test_priority_queue(QuarternaryHeapWithMap::with_capacity(16));
/// test_priority_queue(QuarternaryHeapWithMap::default());
/// test_priority_queue(QuarternaryHeapWithMap::with_capacity(16));
/// test_priority_queue(QuaternaryHeapWithMap::default());
/// test_priority_queue(QuaternaryHeapWithMap::with_capacity(16));
/// test_priority_queue(QuaternaryHeapWithMap::default());
/// test_priority_queue(QuaternaryHeapWithMap::with_capacity(16));
/// ```
///
/// ## Heap as a `PriorityQueueDecKey`
Expand Down Expand Up @@ -114,10 +114,10 @@ pub type QuarternaryHeapWithMap<N, K> = DaryHeapWithMap<N, K, 4>;
/// // using type aliases to simplify signatures
/// test_priority_queue_deckey(BinaryHeapWithMap::default());
/// test_priority_queue_deckey(BinaryHeapWithMap::with_capacity(16));
/// test_priority_queue_deckey(QuarternaryHeapWithMap::default());
/// test_priority_queue_deckey(QuarternaryHeapWithMap::with_capacity(16));
/// test_priority_queue_deckey(QuarternaryHeapWithMap::default());
/// test_priority_queue_deckey(QuarternaryHeapWithMap::with_capacity(16));
/// test_priority_queue_deckey(QuaternaryHeapWithMap::default());
/// test_priority_queue_deckey(QuaternaryHeapWithMap::with_capacity(16));
/// test_priority_queue_deckey(QuaternaryHeapWithMap::default());
/// test_priority_queue_deckey(QuaternaryHeapWithMap::with_capacity(16));
/// ```
#[derive(Debug, Clone)]
pub struct DaryHeapWithMap<N, K, const D: usize = 2>
Expand Down Expand Up @@ -185,7 +185,7 @@ where
/// ```
/// use orx_priority_queue::*;
///
/// let mut queue = QuarternaryHeapWithMap::default();
/// let mut queue = QuaternaryHeapWithMap::default();
/// queue.push("x", 42);
/// queue.push("y", 7);
/// queue.push("z", 99);
Expand Down
2 changes: 1 addition & 1 deletion src/dary/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ where
/// ```
/// use orx_priority_queue::*;
///
/// let mut queue = QuarternaryHeapWithMap::default();
/// let mut queue = QuaternaryHeapWithMap::default();
/// queue.push("x", 42);
/// queue.push("y", 7);
/// queue.push("z", 99);
Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@
//! test_priority_queue(DaryHeapWithMap::<usize, f64, D>::default());
//! test_priority_queue(DaryHeapOfIndices::<usize, f64, D>::with_index_bound(100));
//!
//! // type aliases for common heaps: Binary or Quarternary
//! // type aliases for common heaps: Binary or Quaternary
//! test_priority_queue(BinaryHeap::default());
//! test_priority_queue(QuarternaryHeapWithMap::default());
//! test_priority_queue(QuaternaryHeapWithMap::default());
//! test_priority_queue(BinaryHeapOfIndices::with_index_bound(100));
//! ```
//!
Expand Down Expand Up @@ -163,9 +163,9 @@
//! test_priority_queue_deckey(DaryHeapOfIndices::<usize, f64, D>::with_index_bound(100));
//! test_priority_queue_deckey(DaryHeapWithMap::<usize, f64, D>::default());
//!
//! // type aliases for common heaps: Binary or Quarternary
//! // type aliases for common heaps: Binary or Quaternary
//! test_priority_queue_deckey(BinaryHeapOfIndices::with_index_bound(100));
//! test_priority_queue_deckey(QuarternaryHeapWithMap::default());
//! test_priority_queue_deckey(QuaternaryHeapWithMap::default());
//! ```
//!
//! ### C.2. Usage in Dijkstra's Shortest Path
Expand Down Expand Up @@ -280,7 +280,7 @@
//! assert_eq!(Some(5), dijkstras_with_basic_pq(&graph, &mut pq, 0, 3));
//! assert_eq!(None, dijkstras_with_basic_pq(&graph, &mut pq, 3, 1));
//!
//! let mut pq = QuarternaryHeap::new();
//! let mut pq = QuaternaryHeap::new();
//! assert_eq!(Some(5), dijkstras_with_basic_pq(&graph, &mut pq, 0, 3));
//! assert_eq!(None, dijkstras_with_basic_pq(&graph, &mut pq, 3, 1));
//!
Expand Down Expand Up @@ -335,9 +335,9 @@ mod priority_queue;
mod priority_queue_deckey;

pub use crate::priority_queue::PriorityQueue;
pub use dary::daryheap::{BinaryHeap, DaryHeap, QuarternaryHeap};
pub use dary::daryheap_index::{BinaryHeapOfIndices, DaryHeapOfIndices, QuarternaryHeapOfIndices};
pub use dary::daryheap_map::{BinaryHeapWithMap, DaryHeapWithMap, QuarternaryHeapWithMap};
pub use dary::daryheap::{BinaryHeap, DaryHeap, QuaternaryHeap};
pub use dary::daryheap_index::{BinaryHeapOfIndices, DaryHeapOfIndices, QuaternaryHeapOfIndices};
pub use dary::daryheap_map::{BinaryHeapWithMap, DaryHeapWithMap, QuaternaryHeapWithMap};
pub use has_index::HasIndex;
pub use node_key_ref::NodeKeyRef;
pub use priority_queue_deckey::{
Expand Down
4 changes: 2 additions & 2 deletions src/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ where
/// ```
/// use orx_priority_queue::*;
///
/// let mut queue = QuarternaryHeap::default();
/// let mut queue = QuaternaryHeap::default();
/// assert!(queue.is_empty());
///
/// queue.push("wisdom", 42);
Expand Down Expand Up @@ -83,7 +83,7 @@ where
/// ```
/// use orx_priority_queue::*;
///
/// let mut queue = QuarternaryHeap::default();
/// let mut queue = QuaternaryHeap::default();
/// assert!(queue.is_empty());
///
/// queue.push(0, 12.0);
Expand Down

0 comments on commit 1adc3de

Please sign in to comment.