pub fn exhaustive_integer_range_to_negative_infinity(
    a: Integer
) -> ExhaustiveIntegerRangeToNegativeInfinity 
Expand description

Generates all Integers less than or equal to some number $a$, in order of increasing absolute value.

When two Integers have the same absolute value, the positive one comes first.

The output satisfies $(|x_i|, \operatorname{sgn}(-x_i)) <_\mathrm{lex} (|x_j|, \operatorname{sgn}(-x_j))$ whenever $i < j$.

The output length is infinite.

§Worst-case complexity per iteration

$T(i) = O(i)$

$M(i) = O(i)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.

Although the time and space complexities are worst-case linear, the worst case is very rare. If we exclude the cases where the the previously-generated value is positive and its least-significant limb is Limb::MAX, the worst case space and time complexities are constant.

§Examples

use malachite_base::iterators::prefix_to_string;
use malachite_nz::integer::exhaustive::exhaustive_integer_range_to_negative_infinity;
use malachite_nz::integer::Integer;

assert_eq!(
    prefix_to_string(exhaustive_integer_range_to_negative_infinity(Integer::from(2)), 10),
    "[0, 1, -1, 2, -2, -3, -4, -5, -6, -7, ...]"
)