TernaryTrees- Efficient pure ternary tree Sets and Maps




data CharEl a b Source

Elem2 a b is used to hold elements of a list after insertion, and indicate that we've reached the end of the list.


C !Char 
Val b 


Show b => Show (CharEl a b) 

data StringMap a Source

StringMap a is ternary tree. It is commonly used for storing word lists like dictionaries for spell checking etc.


SNode !Char !(StringMap a) !(StringMap a) !(StringMap a) 
SElemNode a !(StringMap a) !(StringMap a) !(StringMap a) 


Eq a => Eq (StringMap a) 
Show a => Show (StringMap a) 
Binary a => Binary (StringMap a) 

insert :: String -> a -> StringMap a -> StringMap aSource

Inserts a new list of elements into a tree.

insert' :: String -> a -> StringMap aSource

Quickly build an initial tree.

isElem :: String -> StringMap a -> BoolSource

Returns true if the string is in the StringMap

treeSize :: StringMap a -> IntSource

Returns the number of non-Null Elems

numEntries :: StringMap a -> IntSource

Counts how many entries there are in the tree.

fromList :: [(String, a)] -> StringMap aSource

Creates a new tree from a list of strings