LazyIterator
- class LazyIterator[T]
A base type for all internally-iterated objects.
Such objects are only iterable through
.for_eachmethod, rather than Python standard.__iter__:def visitor(value: T) -> None | bool | VisitAction: ... iterator.for_each(visitor)
This allows generating internally iterated sequences on-the-fly while keeping performance overhead low, e.g. combining multiple sequences while traversing a graph. In most cases, this is not as easy to implement with external iteration otherwise.
Children
Members defined in
LazyIterator(8 members)Returns
Trueif this range is not empty.Deprecated Get value at index, This is computed lazily. Throws
IndexErroron out of bounds.Get value at index. This is computed lazily. Returns
Nonefor out of bounds index.Collect all items into a
list.Count the number of items in this range. This is computed lazily.
Check if this range is empty.
Lazily visit each item in this range. Visitation is stopped on returning
FalseorVisitAction.Stop;Get value at index, This is computed lazily. Throws
IndexErroron out of bounds.Methods
- __getitem__(arg0: int, /) syside.T
Deprecated Get value at index, This is computed lazily. Throws
IndexErroron out of bounds.Deprecated since version 0.11: use get instead, or collect or for_each for iteration
Notes:
Has complexity O(n) so should be used sparingly.
Only positive indices are allowed since size is unknown.
- at(arg0: int, /) syside.T | None
Get value at index. This is computed lazily. Returns
Nonefor out of bounds index.Notes:
Has complexity O(n) so should be used sparingly.
Only positive indices are allowed since size is unknown.
- collect() list[syside.T]
Collect all items into a
list.
- for_each(arg0: Callable[[syside.T], None | bool | syside.VisitAction], /) None
Lazily visit each item in this range. Visitation is stopped on returning
FalseorVisitAction.Stop;
- get(arg0: int, /) syside.T
Get value at index, This is computed lazily. Throws
IndexErroron out of bounds.Notes:
Has complexity O(n) so should be used sparingly.
Only positive indices are allowed since size is unknown.