Additional selection criteria – HP Integrity NonStop J-Series User Manual
Page 297

When data is accessed by comparison with self, it is also necessary to know what kind of match
is used: matching may be based on equality, which directly compares one object with another, or
based on identity, which compares object addresses to see if the objects are the same.
Is the best method of access by following linked nodes? Collections that make use of linked
nodes are usually called lists. Lists provide quick access to data at each end of the collection, and
allow you to insert data efficiently into the middle of the collection. However, if you need
repeated access to data in the middle of the collection, lists are not as efficient as some other
collections.
7.
Will most of your access to data be at the ends of a collection? There are many occasions
when you need to handle an unknown amount of data, but most of that data handling will apply
to data that was most recently or least recently put into the collection. A collection that is
particularly efficient at handling data that was most recently added is said to have a "last in, first
out" policy. A last in, first out (LIFO) container is a stack. A collection that handles the data in a
"first in first out" (FIFO) manner is called a queue. Finally, a collection that allows efficient
access to both the most recently and least recently added data is called a deque, or double ended
queue.
8.
For linked lists--Do you need to access the data from only one end of the list , or from both
ends? Singly-linked lists are smaller, but they allow access only from the "front" of the list.
Doubly-linked lists have a more flexible access policy, but at the cost of requiring an additional
pointer for every stored object.
9.
For collections that are accessed by numeric index--Do you need the collection to
automatically resize? If you know the maximum number of items that will be stored in the
collection, you can make insertion and removal slightly more efficient by choosing a collection
with a fixed size. On the other hand, if you need to allow for nearly unlimited expansion, you
should choose a collection that will automatically adjust itself to the amount of data it is currently
storing.
10.
Additional Selection Criteria
Which collection you choose will depend of many things (not the least of which will be your experience
and intuition). In addition to the decision tree, the following questions will also influence your choice of
container.
Do I need to maintain a single object in multiple collections? Use a pointer-based collection.
1.
Am I collecting objects that are very expensive to copy? Use a pointer-based collection.
2.
Is there no compelling reason to use a pointer-based collection? Use a value-based collection.
3.
Do I want to control the order of the objects within the collection externally? Use a
sequential collection such as a vector or list.
4.
Should the items within the collection be mutable (not fixed) after they are inserted? Use a
sequential or mapping (dictionary) collection. Maps and dictionaries have immutable keys but
mutable values.
5.
Would I prefer that the collection maintain its own order based on object comparison? Use
a set, map, or sorted collection.
6.