A Note on How Objects are Found
You may save yourself some difficulty by remembering the following point: the virtual functions of the object within the collection, not those of the target, are called when comparing or testing a target for equality.
The following code fragment illustrates the point:
SortedCollection sc;
RWCollectableString member;
sc.insert(&member);
RWCollectableString target;
RWCollectableString* p = (RWCollectableString*)sc.find(&target);
In this example, the virtual functions of
member within the collection
RWCollectableString are called, not the virtual functions of
target. In other words:
member.compareTo(&target); //This will get called.
target.compareTo(&member); //Not this.