- [stack, queue, deque] just use `Vec`, `VecDeque` with `match`, `if let`, `while let` to ensure not null.
- [heap] another implement (std::collections::BinaryHeap)
- [linkedlist] another implement (std::collections::LinkedList)
- [avl tree]
- [red black tree]
- [trie] TODO: hashmap version?
- [disjoint set]
- [segment tree]
print debug:
- file
- line
- stringify
- type
- value
NOTE: use dbg! if your do not need to know the type!
timeit!(100, (0..1000).into_iter().sum::<i32>());
timeit!(10, {
let mut _sum = 0;
for i in 0..1000 {
_sum += i;
}
});
timeit!(dbg!("hello world!"));
let mut timer = Timer::new()
timer.stop() // print time elapsed from new() to now
timer.diff() // print time elapsed from last stop()/diff() to now
let iter = (0..101).into_iter();
let n = iter.len();
let mut bar = ProgressBar::new(n);
for i in iter {
bar.goto(i);
thread::sleep(Duration::from_millis(50));
}
bar.quit();
for _ in IterPro::new((0..101).into_iter().take(20)) {
thread::sleep(Duration::from_millis(50));
}
- Bisect
[dependencies]
utils = { path = "utils", version = "0.1.0"}
Recommend link if you only want to keep one copy of the codes
ln -s <real folder> <link folder>
use utils;