Skip to content

Commit 802a753

Browse files
committed
give up docmatic
1 parent 2dcc864 commit 802a753

File tree

5 files changed

+62
-53
lines changed

5 files changed

+62
-53
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
9+
### Added
10+
11+
* Quickstart section in the doc

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ serde = { version = "1.0", optional = true, features = ["derive"] }
1515

1616
[dev-dependencies]
1717
serde_json = "1.0.39"
18-
docmatic = "0.1"
1918

2019
[badges]
2120
travis-ci = { repository = "sekineh/binary-heap-plus-rs" }

README.md

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,6 @@ It supports the following features and still maintains backward compatibility.
1313

1414
This crate requires Rust 1.26 or later.
1515

16-
# Quick start
17-
18-
## Max/Min Heap
19-
For max/min heap, `BiaryHeap::from_vec()` is the most versatile way to create a heap.
20-
21-
```rust
22-
extern crate binary_heap_plus;
23-
use binary_heap_plus::*;
24-
25-
// max heap
26-
let mut h: BinaryHeap<i32> = BinaryHeap::from_vec(vec![]);
27-
// max heap with initial capacity
28-
let mut h: BinaryHeap<i32> = BinaryHeap::from_vec(Vec::with_capacity(16));
29-
// max heap from iterator
30-
let mut h: BinaryHeap<i32> = BinaryHeap::from_vec((0..42).collect());
31-
assert_eq!(h.pop(), Some(41));
32-
```
33-
Min heap requires type annotation.
34-
```rust
35-
extern crate binary_heap_plus;
36-
use binary_heap_plus::*;
37-
38-
// min heap
39-
let mut h: BinaryHeap<i32, MinComparator> = BinaryHeap::from_vec(vec![]);
40-
// min heap with initial capacity
41-
let mut h: BinaryHeap<i32, MinComparator> = BinaryHeap::from_vec(Vec::with_capacity(16));
42-
// min heap from iterator
43-
let mut h: BinaryHeap<i32, MinComparator> = BinaryHeap::from_vec((0..42).collect());
44-
assert_eq!(h.pop(), Some(0));
45-
```
46-
47-
## Custom Heap
48-
For custom heap, `BinaryHeap::from_vec_cmp()` works in a similar way to max/min heap. The only difference is that you add the comparator closure with apropriate signature.
49-
```rust
50-
extern crate binary_heap_plus;
51-
use binary_heap_plus::*;
52-
53-
// custom heap: ordered by second value (_.1) of the tuples; min first
54-
let mut h = BinaryHeap::from_vec_cmp(
55-
vec![(1, 5), (3, 2), (2, 3)],
56-
|a: &(i32, i32), b: &(i32, i32)| b.1.cmp(&a.1), // comparator closure here
57-
);
58-
assert_eq!(h.pop(), Some((3, 2)));
59-
```
60-
6116
## Note on `BinaryHeap::from_vec()`
6217

6318
Currently, the `From<Vec<T>>` trait is implemented for max heap only.

src/lib.rs

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,56 @@
44
//! * Heaps other than max heap.
55
//! * Optional `serde` feature.
66
//!
7+
//! # Quick start
8+
//!
9+
//! ## Max/Min Heap
10+
//!
11+
//! For max heap, `BiaryHeap::from_vec()` is the most versatile way to create a heap.
12+
//!
13+
//! ```rust
14+
//! // extern crate binary_heap_plus;
15+
//! use binary_heap_plus::*;
16+
//!
17+
//! // max heap
18+
//! let mut h: BinaryHeap<i32> = BinaryHeap::from_vec(vec![]);
19+
//! // max heap with initial capacity
20+
//! let mut h: BinaryHeap<i32> = BinaryHeap::from_vec(Vec::with_capacity(16));
21+
//! // max heap from iterator
22+
//! let mut h: BinaryHeap<i32> = BinaryHeap::from_vec((0..42).collect());
23+
//! assert_eq!(h.pop(), Some(41));
24+
//! ```
25+
//!
26+
//! Min heap is similar, but requires type annotation.
27+
//!
28+
//! ```rust
29+
//! // extern crate binary_heap_plus;
30+
//! use binary_heap_plus::*;
31+
//!
32+
//! // min heap
33+
//! let mut h: BinaryHeap<i32, MinComparator> = BinaryHeap::from_vec(vec![]);
34+
//! // min heap with initial capacity
35+
//! let mut h: BinaryHeap<i32, MinComparator> = BinaryHeap::from_vec(Vec::with_capacity(16));
36+
//! // min heap from iterator
37+
//! let mut h: BinaryHeap<i32, MinComparator> = BinaryHeap::from_vec((0..42).collect());
38+
//! assert_eq!(h.pop(), Some(0));
39+
//! ```
40+
//!
41+
//! ## Custom Heap
42+
//!
43+
//! For custom heap, `BinaryHeap::from_vec_cmp()` works in a similar way to max/min heap. The only difference is that you add the comparator closure with apropriate signature.
44+
//!
45+
//! ```rust
46+
//! // extern crate binary_heap_plus;
47+
//! use binary_heap_plus::*;
48+
//!
49+
//! // custom heap: ordered by second value (_.1) of the tuples; min first
50+
//! let mut h = BinaryHeap::from_vec_cmp(
51+
//! vec![(1, 5), (3, 2), (2, 3)],
52+
//! |a: &(i32, i32), b: &(i32, i32)| b.1.cmp(&a.1), // comparator closure here
53+
//! );
54+
//! assert_eq!(h.pop(), Some((3, 2)));
55+
//! ```
56+
//!
757
//! # Constructers
858
//!
959
//! ## Generic methods to create different kind of heaps from initial `vec` data.
@@ -23,7 +73,7 @@
2373
//! assert_eq!(heap.pop(), Some(1));
2474
//!
2575
//! // custom-sort heap
26-
//! let mut heap = BinaryHeap::from_vec_cmp(vec![1,5,3], FnComparator(|a: &i32, b: &i32| b.cmp(a)));
76+
//! let mut heap = BinaryHeap::from_vec_cmp(vec![1,5,3], |a: &i32, b: &i32| b.cmp(a));
2777
//! assert_eq!(heap.pop(), Some(1));
2878
//!
2979
//! // custom-key heap

tests/docmatic.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)