TernaryTrees-0.2.0.2: Efficient pure ternary tree Sets and Maps

Data.Map.TernaryMap

Synopsis

Documentation

data TernaryMap k v Source

TernaryMap k v is ternary tree. It is commonly used for storing word lists like dictionaries.

Instances

Functor (TernaryMap k) 
(Eq k, Eq v) => Eq (TernaryMap k v) 
(Show k, Show v) => Show (TernaryMap k v) 
(Binary k, Binary v) => Binary (TernaryMap k v)

A rather long Binary instance, that uses binary numbers to indicate where Ends are efficiently.

insert :: Ord k => [k] -> v -> TernaryMap k v -> TernaryMap k vSource

Inserts an entrie into a tree. Values with the same key will be replaced with the newer value.

singleton :: Ord k => [k] -> v -> TernaryMap k vSource

Quickly build a tree without an initial tree. This should be used to create an initial tree, using insert there after.

member :: Ord k => [k] -> TernaryMap k v -> BoolSource

Returns true if the `[k]` is a key in the TernaryMap.

size :: TernaryMap k v -> IntSource

Counts how many entries there are in the tree.

fromList :: Ord k => [([k], v)] -> TernaryMap k vSource

Creates a new tree from a list of strings

lookup :: Ord k => [k] -> TernaryMap k v -> Maybe vSource

(!) :: Ord k => TernaryMap k v -> [k] -> Maybe vSource

findWithDefault :: Ord k => v -> [k] -> TernaryMap k v -> vSource

insertWith :: Ord k => (v -> v -> v) -> [k] -> v -> TernaryMap k v -> TernaryMap k vSource

Inserts a new value into the tree with a given function that combines the new value and the old value together to for a new entry.

 insertWith f key newval (fromList [(notkey,val1),(key,oldval)]) == fromList [(notkey,val1),(key,f newval oldval)]

insertWithKey :: Ord k => ([k] -> v -> v -> v) -> [k] -> v -> TernaryMap k v -> TernaryMap k vSource

Inserts a new value into the tree with a given function that combines the new value and the old value together to for a new entry.

 insertWithKey f key newval (fromList [(notkey,val1),(key,oldval)]) == fromList [(notkey,val1),(key,f key newval oldval)]

keys :: TernaryMap k v -> [[k]]Source

Returns a (sorted) list of all keys in the map.

assocs :: TernaryMap k v -> [([k], v)]Source

Returns a (sorted) list of all keys in the map.

elems :: TernaryMap k v -> [v]Source

Makes a list of all the values in the map.

null :: TernaryMap k v -> BoolSource

Returns true if the map is empty.