A simple trie data structure which maps strings to values.
Author: Lasse Züngel
Version: October 2024
empty
:: Trie a An empty trie. |
null
:: Trie a -> Bool Returns true iff the trie is empty. |
size
:: Trie a -> Int Returns the size of the trie. |
singleton
:: String -> a -> Trie a A singleton trie. |
insert
:: String -> a -> Trie a -> Trie a Inserts a value into the trie. |
update
:: String -> (Maybe a -> a) -> Trie a -> Trie a Updates or inserts a value in the trie. |
delete
:: String -> Trie a -> Trie a Removes a key from the trie. |
lookup
:: String -> Trie a -> Maybe a Looks up a value in the trie. |
containsKey
:: Trie a -> String -> Bool Checks whether a key is in the trie. |
fromList
:: [(String,a)] -> Trie a Converts a list of key-value pairs into a trie. |
toList
:: Trie a -> [(String,a)] Converts a trie into a list of key-value pairs. |
Trie data structure
Constructors:
An empty trie.
|
Returns the size of the trie.
|
Removes a key from the trie. If the key is not in the trie, the trie is returned unchanged. |
Checks whether a key is in the trie. |