Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Provides a typeclass for all binary search trees and an unbalanced implementation
Synopsis
- class Ord o => Indexable i o v | i -> o, i -> v where
- class Indexable i o v => AnyBST t i o v where
- anyBstInsert :: i -> t i -> t i
- anyBstRemove :: o -> t i -> t i
- anyBstMax :: t i -> Maybe i
- anyBstMin :: t i -> Maybe i
- anyBstLookup :: o -> t i -> Maybe v
- anyBstEmpty :: t i
- anyBstHead :: t i -> Maybe i
- anyBstInorder :: t i -> [i]
- data BST a
- bstInsert :: Indexable i o v => i -> BST i -> BST i
- bstRemove :: Indexable i o v => o -> BST i -> BST i
- bstMax :: BST i -> Maybe i
- bstMin :: BST i -> Maybe i
- bstLookup :: Indexable i o v => o -> BST i -> Maybe v
- bstContains :: Indexable i o v => o -> BST i -> Bool
- bstHead :: Indexable i o v => BST i -> Maybe i
- bstInorder :: Indexable i o v => BST i -> [i]
Documentation
class Ord o => Indexable i o v | i -> o, i -> v where Source #
Only instances of Indexable may be saved in a BST
Instances
Indexable Int Int Int Source # | |
Indexable (Node a) NodeId (Node a) Source # | |
Ord o => Indexable (o, a) o a Source # | |
Ord o => Indexable (o, a, b) o (a, b) Source # | |
Ord o => Indexable (o, a, b, c) o (a, b, c) Source # | |
Ord o => Indexable (o, a, b, c, d) o (a, b, c, d) Source # | |
Ord o => Indexable (o, a, b, c, d, e) o (a, b, c, d, e) Source # | |
class Indexable i o v => AnyBST t i o v where Source #
Typeclass for all BSTs that store the given Indexable
anyBstInsert :: i -> t i -> t i Source #
Insert into the tree
anyBstRemove :: o -> t i -> t i Source #
Remove from the tree
anyBstMax :: t i -> Maybe i Source #
Get the greatest element
anyBstMin :: t i -> Maybe i Source #
Get the least element
anyBstLookup :: o -> t i -> Maybe v Source #
Lookup a given key
anyBstEmpty :: t i Source #
An empty tree
anyBstHead :: t i -> Maybe i Source #
The root of the tree
anyBstInorder :: t i -> [i] Source #
Traverse the tree in order
Instances
An unbalanced binary search tree
Instances
Indexable i o v => AnyBST BST i o v Source # | |
Defined in Data.Chatty.BST anyBstInsert :: i -> BST i -> BST i Source # anyBstRemove :: o -> BST i -> BST i Source # anyBstMax :: BST i -> Maybe i Source # anyBstMin :: BST i -> Maybe i Source # anyBstLookup :: o -> BST i -> Maybe v Source # anyBstEmpty :: BST i Source # anyBstHead :: BST i -> Maybe i Source # anyBstInorder :: BST i -> [i] Source # | |
None (BST a) Source # | |
Defined in Data.Chatty.BST |
bstInorder :: Indexable i o v => BST i -> [i] Source #
Traverse the tree in order