Bug 41013


6.5.8,, 6.5.7, 6.5.6, 6.5.x, 6.5, 6.3.1, 6.3, 6.2.x, 6.1.5, 6.1.x, 6.1, 6.0.x, 6.0,



SortedCollection >> includes: may fail to find elements

SortedCollection includes may fail to find an element, if the elements
in the SortedCollection define = according to one instance variable, but
the SortedCollection uses a sort block that compares a different instance
variable.  This is true using a default sort block if the elements in the
SortedCollection define <= to use a instance variable other than the one
used for the = comparison.

This is since SortedCollection >> includes: performs a binary sort based
on the sorted order, so if the argument does not compare as = to an element
in the vicinty of the insert location, no further searching is done.


Use caution in defining the = and <= methods for elements that will be
in a SortedCollection, and in the sortblock method.  If there is a need
to define these differently, <SortedCollection> asArray includes: will
return the correct result.  Alternatively, subclass SortedCollection and
reimplement includes: as a linear search.

Last updated: 10/21/10