Selecting a tools.h++ collection class, How to use the decision tree – HP Integrity NonStop J-Series User Manual
Page 296

Click on the banner to return to the user guide home page.
©Copyright 1996 Rogue Wave Software
Selecting a Tools.h++ Collection Class
The decision tree diagram includes questions about the data you plan to store in your collection. By
traversing the tree you can quickly see which Tools.h++ collection classes will best suit your data and
programming project.
How to Use the Decision Tree
The questions that appear on the decision tree are brief, so that the diagram will be easy to read. The
following questions expand upon the questions in the decision tree.
Is the order of data in the collection meaningful? Some collections allow you to control the
location of data within the collection. For example, arrays or vectors, and linked lists present data
in order. If you need to access data in a particular order, or based on a numeric index, then order
is meaningful.
1.
Are duplicate entries allowed? Some collections, usually called sets, will not allow you to
insert an item equal to an item that is already in the collection. Other collections do permit
duplicates, and have various ways to hold multiple matching items. Tools.h++ collections
provide mechanisms for both checking for duplication and holding the duplicates.
2.
Is the order determined intrinsically or externally? If data within the collection is controlled
by the way you insert it, we say that the order is determined externally. For example, a vector, or
a linked list is externally ordered. If the data is stored at a place determined by an algorithm used
by the collection, then the ordering is intrinsic. For example, a sorted vector, or a balanced tree
has intrinsic ordering.
3.
Is data accessed by an external key? If you access a value based on a key that is not the same
as the value, we say that data is accessed by an external key. For example, a "phone list"
associates data, in the form of telephone numbers, with keys, in the form of names. Conversly, a
list of committee members is simply a set of data in the form of names. You do not need a key to
get at the information.
4.
Is data accessed by a numeric index? Objects stored in an array or vector are accessed by
numeric index. For example, you access an object at location 12 by using the numeric index "12"
to find it.
5.
Is data accessed by "comparison with self?" Data that is stored with neither an explicit index
nor an explicit key can be found by looking for a match between what you need to find and what
is contained. The list of committee members mentioned in item 4 is and example of this type of
data. Sets or bags are examples of collections that are accessed by comparison with self.
6.