red-black-tree-0.1.0.0: Red Black Trees implemented in Haskell
Copyright(c) 2017 Gabriel Aumala
LicenseBSD3
Maintainergabriel@criptext.com
Stabilityexperimental
PortabilityGHC
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

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:

  1. A tree with only 1 item. (IsRoot).
  2. A tree with a 2 level herarchy: parent and child. ()HasParent).
  3. A tree with a hierarchy of at least 3 levels: grandparent, parent and child. (HasGrandparent)