A map from keys to values. A map cannot contain duplicate keys; each key can map to at most one value.
Constructors
EmptyInvariants:
Empty is not a valid sub-node. It can only appear at the root. (INV1)
BitmapIndexed !Bitmap !(Array (HashMap k v))Invariants:
Only the lower
maxChildrenbits of the Bitmap may be set. The remaining upper bits must be 0. (INV2)The array of a BitmapIndexed node stores at least 1 and at most
maxChildren - 1sub-nodes. (INV3)The number of sub-nodes is equal to the number of 1-bits in its Bitmap. (INV4)
If a BitmapIndexed node has only one sub-node, this sub-node must be a BitmapIndexed or a Full node. (INV5)
Leaf !Hash !(Leaf k v)Full !(Array (HashMap k v))Invariants:
The array of a Full node stores exactly maxChildren sub-nodes. (INV8)
Collision !Hash !(Array (Leaf k v))Invariants:
The location of a Leaf or Collision node in the tree must be compatible with its Hash. (INV6) (TODO: Document this properly (#425))
The array of a Collision node must contain at least two sub-nodes. (INV9)
The hash of each key in a Collision node must be the one stored in the node. (INV7)
No two keys stored in a Collision can be equal according to their Eq instance. (INV10)
Instances27Bifoldable, Eq2, Ord2, Show2, NFData2, Hashable2, …
Bifoldable HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.InternalEq2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.InternalOrd2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.InternalShow2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.InternalNFData2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.InternalHashable2 HashMapDefined in unordered-containers-0.2.21 · Data.HashMap.Internal(Lift k, Lift v) => Lift (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalFunctor (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalFoldable (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalTraversable (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalEq k => Eq1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalOrd k => Ord1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal(Hashable k, Read k) => Read1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalShow k => Show1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalNFData k => NFData1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalHashable k => Hashable1 (HashMap k)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalHashable k => IsList (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal(Eq k, Eq v) => Eq (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalNote that, in the presence of hash collisions, equal
HashMaps may behave differently, i.e. extensionality may be violated:Example2 expressions data D = A | B deriving (Eq, Show)instance Hashable D where hashWithSalt salt _d = salt
Example2 expressions x = fromList [(A,1), (B,2)]y = fromList [(B,2), (A,1)]
Example3 expressions x == yTruetoList x[(A,1),(B,2)]toList y[(B,2),(A,1)]
In general, the lack of extensionality can be observed with any function that depends on the key ordering, such as folds and traversals.
(Data k, Data v, Hashable k) => Data (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal(Ord k, Ord v) => Ord (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalThe ordering is total and consistent with the Eq instance. However, nothing else about the ordering is specified, and it may change from version to version of either this package or of
hashable.(Hashable k, Read k, Read e) => Read (HashMap k e)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal(Show k, Show v) => Show (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalHashable k => Semigroup (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.InternalHashable k => Monoid (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal(NFData k, NFData v) => NFData (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal(Hashable k, Hashable v) => Hashable (HashMap k v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internaltype Item (HashMap k v) = (k, v)Defined in unordered-containers-0.2.21 · Data.HashMap.Internal