hawl-2006.6.4ContentsIndex
Hawl.Data.Trie
Contents
Construction
Query
Destruction
Key manipulation
Synopsis
data Trie a b = Node !(Map a (Trie a b)) !(Maybe b)
empty :: Trie a b
fromList :: Ord a => [([a], b)] -> Trie a b
fromListWith :: Ord a => (b -> b -> b) -> [([a], b)] -> Trie a b
fromListWith' :: Ord a => (b -> c -> b) -> (c -> b) -> [([a], c)] -> Trie a b
insert :: Ord a => [a] -> b -> Trie a b -> Trie a b
insertWith :: Ord a => (b -> b -> b) -> [a] -> b -> Trie a b -> Trie a b
insertWith' :: Ord a => (b -> c -> b) -> (c -> b) -> [a] -> c -> Trie a b -> Trie a b
lookup :: (Monad m, Ord a) => [a] -> Trie a b -> m b
member :: Ord a => [a] -> Trie a b -> Bool
toList :: Trie a b -> [([a], b)]
toTree :: ([a] -> Maybe b -> c) -> Trie a b -> Tree c
addPrefix :: a -> Maybe b -> Trie a b -> Trie a b
Documentation
data Trie a b
Constructors
Node !(Map a (Trie a b)) !(Maybe b)
Construction
empty :: Trie a b
An empty trie
fromList :: Ord a => [([a], b)] -> Trie a b
Construct a trie from a list of (key, value) pairs.
fromListWith :: Ord a => (b -> b -> b) -> [([a], b)] -> Trie a b
Construct a trie from a list of (key, value) pairs with a combining function for values of equals keys. The order in which the elements are inserted and passed to the combining function is unspecified.
fromListWith' :: Ord a => (b -> c -> b) -> (c -> b) -> [([a], c)] -> Trie a b
Construct a trie from a list of (key, value) pairs with a combining function for values of equals keys, and a construction function used the first time a key is inserted. The order in which the elements are inserted and passed to the combining function is unspecified.
insert :: Ord a => [a] -> b -> Trie a b -> Trie a b
Insert an element into a trie.
insertWith
:: Ord a
=> (b -> b -> b)The first argument is the existing value, the second is the new value.
-> [a]
-> b
-> Trie a b
-> Trie a b
Insert an element into a trie with a combining function for the value of an existing key equal to the given one.
insertWith'
:: Ord a
=> (b -> c -> b)The first argument is the existing value, the second is the new value.
-> (c -> b)Used to transform the input value to a value in the map if there is no existing value.
-> [a]
-> c
-> Trie a b
-> Trie a b
Insert an element into a trie with a combining function for the value of an existing key equal to the given one, and a construction function used the first time a key is inserted.
Query
lookup :: (Monad m, Ord a) => [a] -> Trie a b -> m b
Lookup a key in a trie.
member :: Ord a => [a] -> Trie a b -> Bool
Check if a key is in a trie.
Destruction
toList :: Trie a b -> [([a], b)]
Get the (key,value) pairs from a trie. The results are ordered by key.
toTree :: ([a] -> Maybe b -> c) -> Trie a b -> Tree c
Convert a Trie to a Tree.
Key manipulation
addPrefix
:: aPrefix to ad to the keys.
-> Maybe bValue for the new [] key.
-> Trie a b
-> Trie a b
Add a prefix to all keys in the map.
Produced by Haddock version 0.7