Portability | portable |
---|---|
Stability | stable |
Maintainer | pxqr.sta@gmail.com |
Safe Haskell | Safe-Inferred |
This module defines a simple key/value list which both faster and more suitable for bencode dictionaries then just [(k,v)].
- type BKey = ByteString
- data BDictMap a
- empty :: BDictMap a
- singleton :: BKey -> a -> BDictMap a
- null :: BDictMap a -> Bool
- member :: BKey -> BDictMap a -> Bool
- lookup :: BKey -> BDictMap a -> Maybe a
- union :: BDictMap a -> BDictMap a -> BDictMap a
- map :: (a -> b) -> BDictMap a -> BDictMap b
- bifoldMap :: Monoid m => (BKey -> a -> m) -> BDictMap a -> m
- fromAscList :: [(BKey, a)] -> BDictMap a
- toAscList :: BDictMap a -> [(BKey, a)]
Documentation
type BKey = ByteStringSource
BDictMap is an ascending list of key/value pairs sorted by keys.
Construction
Query
Combine
union :: BDictMap a -> BDictMap a -> BDictMap aSource
O(n + m). Merge two dictionaries by taking pair from both given dictionaries. Dublicated keys are not filtered.
Traversal
map :: (a -> b) -> BDictMap a -> BDictMap bSource
O(n). Map a function over all values in the dictionary.
bifoldMap :: Monoid m => (BKey -> a -> m) -> BDictMap a -> mSource
O(n). Map each key/value pair to a monoid and fold resulting
sequnce using mappend
.
Conversion
fromAscList :: [(BKey, a)] -> BDictMap aSource
O(n). Build a dictionary from a list of key/value pairs where the keys are in ascending order.