combin_iterator/altern.rs
1//! This module contains some structure to altern between iterators
2//!
3//! ## When to use what ?
4//!
5//! - `BiAltern` is the most efficient iterator here, in terme of performance, for 2 iterable.<br/>
6//! But, if you want to traverse more than 2 iterator, is drawback is that it require some reflexion, and manipulation to maybe
7//! create the iterator that you want (see the section `Common Mistake` in the module `bi_altern`). <br/>
8//! Futher more, you need to know the number of iterator at compile time for use this one.
9//! He also implement the `std::iter::traits::ExactSizeIterator` and `std::iter::traits::DoubleEndedIterator` traits if possible.
10//! - `VecAltern` is a little less time perfomant iterator (but still good enough for the majority of usage)`, but more flexible.
11//! You can easily iterate over as many iterator you want, and add them at runtime, and during the iteration.
12//!
13//! ## Performance comparaison
14//!
15//! Here are the result of benchmarks done to compare the speed of each:
16//!
17//! - `BiAltern`: <br/>
18//! test create_100000x2 ... bench: 0 ns/iter (+/- 0) <br/>
19//! test create_100000x4 ... bench: 1 ns/iter (+/- 0) <br/>
20//! test create_and_count_100000x2 ... bench: 213,932 ns/iter (+/- 12,216) <br/>
21//! test create_and_count_100000x4 ... bench: 667,491 ns/iter (+/- 82,120) <br/>
22//! test create_and_count_100000x8 ... bench: 2,144,507 ns/iter (+/- 509,807) <br/>
23//! test create_and_count_20000x32 ... bench: 4,385,295 ns/iter (+/- 1,792,604) <br/>
24//! test create_and_count_50000x16 ... bench: 4,757,520 ns/iter (+/- 550,491) <br/>
25//! - `VecAltern`: <br/>
26//! test create_100000x2 ... bench: 157 ns/iter (+/- 55) <br/>
27//! test create_100000x4 ... bench: 264 ns/iter (+/- 18) <br/>
28//! test create_and_count_100000x2 ... bench: 1,499,890 ns/iter (+/- 108,683) <br/>
29//! test create_and_count_100000x4 ... bench: 3,138,175 ns/iter (+/- 266,846) <br/>
30//! test create_and_count_100000x8 ... bench: 6,195,610 ns/iter (+/- 457,717) <br/>
31//! test create_and_count_20000x32 ... bench: 4,375,710 ns/iter (+/- 336,647) <br/>
32//! test create_and_count_50000x16 ... bench: 6,058,750 ns/iter (+/- 372,925) <br/>
33//!
34//! The first number precise the size of each iterator, and the second precise the number of iterator.
35
36
37pub mod bi_altern;
38pub mod vec_altern;
39
40pub use bi_altern::BiAltern;
41pub use bi_altern::AlternWith;
42pub use vec_altern::VecAltern;