Function malachite_nz::integer::exhaustive::exhaustive_nonzero_integers
source · pub fn exhaustive_nonzero_integers() -> IntegerUpDown
Expand description
Generates all nonzero Integer
s, in order of increasing absolute value. When two Integer
s
have the same absolute value, the positive one comes first.
The output length is infinite.
§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_nonzero_integers;
assert_eq!(
prefix_to_string(exhaustive_nonzero_integers(), 10),
"[1, -1, 2, -2, 3, -3, 4, -4, 5, -5, ...]"
)