SetIterator

SetIterator inherits Iterator

SetIterator is a type that allows the user to iterate over a range of elements in a Set container. Use the GetIterator method to obtain an iterator to the beginning of the set.

Usage:

Set<int> set = Set<int>();
SetIterator iter = set.GetIterator();
while (iter.HasNext())
{
   iter.Next();
   int data = (int)iter.Data();
}

When iterating over the entire range of the Set, the foreach loop is a more convenient method:

Set<int> set = Set<int>();
foreach (int data in set)
{
   ...
}

Methods

Note

Return values from methods that return Object should be cast to the correct data type.

bool HasPrev()

Returns true if another element exists before the current element.

Object Prev()

Decrements the iterator to the previous element and returns its associated data, which should be cast to the data type of the Set before usage. If at the beginning of the set and no previous element exists, invalid data is returned, so HasPrev() should be queried before using this method.

Object Data()

Returns the data associated with the current element, which should be cast to the data type of the Set before usage.

See Iterator for a list of methods inherited by all iterator types.