TernaryTrees-0.2.0.2: Efficient pure ternary tree Sets and Maps

Data.Map.StringMap

Synopsis

Documentation

data StringMap v Source

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

Instances

Functor StringMap 
Eq v => Eq (StringMap v) 
Show v => Show (StringMap v) 
Binary v => Binary (StringMap v)

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

insert :: String -> v -> StringMap v -> StringMap vSource

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

singleton :: String -> v -> StringMap vSource

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

member :: String -> StringMap v -> BoolSource

Returns true if the String is a key in the TernaryMap.

size :: StringMap v -> IntSource

Counts how many entries there are in the tree.

fromList :: [(String, v)] -> StringMap vSource

Creates a new tree from a list of strings

insertWith :: (v -> v -> v) -> String -> v -> StringMap v -> StringMap 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 :: (String -> v -> v -> v) -> String -> v -> StringMap v -> StringMap 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 :: StringMap v -> [String]Source

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

assocs :: StringMap v -> [(String, v)]Source

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

elems :: StringMap v -> [v]Source

Makes a list of all the values in the map.

null :: StringMap v -> BoolSource

Returns true if the map is empty.