rbst-0.0.0.1: Randomized Binary Search Trees

Copyright(c) 2020 Arnau Abella Dmitrii Kovanikov
LicenseMIT (see the file LECENSE)
MaintainerArnau Abella arnauabell@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

RBST.Pretty

Contents

Description

RBST visualization.

prettyPrint was copied from treap package wrote by Dmitrii Kovanikov.

Synopsis

Printing

Pretty printing

pretty :: (Show k, Show a) => RBST k a -> String Source #

Pretty 2-dimensional ASCII drawing of a RBST.

See prettyPrint for an example.

prettyPrint :: (Show k, Show a) => RBST k a -> IO () Source #

Call pretty function and output the result directly to stdout.

>>> let tree = (fromList $ zip ['a'..'e'] [1..5]) :: RBST Char Int
>>> prettyPrint  tree
               ('d',4) [5]
                       ╱╲
                      ╱  ╲
                     ╱    ╲
                    ╱      ╲
                   ╱        ╲
                  ╱          ╲
                 ╱            ╲
                ╱              ╲
               ╱                ╲
      ('b',2) [3]       ('e',5) [1]
           ╱╲
          ╱  ╲
         ╱    ╲
        ╱      ╲
       ╱        ╲
      ╱          ╲
('a',1) [1] ('c',3) [1]

Compact printing

compact :: (Show k, Show a) => RBST k a -> String Source #

Comptact 2-dimensional ASCII drawing of a RBST.

See comptactPrint for an example.

compactPrint :: (Show k, Show a) => RBST k a -> IO () Source #

Call comptact function and output the result directly to stdout.

>>> let tree = (fromList $ zip ['a'..'e'] [1..5]) :: RBST Char Int
>>> compactPrint  tree
('d',4) [5]
     |
     |-- ('e',5) [1]
     |
     \__ ('b',2) [3]
             |
             |-- ('c',3) [1]
             |
             \__ ('a',1) [1]