pub fn integer_increasing_inclusive_range(
a: Integer,
b: Integer
) -> IntegerIncreasingRange ⓘ
Expand description
Generates all Integer
s in the closed interval $[a, b]$, in ascending order.
$a$ must be less than or equal to $b$. If $a$ and $b$ are equal, the range contains a single
element. To generate all Integer
s in an infinite interval in ascending or descending order,
use integer_increasing_range_to_infinity
or
integer_decreasing_range_to_negative_infinity
.
The output is $(k)_{k=a}^{b}$.
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 previously-generated value is positive and its
least-significant limb 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::integer_increasing_inclusive_range;
use malachite_nz::integer::Integer;
assert_eq!(
integer_increasing_inclusive_range(Integer::from(-4), Integer::from(4)).collect_vec()
.to_debug_string(),
"[-4, -3, -2, -1, 0, 1, 2, 3, 4]"
)