Module Data.Trie

A simple trie data structure which maps strings to values.

Author: Lasse Züngel

Version: October 2024

Summary of exported operations:

empty :: Trie a  Deterministic 
An empty trie.
null :: Trie a -> Bool  Deterministic 
Returns true iff the trie is empty.
size :: Trie a -> Int  Deterministic 
Returns the size of the trie.
singleton :: String -> a -> Trie a  Deterministic 
A singleton trie.
insert :: String -> a -> Trie a -> Trie a  Deterministic 
Inserts a value into the trie.
delete :: String -> Trie a -> Trie a  Deterministic 
Removes a key from the trie.
lookup :: String -> Trie a -> Maybe a  Deterministic 
Looks up a value in the trie.
containsKey :: Trie a -> String -> Bool  Deterministic 
Checks whether a key is in the trie.
fromList :: [(String,a)] -> Trie a  Deterministic 
Converts a list of key-value pairs into a trie.
toList :: Trie a -> [(String,a)]  Deterministic 
Converts a trie into a list of key-value pairs.

Exported datatypes:


Trie

Trie data structure

Constructors:


Exported operations:

empty :: Trie a  Deterministic 

An empty trie.

Further infos:
  • solution complete, i.e., able to compute all solutions

null :: Trie a -> Bool  Deterministic 

Returns true iff the trie is empty.

size :: Trie a -> Int  Deterministic 

Returns the size of the trie.

Further infos:
  • solution complete, i.e., able to compute all solutions

singleton :: String -> a -> Trie a  Deterministic 

A singleton trie.

insert :: String -> a -> Trie a -> Trie a  Deterministic 

Inserts a value into the trie.

delete :: String -> Trie a -> Trie a  Deterministic 

Removes a key from the trie. If the key is not in the trie, the trie is returned unchanged.

lookup :: String -> Trie a -> Maybe a  Deterministic 

Looks up a value in the trie.

containsKey :: Trie a -> String -> Bool  Deterministic 

Checks whether a key is in the trie.

fromList :: [(String,a)] -> Trie a  Deterministic 

Converts a list of key-value pairs into a trie.

toList :: Trie a -> [(String,a)]  Deterministic 

Converts a trie into a list of key-value pairs.

Note that no guarantees are made about the order of the elements in the list.