pub fn exhaustive_integer_inclusive_range(
    a: Integer,
    b: Integer
) -> ExhaustiveIntegerRange 
Expand description

Generates all Integers in the closed interval $[a, b]$, in order of increasing absolute value.

When two Integers have the same absolute value, the positive one comes first. $a$ must be less than or equal to $b$. If $a$ and $b$ are equal, the range contains a single element.

The output satisfies $(|x_i|, \operatorname{sgn}(-x_i)) <_\mathrm{lex} (|x_j|, \operatorname{sgn}(-x_j))$ whenever $i, j \in [0, b - a]$ and $i < j$.

The output length is $b - a + 1$.

§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 least-significant limb of the absolute value of the previously-generated value is Limb::MAX, the worst case space and time complexities are constant.

§Panics

Panics if $a > b$.

§Examples

use itertools::Itertools;
use malachite_base::strings::ToDebugString;
use malachite_nz::integer::exhaustive::exhaustive_integer_inclusive_range;
use malachite_nz::integer::Integer;

assert_eq!(
    exhaustive_integer_inclusive_range(Integer::from(-4), Integer::from(4)).collect_vec()
            .to_debug_string(),
    "[0, 1, -1, 2, -2, 3, -3, 4, -4]"
)