Function malachite_nz::integer::exhaustive::exhaustive_integers
source · pub fn exhaustive_integers() -> Chain<Once<Integer>, IntegerUpDown>
Expand description
Generates all Integer
s, in order of increasing absolute value. When two Integer
s have
the same absolute value, the positive one comes first.
§Worst-case complexity per iteration
$T(i) = O(i)$
$M(i) = O(1)$, amortized.
where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.
§Examples
use malachite_base::iterators::prefix_to_string;
use malachite_nz::integer::exhaustive::exhaustive_integers;
assert_eq!(
prefix_to_string(exhaustive_integers(), 10),
"[0, 1, -1, 2, -2, 3, -3, 4, -4, 5, ...]"
)