Key and Value Types
There are several restrictions on the key and value types:
In addition to these restrictions, it must be possible to compare keys for
sorting purposes. In other words, if k1 and k2
are two keys,
k1<k2 must be welldefined. Moreover, when <
is applied to two keys, it must be a "strong total order relation".
That is, it must have the following properties:

k1<k1 must never hold for any key
k1.

For any two keys k1 and k2,
either k1<k2, k2<k1, or
k1 and k2 are equal. No more than one of these
conditions may hold for any particular values of k1 and
k2.

For any three keys k1, k2,
and k3, if k1<k2 and k2<k3
both hold then k1<k3 must also hold.
Notice that we do not require that k1==k2 or k1>k2
be defined because we can infer k1>k2 from
k2<k1 and k1==k2 from !(k1<k2k2<k1).
The integral types (int, short,
char, and long) and the String
class all have an appropriate definition for <. The floatingpoint
types are a different matter:
some machines support a special floatingpoint ``notanumber''
value (NaN) that is neither less than, greater than, or equal to anything
else.
Using floatingpoint keys on such a machine invites disaster if a key is ever
NaN. Floatingpoint values cause no trouble.
Next topic:
Using a Map
Previous topic:
Defining Map Classes
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0  02 June 2005