Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!haven.umd.edu!news.umbc.edu!eff!news.duke.edu!news.mathworks.com!newsfeed.internetmci.com!howland.reston.ans.net!torn!nott!cunews!tina.mrco.carleton.ca!knight
From: knight@mrco.carleton.ca (Alan Knight)
Subject: Re: OrderedCollection new:
X-Nntp-Posting-Host: tina.mrco.carleton.ca
Message-ID: <knight.819738817@tina.mrco.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Reply-To: knight@mrco.carleton.ca (Alan Knight)
Organization: The Object People
References: <4bgglt$bdp@ralph.vnet.net> <4bgv92$58q@newsbf02.news.aol.com>
Date: Sat, 23 Dec 1995 17:13:37 GMT
Lines: 30

In <4bgv92$58q@newsbf02.news.aol.com> bytesmiths@aol.com (Bytesmiths) writes:

>Tom Gordon <tadpole@vnet.net@vnet.net> writes:
>    "Is there any good reason why ( OrderedCollection new: ) responds with
>a silly OrderedCollection of zero size?"

>Are you certain that's what's happening?

That's certainly what's happening. (OrderedCollection new: anything)
size = 0.  The fact that it's pre-allocated some space for what you
might want to put in there is an implementation detail. It seems like
what you want is more like a growable array than an ordered collection.
e.g.
  anArray at: X will return the contents at index X if it's been set,
and nil otherwise.

One solution would be to implement an array like this, but I think it
would be easier to either

1) Use a dictionary if performance of indexing is not critical (or if
the cachei s sparse)
2) Use arrays as Jan suggested.


-- 
 Alan Knight                | The Object People
 knight@acm.org             | Smalltalk and OO Training and Consulting
 alan@objectpeople.on.ca    | 509-885 Meadowlands Dr.
 +1 613 225 8812            | Ottawa, Canada, K2C 3N2

