[Lazarus] Easiest way to "case" strings
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Fri Mar 27 02:22:17 CET 2009
Graeme Geldenhuys schrieb:
> HasNext() Returns true if the collection has more items
> when traversing the collection in the forward
> direction.
This (and the Peek methods) require that the collection is organized
strictly sequential, for Previous in both directions. The implementation
for an DataSet can consume an considerable amount of time for such
operations. It looks to me as if such an iterator interface has very
limited practical use.
> Remove() Removes from the collection the last item that
> was returned by the Next() or Previous() calls.
> (optional modifier operation)
> SetItem(item) Replaces the last item returned by the Next()
> or Previous() calls with the specified item.
> (optional modifier operation)
Which element will the iterator represent, after such an operation?
After Remove it has to represent the next or previous item, depending on
the direction of traversion.
> A *huge* benefit of using iterators, is that the developers doesn't
> need to worry about if the list/container is 0-based or 1-based, how
> to get the next or previous item etc... It now gives the developer a
> consistent interface API to work with, no matter what is being
> iterated.
Nice try, but I prefer the slimmer Count and Item[] interface, with a
chance to remember the index of a found item, and with immediate use of
an item without an type cast. I.e. I never used collections at all, but
that's not an argument against using collections and iterators at all,
only my personal preference ;-)
DoDi
More information about the Lazarus
mailing list