Skip to content

Commit db931c0

Browse files
authored
Merge pull request #39 from orxfun/test-&-advertise-MSRV
test and advertise MSRV
2 parents 075423b + 062b143 commit db931c0

3 files changed

Lines changed: 22 additions & 25 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ name: Rust
22

33
on:
44
push:
5-
branches: [ "main" ]
65
pull_request:
7-
branches: [ "main" ]
86

97
env:
108
CARGO_TERM_COLOR: always

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "orx-priority-queue"
3-
version = "1.7.0"
3+
version = "1.8.0"
44
edition = "2024"
55
authors = ["orxfun <orx.ugur.arikan@gmail.com>"]
66
readme = "README.md"
@@ -19,7 +19,6 @@ impl_all = ["impl_priority_queue"]
1919
[dependencies]
2020
priority-queue = { version = "2.3", optional = true }
2121

22-
2322
[[bench]]
2423
name = "basic_queue"
2524
harness = false

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Priority queue traits and high performance d-ary heap implementations.
88

9-
> **no-std**: This crate supports **no-std**; however, *std* is added as a default feature. Please include with **no-default-features** for no-std use cases: `cargo add orx-priority-queue --no-default-features`.
9+
> **no-std**: This crate supports **no-std**; however, _std_ is added as a default feature. Please include with **no-default-features** for no-std use cases: `cargo add orx-priority-queue --no-default-features`.
1010
1111
## A. Priority Queue Traits
1212

