|
Debug Tools
|


Public Member Functions | |
| def | __init__ (self, data_container, iterable_access, empty_slots, end_index=None, filled_slots=set()) |
| def | __len__ (self) |
| def | __iter__ (self) |
| def | __next__ (self) |
| def | stop_iteration (self, index) |
| def | __str__ (self) |
Public Attributes | |
| current_index | |
| The current index used when iterating over this collection items. | |
| empty_slots | |
| List the empty free spots for old items, which should be skipped when iterating over. | |
| filled_slots | |
| List the empty free spots for new items, which should be skipped when iterating over. | |
| data_container | |
| The underlying container used to calculate this iterable length. | |
| iterable_access | |
| The iterable access method to get the next item given a index. | |
Dynamically creates creates a unique iterable which can be used one time.
Why have an __iter__ method in Python?
https://stackoverflow.com/questions/36681312/why-have-an-iter-method-in-python
Definition at line 49 of file dynamic_iteration.py.
| def __init__ | ( | self, | |
| data_container, | |||
| iterable_access, | |||
| empty_slots, | |||
end_index = None, |
|||
filled_slots = set() |
|||
| ) |
Receives a iterable an initialize the object to start an iteration.
@param `iterable_access` a function pointer to function which returns the next element given its index
@param `end_index` it must be a list with one integer element
@param `empty_slots` it must be a set with indexes of free place to put new elements
Definition at line 57 of file dynamic_iteration.py.
| def __iter__ | ( | self | ) |
Resets the current index and return a copy if itself for iteration.
Definition at line 90 of file dynamic_iteration.py.
References DynamicIterable.current_index.
| def __len__ | ( | self | ) |
Return the total length of this container.
Definition at line 84 of file dynamic_iteration.py.
References DynamicIterable.data_container.
| def __next__ | ( | self | ) |
Called by Python automatically when iterating over this set and python wants to know the
next element to iterate. Raises `StopIteration` when the iteration has been finished.
How to make a custom object iterable?
https://stackoverflow.com/questions/21665485/how-to-make-a-custom-object-iterable
https://stackoverflow.com/questions/4019971/how-to-implement-iter-self-for-a-container-object-python
Definition at line 97 of file dynamic_iteration.py.
References DynamicIterable.current_index, DynamicIterable.empty_slots, DynamicIterable.filled_slots, and DynamicIterable.iterable_access.
| def __str__ | ( | self | ) |
Return a nice string representation of this iterable.
Definition at line 127 of file dynamic_iteration.py.
Referenced by LockableType.__repr__().

| def stop_iteration | ( | self, | |
| index | |||
| ) |
Raise the exception `StopIteration` to stop the current iteration.
Definition at line 121 of file dynamic_iteration.py.