Re: NSEnumerator and the missing peek method
Re: NSEnumerator and the missing peek method
- Subject: Re: NSEnumerator and the missing peek method
- From: Marcel Weiher <email@hidden>
- Date: Fri, 30 Sep 2005 00:04:22 +0100
On 29 Sep 2005, at 22:09, John C. Randolph wrote:
On Sep 29, 2005, at 1:53 PM, Jan Vereecken wrote:
- Why didn't the AppKit developers include this (the hasNext
method) in the first place?
Probably because you can't always tell if there is a next object
until you try to obtain it. Remember, enumerators don't only
traverse arrays. They might be going through sets, and I could
write an enumerator that traverses a tree, which still behaves the
same as all other enumerators
Precisely! For example, MPWFoundation provides filter-enumerators
that obtain the next object by filtering their source enumerator. The
filtering takes the form of selecting objects based on the return
value of a method (in which case -nextObject has to run the source
until it finds one that matches or reaches its end), or of just
getting the return value of the method and returning that instead.
Since each filter-enumerator provides the same interface it requires,
they are arbitrarily stackable, though that capability is currently
not exposed in the HOM-wrappers that are the primary interface to
filter-enumerators.
Furthermore, a NSEnumerator doesn't have to actually be based on an
underlying list, it might simply compute its values on the fly.
Marcel
--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
The simplicity of power HOM, IDEAs, MetaAd etc.
1d480c25f397c4786386135f8e8938e4
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden