Bug 40575

GemStone/S 64 Bit

2.4.3, 2.4.2, 2.4.1, 2.4,, 2.3.1, 2.3,,,,, 2.2.5, 2.2.4, 2.2.3, 2.2.x, 2.2, 2.1.4, 2.1.x, 2.0.x, 1.x



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: 4/26/10