Safe Haskell | None |
---|---|
Language | Haskell2010 |
Implementation of static hash map data structure.
Synopsis
- data Map v
- lookup :: Bytes -> Map v -> Maybe v
- fromList :: CryptHandle -> [(Bytes, v)] -> IO (Map v)
- fromTrustedList :: [(Bytes, v)] -> Map v
- fromListWith :: forall v. CryptHandle -> (v -> v -> v) -> [(Bytes, v)] -> IO (Map v)
- data HashMapException = HashMapException !Int [Bytes] [[(Word, Bytes)]]
- distribution :: Map v -> [(Int, Int)]
- distinctEntropies :: Map v -> Int
Documentation
A static perfect hash table where the keys are byte arrays. This table cannot be updated after its creation, but all lookups have guaranteed O(1) worst-case cost. It consumes linear space. This is an excellent candidate for use with compact regions.
Instances
Functor Map Source # | |
Foldable Map Source # | |
Defined in Data.Bytes.HashMap.Internal fold :: Monoid m => Map m -> m # foldMap :: Monoid m => (a -> m) -> Map a -> m # foldr :: (a -> b -> b) -> b -> Map a -> b # foldr' :: (a -> b -> b) -> b -> Map a -> b # foldl :: (b -> a -> b) -> b -> Map a -> b # foldl' :: (b -> a -> b) -> b -> Map a -> b # foldr1 :: (a -> a -> a) -> Map a -> a # foldl1 :: (a -> a -> a) -> Map a -> a # elem :: Eq a => a -> Map a -> Bool # maximum :: Ord a => Map a -> a # | |
Traversable Map Source # | |
fromList :: CryptHandle -> [(Bytes, v)] -> IO (Map v) Source #
Build a static hash map. This may be used on input that comes from an adversarial user. It always produces a perfect hash map.
fromTrustedList :: [(Bytes, v)] -> Map v Source #
Build a map from keys that are known at compile time. All keys must be 64 bytes or less. This uses a built-in source of entropy and is entirely deterministic. An adversarial user could feed this function keys that cause it to error out rather than completing.
:: CryptHandle | Source of randomness |
-> (v -> v -> v) | |
-> [(Bytes, v)] | |
-> IO (Map v) |
Used for testing
data HashMapException Source #
HashMapException !Int [Bytes] [[(Word, Bytes)]] |
Instances
Eq HashMapException Source # | |
Defined in Data.Bytes.HashMap (==) :: HashMapException -> HashMapException -> Bool # (/=) :: HashMapException -> HashMapException -> Bool # | |
Show HashMapException Source # | |
Defined in Data.Bytes.HashMap showsPrec :: Int -> HashMapException -> ShowS # show :: HashMapException -> String # showList :: [HashMapException] -> ShowS # | |
Exception HashMapException Source # | |
Defined in Data.Bytes.HashMap |
distribution :: Map v -> [(Int, Int)] Source #
For each slot, gives the number of keys that hash to it after the first hash function has been applied.
distinctEntropies :: Map v -> Int Source #
The number of non-matching entropies being used.