Skip to content

Commit 1c6f43a

Browse files
committed
v0.2.1, revamped README
1 parent bf762c9 commit 1c6f43a

File tree

4 files changed

+93
-17
lines changed

4 files changed

+93
-17
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ script:
1212
matrix:
1313
allow_failures:
1414
- rust: nightly
15+
- rust: beta # clippy currently has a bug on beta
1516
fast_finish: true

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "contest-algorithms"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
authors = ["Aram Ebtekar"]
55
edition = "2018"
66

README.md

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ To my delight, I found that Rust eliminates entire classes of bugs, while reduci
2323

2424
Some contest sites and online judges that support Rust:
2525
- [Codeforces](https://codeforces.com)
26+
- [AtCoder](https://atcoder.jp)
2627
- [Kattis](https://open.kattis.com/help/rust)
2728
- [SPOJ](https://www.spoj.com/)
2829
- [LeetCode](https://leetcode.com/contest)
2930
- [HackerRank](https://www.hackerrank.com/contests)
31+
- [Timus](http://acm.timus.ru/help.aspx?topic=rust)
3032

3133
The following support pre-2018 versions of Rust:
3234
- [Google Kick Start and Code Jam](https://codingcompetitions.withgoogle.com)
33-
- [AtCoder](https://atcoder.jp)
34-
- [Timus](http://acm.timus.ru/help.aspx?topic=rust)
3535

3636
For help in getting started, you may check out [some of my past submissions](https://codeforces.com/contest/1168/submission/55200038).
3737

@@ -41,17 +41,83 @@ My other goal is to appeal to developers who feel limited by ancient (yet still
4141

4242
Rather than try to persuade you with words, this repository aims to show by example. If you're new to Rust, see [Jim Blandy's *Why Rust?*](http://www.oreilly.com/programming/free/files/why-rust.pdf) for a brief introduction, or just [dive in!](https://doc.rust-lang.org/book/)
4343

44-
## Contents
45-
46-
- [Basic graph representations](src/graph/mod.rs): adjacency lists, disjoint set union
47-
- [Elementary graph algorithms](src/graph/util.rs): minimum spanning tree, Euler path, Dijkstra's algorithm, DFS iteration
48-
- [Connected components](src/graph/connectivity.rs): 2-edge-, 2-vertex- and strongly connected components, bridges, articulation points, topological sort, 2-SAT
49-
- [Network flows](src/graph/flow.rs): Dinic's blocking flow, Hopcroft-Karp bipartite matching, min cost max flow
50-
- [Number theory](src/math/mod.rs): canonical solution to Bezout's identity, Miller's primality test
51-
- [FFT](src/math/fft.rs): fast Fourier transform, number theoretic transform, convolution
52-
- [Arithmetic](src/math/num.rs): rational and complex numbers, linear algebra, safe modular arithmetic
53-
- [Ordering algorithms](src/order.rs): binary search, mergesort, coordinate compression, online convex hull trick
54-
- [Associative range query](src/range_query): static and dynamic ARQ trees (a.k.a. segtrees), Mo's query square root decomposition
55-
- [Scanner](src/scanner.rs): utility for reading input data ergonomically
56-
- [String processing](src/string_proc.rs): Knuth-Morris-Pratt and Aho-Corasick string matching, suffix array, Manacher's linear-time palindrome search
44+
# Contents
45+
46+
## [Graphs](src/graph/)
47+
48+
### [Graph representations](src/graph/mod.rs)
49+
50+
- Integer index-based adjacency list representation
51+
- Disjoint set union
52+
53+
### [Elementary graph algorithms](src/graph/util.rs)
54+
55+
- Euler path and tour
56+
- Kruskal's minimum spanning tree
57+
- Dijkstra's single-source shortest paths
58+
- DFS pre-order traversal
59+
60+
### [Connected components](src/graph/connectivity.rs)
61+
62+
- Connected components
63+
- Strongly connected components
64+
- Bridges and 2-edge-connected components
65+
- Articulation points and 2-vertex-connected components
66+
- Topological sort
67+
- 2-SAT solver
68+
69+
### [Network flows](src/graph/flow.rs)
70+
71+
- Dinic's blocking maximum flow
72+
- Hopcroft-Karp bipartite matching
73+
- Minimum cost maximum flow
74+
75+
## [Math](src/math/)
76+
77+
### [Number theory](src/math/mod.rs)
78+
79+
- Greatest common divisor
80+
- Canonical solution to Bezout's identity
81+
- Miller's primality test
82+
83+
### [Generic FFT](src/math/fft.rs)
84+
85+
- Fast Fourier transform
86+
- Number theoretic transform
87+
- Convolution
88+
89+
### [Arithmetic](src/math/num.rs)
90+
91+
- Rational numbers
92+
- Complex numbers
93+
- Linear algebra
94+
- Safe modular arithmetic
95+
96+
## [Ordering and search](src/order.rs)
97+
98+
- Comparator for `PartialOrd`
99+
- Binary search: drop-in replacements for C++ `lower_bound()`/`upper_bound()`
100+
- Merge and mergesort
101+
- Coordinate compression
102+
- Online convex hull trick (update and query the upper envelope of a set of lines)
103+
104+
## [Associative range query](src/range_query)
105+
106+
- Statically allocated binary indexed ARQ tree (a.k.a. generic segtree with lazy propagation)
107+
- Dynamically allocated ARQ tree, optionally sparse and persistent
108+
- Mo's algorithm (a.k.a. query square root decomposition)
109+
110+
## [Scanner](src/scanner.rs)
111+
112+
- Utility for reading input data ergonomically
113+
- File and standard I/O examples
114+
115+
## [String processing](src/string_proc.rs)
116+
117+
- Generic trie
118+
- Knuth-Morris-Pratt single-pattern string matching
119+
- Aho-Corasick multi-pattern string matching
120+
- Suffix array: O(n log n) construction using counting sort
121+
- Longest common prefix
122+
- Manacher's linear-time palindrome search
57123

src/order.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
//! Miscellaneous algorithms.
1+
//! Ordering algorithms.
22
33
/// A comparator on partially ordered elements, that panics if they are incomparable
4+
///
5+
/// # Example
6+
///
7+
/// ```
8+
/// use contest_algorithms::order::asserting_cmp;
9+
/// let mut vec = vec![4.5, -1.7, 1.2];
10+
/// vec.sort_unstable_by(asserting_cmp);
11+
/// assert_eq!(vec, vec![-1.7, 1.2, 4.5]);
12+
/// ```
413
pub fn asserting_cmp<T: PartialOrd>(a: &T, b: &T) -> std::cmp::Ordering {
514
a.partial_cmp(b).expect("Comparing incomparable elements")
615
}

0 commit comments

Comments
 (0)