Function malachite_nz::integer::exhaustive::integer_increasing_range
source · pub fn integer_increasing_range(
a: Integer,
b: Integer,
) -> IntegerIncreasingRange ⓘ
Expand description
Generates all Integer
s in the half-open interval $[a, b)$, in ascending order.
$a$ must be less than or equal to $b$. If $a$ and $b$ are equal, the range is empty. 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-1}$.
The output length is $b - a$.
§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_range;
use malachite_nz::integer::Integer;
assert_eq!(
integer_increasing_range(Integer::from(-4), Integer::from(4))
.collect_vec()
.to_debug_string(),
"[-4, -3, -2, -1, 0, 1, 2, 3]"
)