The way I make a set is to use the keys of a hash as a set.  I just set the
value to nil.  Works great and is MUCH faster than arrays.

-----Original Message-----
From: HarryO [mailto:harryo / zipworld.com.au]
Sent: Friday, November 16, 2001 11:57 AM
To: ruby-talk ML; undisclosed-recipients:
Subject: [ruby-talk:25639] Re: Specialised data structures - good or
bad?


> I'm not particularly advocating a data-structures package. It's not
> something I personally feel the need for. But we already have half of a
> Set in Array. Rather than adding more methods to an already overloaded
> class, I'm suggesting making the natural split.

I agree with that.  There are cases where you really want the semantics
of a set.  An array does not provide those semantics and it shouldn't.

I definitely think Set is a worthwhile type to have separately to Array.
It could probably be implemented by wrapping an Array, in order to
minimise the amount of rewriting, but an efficient implementation would
probably do it a better way.

As you say, though, String, Array and Hash, plus the numeric types are
all one needs for the majority of work, barring an absolute need for
efficiency.

I definitely think more esoteric data structures have a place, but only
in very specific circumstances, so keep them in a separate package
somewhere, as you suggested, rather than making them part of the core.