[squeak-dev] Set class comment

Casey Ransberger casey.obrien.r at gmail.com
Tue Mar 30 02:09:55 UTC 2010

I noticed that the class comment for Set still thinks you can't stick nil in
a set. I was going to update it, but I'm a little confused about what's
going on in #array.

#(#foo # bar #baz nil) asSet array

{nil . nil . nil . a SetElement . nil . #foo . #baz . nil . nil . nil .

Can I assume that the SetElement is a stand in for the nil item in the Set?

See below for what I have so far.


As of Squeak 4.1, Sets can contain nil.

I represent a set of objects without duplicates.  I can hold anything that
responds to
#hash and #=.  My instances will automatically grow, if necessary,
Note that I rely on #=, not #==.  If you want a set using #==, use

Instance structure:

  array An array whose non-nil elements are the elements of the set,
and whose nil elements are empty slots.  There is always at least one nil.
In fact I try to keep my "load" at 75% or less so that hashing will work

  tally The number of elements in the set.  The array size is always greater
than this.

The core operation is #findElementOrNil:, which either finds the position
where an
object is stored in array, if it is present, or finds a suitable position
holding nil, if
its argument is not present in array,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100329/89015ed2/attachment.htm

More information about the Squeak-dev mailing list