The IStringIterator interface describes an abstract interface for enumerating over a list of strings. It effectively hides the underlying implementation, whether a TStrings, a string hash table or other structure, while still allowing access to all the strings stored in the implementation.
The IStringIterator interface is similar to an Enumeration in java.
To use the iterator is simple, get the iterator and then keep calling the CommonInterfaces.IStringIterator.NextElement method until the CommonInterfaces.IStringIterator.HasMoreElements method returns False. The iterator works by giving you the next element until the end of the list, there is no provision for getting the previous element.
Namespace: CommonInterfaces
Delphi
|
type
IStringIterator = interface
['{F83E4162-A296-11D3-B992-00C04F8EDA5F}']
end;
|
|
Name
|
Description
|
|
Count
|
Returns the number of items left in the enumeration.
|
Top
|
|
Name
|
Description
|
|
CurrentElement
|
Returns the current item in the enumeration, your "place" in the enumeration.
When the iterator is first supplied or when it is Reset, there is no current element (calling this method in such a case should raise an exception). Only after the first call to the NextElement method will this method return a value.
Unlike the NextElement method which returns a new value every time you call it, this method always returns the same value no matter how many times you call it (until NextElement is called, of course).
|
|
GetCount
|
Returns the number of items left in the enumeration.
Accessor method for CommonInterfaces.IStringIterator.Count property.
|
|
get_Count
|
Returns the number of items left in the enumeration.
Accessor method for CommonInterfaces.IStringIterator.Count property.
Note
|
Required by VCL.Net
|
|
|
HasMoreElements
|
Returns True if there are more elements to retrieve from the enumeration. While this method returns true, the CommonInterfaces.IStringIterator.NextElement method should not raise an exception.
|
|
NextElement
|
Returns the next item in the enumeration. If there are no more items, the method should raise an exception.
To check if there are more items, use the CommonInterfaces.IStringIterator.HasMoreElements method. The NextElement method advances its place in the enumeration and then returns that item. Every call to NextElement returns a new item (until the end of the enumeration). If you wish to access the current item multiple times in a loop, use the CommonInterfaces.IStringIterator.CurrentElement method.
|
|
Reset
|
Resets the iterator to the beginning of the enumeration.
|
Top
|
The InterfaceCollections unit contains some implementations of the iterators for common objects.
|