Tools.h++ Manual

104011 Tandem Computers Incorporated 15-1
Smalltalk-like Collection Classes 15
15.1 Introduction
The third general type of collection classes provided with the Tools.h++ Class
Library is a set of "Smalltalk-80-like Collection Classes". In this approach,
objects to be collected must inherit the abstract base class "
RWCollectable
",
using either single or multiple inheritance. The principal advantage of this
approach is that the programming-interface is much cleaner and the collection
classes are far more powerful. The disadvantage is that the objects are slightly
larger, the collection classes slightly slower, and (as we shall see) not as
typesafe..
Many of these classes have a typedef to either the corresponding Smalltalk
names, or to a generic name. This typedef is activated by defining the
preprocessor macro
RW_STD_TYPEDEFS
. Table 15-1 summarizes.
Table 15-1 Smalltalk-like classes, iterators, and implementations.
Class Iterator
"Smalltalk"
typedef Implemented as
RWBag
RWBagIterato
r Bag
Dictionary of
occurrences
RWBinaryTree RWBinaryTree-
Iterator
SortedCollect-
ion
Binary tree
RWBTree
B-Tree in memory