From: Robert Klemme Date: 2003-05-28T17:15:20+09:00 Subject: Re: Binary Tree vs. Hash "Mauricio Fern�ndez" schrieb im Newsbeitrag news:20030528053926.GA20904@student.ei.uni-stuttgart.de... > We cannot optimize w/ the @sorted flag because Array is used for two > different purposes: > * poor man's set (sorting would help here for include? and the like) > * plain old array (you don't want sorting as you expect to find one > element at the index you inserted it) > > Unless we create 2 classes specifically for these 2 different semantics, > nothing can be done. Thanks for pointing this out with so few words! > So if anything, the first step would be creating a Set class. Set > objects could be hinted on creation whether to use internally a > sorted array, a hash ( object => true ), etc, depending on the desired > complexity and space/time trade-off. Yes. Apart from that I'd prefer different classes over a flag at construction time. It's more OO and you need several classes for the implementation anyway. Cheers robert