ocean.util.container.map.HashMap

Template for a class implementing a mapping from hashes to a user-specified type.

The interface of the class has been kept deliberately simple, purely handling the management of the mapping. The handling of the mapping values is left entirely up to the user -- all methods simply return a pointer to the mapping value which the user can do what they like with. (This is an intentional design decision, in order to reduce the complexity of the template.)

The HashMap is designed as a replacement for ocean.core.ArrayMap. It has several advantages: 1. Memory safety. As the ArrayMap's buckets are implemented as dynamic arrays, each bucket will theoretically grow continually in size over extended periods of use. Even when clear()ed, the buffers allocated for the buckets will not reduce in size. The HashMap, on the other hand, uses a pool of elements, meaning that the memory allocated for each bucket is truly variable. 2. Code simplicity via removing optional advanced features such as thread safety and value array copying. 3. Extensibility. Functionality is split into several modules, including a base class for easier reuse of components.

A usage example with various types stored in mappings is below in the unit tests.

Members

Classes

HashMap
class HashMap(V)

HashMap class template. Manages a mapping from hash_t to the specified type.

Meta

License

Boost Software License Version 1.0. See LICENSE_BOOST.txt for details. Alternatively, this file may be distributed under the terms of the Tango 3-Clause BSD License (see LICENSE_BSD.txt for details).