13from abc
import ABC, abstractmethod
25 def __init__(self, key = "", value = "") -> None:
95class Iterator(IIterator):
103 def __init__(self, items : list, numItems: int) ->
None:
121 retrieved_item =
None
125 return retrieved_item
149 _keys = [
"One",
"Two",
"Three" ]
152 _values = [
"Value 1",
"Value 2",
"Value 3" ]
165 numItems = len(IteratorContainer_Class._keys)
166 for index
in range(0, numItems):
167 items.append(
ItemPair(IteratorContainer_Class._keys[index],
168 IteratorContainer_Class._values[index]))
181 return Iterator(IteratorContainer_Class._keys, len(IteratorContainer_Class._keys))
192 return Iterator(IteratorContainer_Class._values, len(IteratorContainer_Class._values))
Represents an iterator for some type.
None Reset(self)
Start iteration from beginning of container.
Any Next(self)
Retrieve the next item from the container.
Represents a key/value pair where the key and value are strings.
Value
The value of the item pair.
Key
The key used to match the item pair.
None __init__(self, key="", value="")
Constructor.
Represents a container that offers up two kinds of iterators for the hardcoded contents,...
IIterator GetItems(self)
Retrieve an iterator over the data that returns an ItemPair object containing both key and value for ...
IIterator GetValues(self)
Retrieve an iterator over the "value" part of the data, where the data returned from the iterator is ...
IIterator GetKeys(self)
Retrieve an iterator over the "key" part of the data, where the data returned from the iterator is a ...
Represents an iterator for a container by implementing the IIterator interface.
None Reset(self)
Reset the iterator to the beginning.
None __init__(self, list items, int numItems)
Constructor.
Any Next(self)
Fetches the next item in the iteration, if any.
_items
The array of items to iterate over.
_numItems
The number of items in the array of items.
_index
The index into the _items array to the next item.