hunt.collection.HashMap

Undocumented in source.

Members

Classes

HashMap
class HashMap(K, V)
HashMapNode
class HashMapNode(K, V)

Basic hash bin node, used for most entries. (See below for TreeNode subclass, and in LinkedHashMap for its Entry subclass.)

LinkedHashMapEntry
class LinkedHashMapEntry(K, V)

HashMap.Node subclass for normal LinkedHashMap entries.

TreeNode
class TreeNode(K, V)

Entry for Tree bins. Extends LinkedHashMap.Entry (which in turn extends Node) so can be used as extension of either regular or linked node.

Functions

hash
size_t hash(K key)

Computes key.toHash() and spreads (XORs) higher bits of hash to lower. Because the table uses power-of-two masking, sets of hashes that vary only in bits above the current mask will always collide. (Among known examples are sets of Float keys holding consecutive whole numbers in small tables.) So we apply a transform that spreads the impact of higher bits downward. There is a tradeoff between speed, utility, and quality of bit-spreading. Because many common sets of hashes are already reasonably distributed (so don't benefit from spreading), and because we use trees to handle large sets of collisions in bins, we just XOR some shifted bits in the cheapest possible way to reduce systematic lossage, as well as to incorporate impact of the highest bits that would otherwise never be used in index calculations because of table bounds.

tableSizeFor
int tableSizeFor(int cap)

Returns a power of two size for the given target capacity.

Meta