[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using collections
From: |
Roger M. Burkhart |
Subject: |
Re: Using collections |
Date: |
Tue, 28 Jan 1997 18:06:05 -0600 |
> I had a question about using collections for integers or other numbers.
> I'd like to use the collections instead of an ordinary array so I could use
> the probes and also be able to cleanly drop them, but they seem a bit
> cumbersome for simple types. First, one of the integers could be zero, but
> nil (also 0) is used as the end of list marker in the loops; as well, the
> contains: predicate appears not to handle searching for zeros.
There are alternative ways to test for the end of a loop on collection
members, using an explicit test for index location:
index = [aCollection begin: scratchZone];
while ( 1 ) {
member = [index next];
if ( [index getLoc] == End ) break;
...
}
So, if you don't mind casting to/from id type whenever you add/retrieve other
types from a collection, you should still be able to accomplish anything
you want to accomplish. But you're right that the current default contains:
method doesn't consider the possible presence of a zero member right now;
that's a bug that needs to be fixed.
> Second,
> since there's only room for a pointer, this would seem to leave no
> efficient way to handle doubles. Presumably the power of the
> createBegin-createEnd paradigm is that I could create an Array (say), set
> the type to doubles, and get back an array tailored for doubles. I assume
> that this kind of optimization is desired, but not high priority--can you
> say where on the to-do list these features are? Or maybe I've missed the
> better way to do this.
Yes, the createBegin/End sequence could be used to declare a different-sized
internal member, with a different implementation as a result. This has been
considered and I'd like to see it some day, but lots of other things are
ahead of it, including core capabilities of collections on id types.
Roger
- Re: Using collections, (continued)
- Re: Using collections, glen e. p. ropella, 1997/01/17
- Re: Using collections, glen e. p. ropella, 1997/01/17
- Re: Using collections, glen e. p. ropella, 1997/01/23
- Re: Using collections, Roger M. Burkhart, 1997/01/23
- Re: Using collections, Roger M. Burkhart, 1997/01/27
- Re: Using collections, Kevin Crowston, 1997/01/27
- Re: Using collections,
Roger M. Burkhart <=