| Copyright | (c) 2017 Gabriel Aumala |
|---|---|
| License | BSD3 |
| Maintainer | gabriel@criptext.com |
| Stability | experimental |
| Portability | GHC |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.RedBlackTree.TreeFamily
Description
TreeFamily is a structure that is used to describe the hierarchy of a tree
in which a new branch has been isenrted at the bottom. With this we can quickly answer
questions like is the new branch the root? Does it only have parent? Does have
a grandparent or more ancestors?. This is used internally by
Data.RedBlackTree.InsertionAlgorithm to identify insertion cases and handle
the appropriately.
Synopsis
- getTreeFamily :: BinaryTreeNode a => BranchZipper a -> TreeFamily a
- data TreeFamily a
- = IsRoot (TreeBranch a)
- | HasParent (TreeDirection a) (TreeBranch a)
- | HasGrandparent (TreeDirections a) (TreeDirection a) (TreeDirection a) (TreeBranch a)
Documentation
getTreeFamily :: BinaryTreeNode a => BranchZipper a -> TreeFamily a Source #
Takes a zipper focusing on a branch and returns a TreeFamily structure
relative to that branch.
data TreeFamily a Source #
Describes the hierarchy 3 kinds of non empty trees:
- A tree with only 1 item. (
IsRoot). - A tree with a 2 level herarchy: parent and child. ()
HasParent). - A tree with a hierarchy of at least 3 levels: grandparent, parent and
child. (
HasGrandparent)
Constructors
| IsRoot (TreeBranch a) | |
| HasParent (TreeDirection a) (TreeBranch a) | |
| HasGrandparent (TreeDirections a) (TreeDirection a) (TreeDirection a) (TreeBranch a) |