NumberLine<T extends num> class
A memory-efficient iterable sequence of numbers.
Mimics C++ std::views::iota or Python's range().
Can iterate over both int and double, and the boundary condition for end is exclusive, meaning it stops before the exact requested ending.
- Inheritance
-
- Object
- IterableBase<
T> - NumberLine
Constructors
- NumberLine(T start, T end, {T? step})
-
Creates a memory-efficient sequence from
starttoendexclusive, incrementing bystep.
Properties
- end ↔ T
-
The ending exclusive boundary of the sequence.
getter/setter pair
- first → T
-
The first element.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setteroverride
- isEmpty → bool
-
Whether this collection has no elements.
no setterinherited
- isNotEmpty → bool
-
Whether this collection has at least one element.
no setterinherited
-
iterator
→ Iterator<
T> -
A new
Iteratorthat allows iterating the elements of thisIterable.no setteroverride - last → T
-
The last element.
no setterinherited
- length → int
-
The number of elements in this Iterable.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- single → T
-
Checks that this iterable has only one element, and returns that element.
no setterinherited
- start ↔ T
-
The starting inclusive boundary of the sequence.
getter/setter pair
- step ↔ T
-
The amount or distance to step incrementally on each iteration.
getter/setter pair
Methods
-
any(
bool test(T element)) → bool -
Checks whether any element of this iterable satisfies
test.inherited -
cast<
R> () → Iterable< R> -
A view of this iterable as an iterable of
Rinstances.inherited -
contains(
Object? element) → bool -
Whether the collection contains an element equal to
element.override -
elementAt(
int index) → T -
Returns the
indexth element.inherited -
empty(
) → bool - Returns true if the sequence is empty.
-
every(
bool test(T element)) → bool -
Checks whether every element of this iterable satisfies
test.inherited -
expand<
T> (Iterable< T> toElements(T element)) → Iterable<T> -
Expands each element of this Iterable into zero or more elements.
inherited
-
firstWhere(
bool test(T element), {T orElse()?}) → T -
The first element that satisfies the given predicate
test.inherited -
fold<
T> (T initialValue, T combine(T previousValue, T element)) → T -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< T> other) → Iterable<T> -
Creates the lazy concatenation of this iterable and
other.inherited -
forEach(
void action(T element)) → void -
Invokes
actionon each element of this iterable in iteration order.inherited -
get(
int index) → T -
Retrieves the element at the specified 0-based
indexin O(1) time. -
hasValue(
) → bool - Returns true if the sequence has elements.
-
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
lastWhere(
bool test(T element), {T orElse()?}) → T -
The last element that satisfies the given predicate
test.inherited -
map<
T> (T toElement(T e)) → Iterable< T> -
The current elements of this iterable modified by
toElement.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reduce(
T combine(T value, T element)) → T -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
reset(
) → void - Resets the sequence to its initial state.
-
set(
T newStart, T newEnd, [T? newStep]) → void - Modifies the boundaries of this number line sequence.
-
singleWhere(
bool test(T element), {T orElse()?}) → T -
The single element that satisfies
test.inherited -
skip(
int count) → Iterable< T> -
Creates an Iterable that provides all but the first
countelements.inherited -
skipWhile(
bool test(T value)) → Iterable< T> -
Creates an
Iterablethat skips leading elements whiletestis satisfied.inherited -
take(
int count) → Iterable< T> -
Creates a lazy iterable of the
countfirst elements of this iterable.inherited -
takeWhile(
bool test(T value)) → Iterable< T> -
Creates a lazy iterable of the leading elements satisfying
test.inherited -
toList(
{bool growable = true}) → List< T> -
Creates a List containing the elements of this Iterable.
inherited
-
toSet(
) → Set< T> -
Creates a Set containing the same elements as this iterable.
inherited
-
toString(
) → String -
Returns a string representation of (some of) the elements of
this.override -
type(
) → Type -
Returns the type argument
T. -
where(
bool test(T element)) → Iterable< T> -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test.inherited -
whereType<
T> () → Iterable< T> -
Creates a new lazy Iterable with all elements that have type
T.inherited
Operators
-
operator %(
num modulo) → NumberLine< T> - Modulo operation on sequence boundaries keeping the step intact.
-
operator *(
num factor) → NumberLine< T> -
Scales the sequence proportionally by multiplying boundaries and step by
factor. -
operator +(
num offset) → NumberLine< T> -
Shifts the sequence by adding
offsetconsistently to boundaries. -
operator -(
num offset) → NumberLine< T> -
Shifts the sequence by subtracting
offsetconsistently from boundaries. -
operator /(
num divisor) → NumberLine< double> - Divides the sequence proportionally safely returning a NumberLine of doubles.
-
operator <(
Iterable< T> other) → bool - Safely performs lexicographical comparison against another iterable.
-
operator <=(
Iterable< T> other) → bool -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
Iterable< T> other) → bool -
operator >=(
Iterable< T> other) → bool -
operator [](
int index) → T -
Retrieves the element at the specified 0-based
indexin O(1) time. -
operator []=(
int index, T value) → void - Unsupported. Modifying a generated mathematical sequence element by element is invalid.