Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Data.Bytes.HashMap
Contents
Description
Implementation of static hash map data structure.
Synopsis
- data Map v
- empty :: 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)
- elements :: Map v -> [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
Foldable Map Source # | |
Defined in Data.Bytes.HashMap.Internal Methods fold :: Monoid m => Map m -> m # foldMap :: Monoid m => (a -> m) -> Map a -> 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 # | |
Functor 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.
Arguments
:: forall v. CryptHandle | Source of randomness |
-> (v -> v -> v) | |
-> [(Bytes, v)] | |
-> IO (Map v) |
elements :: Map v -> [v] Source #
Recover the elements of the hashmap. These are ordered lexicographically by their corresponding keys. That is, this function returns the same output regardless of the entropy used to build the hashmap.
Used for testing
data HashMapException Source #
Constructors
HashMapException !Int [Bytes] [[(Word, Bytes)]] |
Instances
Exception HashMapException Source # | |
Defined in Data.Bytes.HashMap Methods toException :: HashMapException -> SomeException # | |
Show HashMapException Source # | |
Defined in Data.Bytes.HashMap Methods showsPrec :: Int -> HashMapException -> ShowS # show :: HashMapException -> String # showList :: [HashMapException] -> ShowS # | |
Eq HashMapException Source # | |
Defined in Data.Bytes.HashMap Methods (==) :: HashMapException -> HashMapException -> Bool # (/=) :: HashMapException -> HashMapException -> Bool # |
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.