next up previous
Next: Restrictions on key Up: Collection hierarchy Previous: Why is external

A comparison between Databases and KeyDatabases

If you need the power of a database (which can compare externally-meaningful keys, such as strings or integers), the seldom-used ``key'' databases can be a better choice than the ``regular'' databases.

The ``regular'' databases (Database and RefDatabase) copy (with a copy constructor) their key argument on insert, while the ``key'' databases (KeyDatabase and RefKeyDatabase) take over ownership of their key argument.

Creating a cloned copy frees the database from worrying about changes to the original object which might invalidate the comparison order, but can be less efficient if the original object is available to be owned by the database.

There are two situations in which a ``key'' database is a better choice than a ``regular'' database.





Jay Hoeflinger
Mon Apr 21 11:52:18 CDT 1997