Re: Count of enumerator?
Re: Count of enumerator?
- Subject: Re: Count of enumerator?
- From: Ryan Britton <email@hidden>
- Date: Thu, 11 May 2006 08:21:31 -0700
One of the factors that I suspect is keeping this kind of
functionality from NSDirectoryEnumerator in particular is the
implementation. Chances are that NSDirectoryEnumerator fetches its
contents lazily due to the expense of disk operations and does not do
these operations until they're needed. Since NSDirectoryEnumerator
allows you to skip descendents of a directory at will, this kind of
optimization would be huge for instances where that happens
frequently. If you take a look at UKDirectoryEnumerator at the
following link, it shows a possible lazy approach this enumerator
might be similar to (though the NS* version is a lot slower...).
http://www.zathras.de/angelweb/sourcecode.htm
On May 11, 2006, at 8:06 AM, Christopher Hickman wrote:
Is it possible to get a count of an enumerator without exhausting
it? I
just want to know how many objects remain in my enumerator, but
calling
allObjects to get a count exhausts it. I can work around by doing
some
silly things like creating a new enumerator from the array returned by
allObjects after counting it, but it seems like there should be a
simpler
way. (Plus, I lose functionality from that since -[NSArray
objectEnumerator]
returns an NSEnumerator and I'm starting with an
NSDirectoryEnumerator.
I guess I might just have to file an enhancement request against
Foundation
to add -[NSEnumerator count], but I'm hoping there's just something
I'm
missing.
Topher
_______________________________________________
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
_______________________________________________
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