@@ -19,8 +19,9 @@ See [DecreaseKey](https://github.com/orxfun/orx-priority-queue/blob/main/docs/De
1919
## B. d-ary Heap Implementations
2020

2121
d-ary implementations are generalizations of the binary heap; i.e., binary heap is a special case where `D=2`. It is advantageous to have a parametrized d; as for instance, in the benchmarks defined here, `D=4` outperforms `D=2`.
22-
* With a large d: number of per level comparisons increases while the tree depth becomes smaller.
23-
* With a small d: each level requires fewer comparisons while the tree with the same number of nodes is deeper.
22+
23+
- With a large d: number of per level comparisons increases while the tree depth becomes smaller.
24+
- With a small d: each level requires fewer comparisons while the tree with the same number of nodes is deeper.
2425

2526
Further, three categories of d-ary heap implementations are introduced.
2627

@@ -32,8 +33,8 @@ This is the basic d-ary heap implementing `PriorityQueue`. It is the default cho
3233

3334
This is a d-ary heap paired up with a positions array and implements `PriorityQueueDecKey`.
3435

35-
* It requires the nodes to implement `HasIndex` trait which is nothing but `fn index(&self) -> usize`. Note that `usize`, `u64`, etc., already implements `HasIndex`.
36-
* Further, it requires to know the maximum index that is expected to enter the queue. In other words, candidates are expected to come from a closed set.
36+
- It requires the nodes to implement `HasIndex` trait which is nothing but `fn index(&self) -> usize`. Note that `usize`, `u64`, etc., already implements `HasIndex`.
37+
- Further, it requires to know the maximum index that is expected to enter the queue. In other words, candidates are expected to come from a closed set.
3738

3839
Once these conditions are satisfied, it **performs significantly faster** than the alternative decrease key queues.
3940

@@ -51,30 +52,29 @@ This is the most general decrease-key queue that provides the open-set flexibili
5152

5253
In addition, queue implementations are provided in this crate for the following external data structures:
5354

54-
* `std::collections::BinaryHeap<(N, K)>` implements only `PriorityQueue<N, K>`,
55-
* `priority_queue:PriorityQueue<N, K>` implements both `PriorityQueue<N, K>` and `PriorityQueueDecKey<N, K>`
56-
* requires `--features impl_priority_queue`
57-
* or `--features impl_all`
55+
- `std::collections::BinaryHeap<(N, K)>` implements only `PriorityQueue<N, K>`,
56+
- `priority_queue:PriorityQueue<N, K>` implements both `PriorityQueue<N, K>` and `PriorityQueueDecKey<N, K>`
57+
- requires `--features impl_priority_queue`
58+
- or `--features impl_all`
5859

5960
This allows to use all the queue implementations interchangeably and pick the one fitting best to the use case.
6061

6162
### Performance & Benchmarks
6263

63-
*You may find the details of the benchmarks at [benches](https://github.com/orxfun/orx-priority-queue/blob/main/benches) folder.*
64+
_You may find the details of the benchmarks at [benches](https://github.com/orxfun/orx-priority-queue/blob/main/benches) folder._
6465

6566
<img src="https://raw.githubusercontent.com/orxfun/orx-priority-queue/main/docs/bench_results.PNG" alt="https://raw.githubusercontent.com/orxfun/orx-priority-queue/main/docs/bench_results.PNG" />
6667

6768
The table above summarizes the benchmark results of basic operations on basic queues, and queues allowing decrease key operations.
6869

69-
* In the first benchmark, we repeatedly call `push` and `pop` operations on a queue while maintaining an average length of 100000:
70-
* We observe that `BinaryHeap` (`DaryHeap<_, _, 2>`) performs almost the same as the standard binary heap.
71-
* Experiments on different values of d shows that `QuaternaryHeap` (D=4) outperforms both binary heaps.
72-
* Further increasing D to 8 does not improve performance.
73-
* Finally, we repeat the experiments with `BinaryHeap` and `QuaternaryHeap` using the specialized [`push_then_pop`](https://docs.rs/orx-priority-queue/latest/orx_priority_queue/trait.PriorityQueue.html#tymethod.push_then_pop) operation. Note that this operation further doubles the performance, and hence, should be used whenever it fits the use case.
74-
* In the second benchmark, we add [`decrease_key_or_push`](https://docs.rs/orx-priority-queue/latest/orx_priority_queue/trait.PriorityQueueDecKey.html#method.decrease_key_or_push) calls to the operations. Standard binary heap is excluded since it cannot implement `PriorityQueueDecKey`.
75-
* We observe that `DaryHeapOfIndices` significantly outperforms other decrease key queues.
76-
* Among `BinaryHeapOfIndices` and `QuaternaryHeapOfIndices`, the latter with D=4 again performs better.
77-
70+
- In the first benchmark, we repeatedly call `push` and `pop` operations on a queue while maintaining an average length of 100000:
71+
- We observe that `BinaryHeap` (`DaryHeap<_, _, 2>`) performs almost the same as the standard binary heap.
72+
- Experiments on different values of d shows that `QuaternaryHeap` (D=4) outperforms both binary heaps.
73+
- Further increasing D to 8 does not improve performance.
74+
- Finally, we repeat the experiments with `BinaryHeap` and `QuaternaryHeap` using the specialized [`push_then_pop`](https://docs.rs/orx-priority-queue/latest/orx_priority_queue/trait.PriorityQueue.html#tymethod.push_then_pop) operation. Note that this operation further doubles the performance, and hence, should be used whenever it fits the use case.
75+
- In the second benchmark, we add [`decrease_key_or_push`](https://docs.rs/orx-priority-queue/latest/orx_priority_queue/trait.PriorityQueueDecKey.html#method.decrease_key_or_push) calls to the operations. Standard binary heap is excluded since it cannot implement `PriorityQueueDecKey`.
76+
- We observe that `DaryHeapOfIndices` significantly outperforms other decrease key queues.
77+
- Among `BinaryHeapOfIndices` and `QuaternaryHeapOfIndices`, the latter with D=4 again performs better.
7878

7979
## C. Examples
8080

@@ -175,8 +175,8 @@ test_priority_queue_deckey(QuaternaryHeapWithMap::default());
175175

176176
You may see below two implementations of the Dijkstra's shortest path algorithm: one using a `PriorityQueue` and the other with a `PriorityQueueDecKey`. Please note the following:
177177

178-
* Priority queue traits allow us to be generic over queues. Therefore, we are able to implement the algorithm once that works for any queue implementation.
179-
* The second implementation with a decrease key queue pushes some of the bookkeeping to the queue, and arguably leads to a cleaner algorithm implementation.
178+
- Priority queue traits allow us to be generic over queues. Therefore, we are able to implement the algorithm once that works for any queue implementation.
179+
- The second implementation with a decrease key queue pushes some of the bookkeeping to the queue, and arguably leads to a cleaner algorithm implementation.
180180

181181
```rust
182182
use orx_priority_queue::*;

0 commit comments

Comments
 (0)