Tekvel Magic
|
Infinite iterator for cycling through a list of values. More...
Public Member Functions | |
def | __init__ (self, values) |
Initializes the InfiniteIterator with a list of values. More... | |
def | __iter__ (self) |
Initializes the InfiniteIterator with a list of values. More... | |
def | __next__ (self) |
Returns the iterator object itself. More... | |
Public Attributes | |
values | |
current_position | |
current_value | |
Infinite iterator for cycling through a list of values.
This class provides an infinite iterator that continuously cycles through a list of values. Each iteration returns a tuple containing the current value and its index within the list. The index is updated as the iterator loops through the values repeatedly. Useful for scenarios where cyclic iteration over a dataset is required, such as generating test patterns or simulating states.
Example usage:
Output:
def __init__ | ( | self, | |
values | |||
) |
Initializes the InfiniteIterator with a list of values.
Sets up the iterator with the provided list of values and prepares it for infinite cycling.
values | List of values to iterate over. |
def __iter__ | ( | self | ) |
Initializes the InfiniteIterator with a list of values.
Sets up the iterator with the provided list of values and prepares it for infinite cycling.
values | List of values to iterate over. |
def __next__ | ( | self | ) |
Returns the iterator object itself.
Enables the object to be used in iteration contexts such as loops.
current_position |
current_value |
values |