7using System.Collections.Generic;
108 _items = (TItemType[])items.Clone();
118 TItemType? item =
default(TItemType);
149 string[]
_keys =
new string[] {
"One",
"Two",
"Three" };
150 string[]
_values =
new string[] {
"Value 1",
"Value 2",
"Value 3" };
159 List<ItemPair> items =
new List<ItemPair>();
161 int numItems =
_keys.Length;
162 for (
int index = 0; index < numItems; ++index)
Represents a key/value pair where the key and value are strings.
ItemPair(string key, string value)
Constructor.
Represents a container that offers up two kinds of iterators for the hardcoded contents.
IIterator< string > GetValues()
Retrieve an iterator over the "value" part of the data, where the data returned from the iterator is ...
IIterator< string > GetKeys()
Retrieve an iterator over the "key" part of the data, where the data returned from the iterator is a ...
IIterator< ItemPair > GetItems()
Retrieve an iterator over the data that returns an ItemPair object containing both key and value for ...
Represents an iterator for a container by implementing the IIterator interface.
int _index
The index into the _items array to the next item.
void Reset()
Reset the iterator to the beginning.
Iterator(TItemType[] items)
Constructor.
TItemType[] _items
The array of items to iterate over.
TItemType? Next()
Returns the next item in the iteration or null, if there are no more items.
Represents an iterator for some type. This is a forward-only iterator in that it can only start at 0 ...
void Reset()
Start iteration from beginning of container.
TItemType? Next()
Retrieve the next item from the container.
The namespace containing all Design Pattern Examples implemented in C#.