balanced-binary-search-tree-1.0.0.0: Type safe BST and AVL trees
Copyright(c) Nicolás Rodríguez 2021
LicenseGPL-3
MaintainerNicolás Rodríguez
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

Data.Tree.AVL.Extern.Balance

Description

Implementation of the balancing algorithm over ITree trees for externalist AlmostAVL trees.

Synopsis

Documentation

class Balanceable (t :: Tree) where Source #

This type class provides the functionality to balance a tree t without checking any structural invariant (key ordering or height balance). The insertion is defined at the value level and the type level; the verification of the BST/AVL restrictions is performed after the insertion.

Associated Types

type Balance (t :: Tree) :: Tree Source #

Methods

balance :: ITree t -> ITree (Balance t) Source #

Instances

Instances details
Balanceable 'EmptyTree Source # 
Instance details

Defined in Data.Tree.AVL.Extern.Balance

Associated Types

type Balance 'EmptyTree :: Tree Source #

(us ~ UnbalancedState (Height l) (Height r), Balanceable' ('ForkTree l (Node n a) r) us) => Balanceable ('ForkTree l (Node n a) r) Source # 
Instance details

Defined in Data.Tree.AVL.Extern.Balance

Associated Types

type Balance ('ForkTree l (Node n a) r) :: Tree Source #

Methods

balance :: ITree ('ForkTree l (Node n a) r) -> ITree (Balance ('ForkTree l (Node n a) r)) Source #

class Balanceable' (t :: Tree) (us :: US) where Source #

This type class provides the functionality to balance a tree t without checking any structural invariant (key ordering or height balance). It's only used by the Balanceable class and it has one extra parameter us, which is the UnbalancedState of the two sub trees of t.

Associated Types

type Balance' (t :: Tree) (us :: US) :: Tree Source #

Methods

balance' :: ITree t -> Proxy us -> ITree (Balance' t us) Source #

Instances

Instances details
(bs ~ BalancedState (Height rl) (Height rr), Rotateable ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) 'RightUnbalanced bs) => Balanceable' ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) 'RightUnbalanced Source # 
Instance details

Defined in Data.Tree.AVL.Extern.Balance

Associated Types

type Balance' ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) 'RightUnbalanced :: Tree Source #

Methods

balance' :: ITree ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) -> Proxy 'RightUnbalanced -> ITree (Balance' ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) 'RightUnbalanced) Source #

Balanceable' ('ForkTree l (Node n a) r) 'NotUnbalanced Source # 
Instance details

Defined in Data.Tree.AVL.Extern.Balance

Associated Types

type Balance' ('ForkTree l (Node n a) r) 'NotUnbalanced :: Tree Source #

(bs ~ BalancedState (Height ll) (Height lr), Rotateable ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) 'LeftUnbalanced bs) => Balanceable' ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) 'LeftUnbalanced Source # 
Instance details

Defined in Data.Tree.AVL.Extern.Balance

Associated Types

type Balance' ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) 'LeftUnbalanced :: Tree Source #

Methods

balance' :: ITree ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) -> Proxy 'LeftUnbalanced -> ITree (Balance' ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) 'LeftUnbalanced) Source #

class Rotateable (t :: Tree) (us :: US) (bs :: BS) where Source #

This type class provides the functionality to apply a rotation to a tree t without checking any structural invariant (key ordering or height balance). The rotation is defined at the value level and the type level; the verification of the BST/AVL restrictions is performed after the insertion.

Associated Types

type Rotate (t :: Tree) (us :: US) (bs :: BS) :: Tree Source #

Methods

rotate :: ITree t -> Proxy us -> Proxy bs -> ITree (Rotate t us bs) Source #

Instances

Instances details
Rotateable ('ForkTree l (Node n a) ('ForkTree ('ForkTree rll (Node rln rla) rlr) (Node rn ra) rr)) 'RightUnbalanced 'LeftHeavy Source # 
Instance details

Defined in Data.Tree.AVL.Extern.Balance

Associated Types

type Rotate ('ForkTree l (Node n a) ('ForkTree ('ForkTree rll (Node rln rla) rlr) (Node rn ra) rr)) 'RightUnbalanced 'LeftHeavy :: Tree Source #

Methods

rotate :: ITree ('ForkTree l (Node n a) ('ForkTree ('ForkTree rll (Node rln rla) rlr) (Node rn ra) rr)) -> Proxy 'RightUnbalanced -> Proxy 'LeftHeavy -> ITree (Rotate ('ForkTree l (Node n a) ('ForkTree ('ForkTree rll (Node rln rla) rlr) (Node rn ra) rr)) 'RightUnbalanced 'LeftHeavy) Source #

Rotateable ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) 'RightUnbalanced 'Balanced Source # 
Instance details

Defined in Data.Tree.AVL.Extern.Balance

Associated Types

type Rotate ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) 'RightUnbalanced 'Balanced :: Tree Source #

Methods

rotate :: ITree ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) -> Proxy 'RightUnbalanced -> Proxy 'Balanced -> ITree (Rotate ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) 'RightUnbalanced 'Balanced) Source #

Rotateable ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) 'RightUnbalanced 'RightHeavy Source # 
Instance details

Defined in Data.Tree.AVL.Extern.Balance

Associated Types

type Rotate ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) 'RightUnbalanced 'RightHeavy :: Tree Source #

Methods

rotate :: ITree ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) -> Proxy 'RightUnbalanced -> Proxy 'RightHeavy -> ITree (Rotate ('ForkTree l (Node n a) ('ForkTree rl (Node rn ra) rr)) 'RightUnbalanced 'RightHeavy) Source #

Rotateable ('ForkTree ('ForkTree ll (Node ln la) ('ForkTree lrl (Node lrn lra) lrr)) (Node n a) r) 'LeftUnbalanced 'RightHeavy Source # 
Instance details

Defined in Data.Tree.AVL.Extern.Balance

Associated Types

type Rotate ('ForkTree ('ForkTree ll (Node ln la) ('ForkTree lrl (Node lrn lra) lrr)) (Node n a) r) 'LeftUnbalanced 'RightHeavy :: Tree Source #

Methods

rotate :: ITree ('ForkTree ('ForkTree ll (Node ln la) ('ForkTree lrl (Node lrn lra) lrr)) (Node n a) r) -> Proxy 'LeftUnbalanced -> Proxy 'RightHeavy -> ITree (Rotate ('ForkTree ('ForkTree ll (Node ln la) ('ForkTree lrl (Node lrn lra) lrr)) (Node n a) r) 'LeftUnbalanced 'RightHeavy) Source #

Rotateable ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) 'LeftUnbalanced 'Balanced Source # 
Instance details

Defined in Data.Tree.AVL.Extern.Balance

Associated Types

type Rotate ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) 'LeftUnbalanced 'Balanced :: Tree Source #

Methods

rotate :: ITree ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) -> Proxy 'LeftUnbalanced -> Proxy 'Balanced -> ITree (Rotate ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) 'LeftUnbalanced 'Balanced) Source #

Rotateable ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) 'LeftUnbalanced 'LeftHeavy Source # 
Instance details

Defined in Data.Tree.AVL.Extern.Balance

Associated Types

type Rotate ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) 'LeftUnbalanced 'LeftHeavy :: Tree Source #

Methods

rotate :: ITree ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) -> Proxy 'LeftUnbalanced -> Proxy 'LeftHeavy -> ITree (Rotate ('ForkTree ('ForkTree ll (Node ln la) lr) (Node n a) r) 'LeftUnbalanced 'LeftHeavy) Source #