Fixed key map class template.
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).
Copyright (c) 2009-2016 dunnhumby Germany GmbH. All rights reserved.
Map template with a fixed set of keys.
Map template with a fixed set of keys, specified in the class' constructor. If an item is added whose key is not in the fixed set, an exception is thrown.
Such a map can be faster than a standard hash map, as the fixed set of possible keys means that a fast binary search can be used to find the index of the corresponding value. This of course only holds true when the time taken to generate a hash from a key would be slower than the time taken to do a binary search over the key. In the case of char[] keys, tests have shown that for keys of 5 characters or longer, the FixedKeyMap starts to be faster than the StandardKeyHashingMap, and that in the case of long keys (100 characters) it is an order of magnitude faster.
Usage example: