Tools.h++ Manual

104011 Tandem Computers Incorporated 14-1
“Generic” Collection Classes 14
This chapter describes the second kind of collection classes included in the
Tools.h++ Class Library: generic collection classes. They are so-called because
they use the macros defined in
<generic.h>
, an early approximation to
parameterized types, first described in Stroustrup (1986, p. 209). While they
can be more unwieldy than true templates
1
, they do offer the advantage of
being portable to any C++ compiler, even older compilers.
Most of the "generic" collection classes use reference-based semantics (that is,
they store and retrieve pointers to other objects). Like the other reference-
based Tools.h++ collection classes, you are responsible for the allocation and
deallocation of the objects themselves. However, the three vector-based
collection classes,
RWGVector
(val),
RWGOrderedVector
(val), and
RWGSortedVector
(val) use value-based semantics and store the type itself
(which could be a pointer to an object).
The storage and retrieval methods and criteria differ from class to class.
1. Actually, the generic macros are very easy to use, they are just difficult to write. Because they are
preprocessor macros, they must be “all on one line,” making them very difficult to debug.