next node: HeapFilter,
prev node: HeapCompare,
up to node: Subsystem Heaps


HeapConv

Heaps can can be converted

Signature of HeapConv

List of Import References :
See BOOL
See Char
See DENOTATION
See Heap
See Nat
See Option
See Seq
See String
See Tree

SIGNATURE HeapConv[data, <]

$Date: 2010-09-30 18:24:17 +0200 (Do, 30. Sep 2010) $ ($Revision: 616 $)

IMPORT Heap[data, <] ONLY heap
       Tree[data] ONLY tree
       Seq[data] ONLY seq
       Seq[seq[data]] ONLY seq
       String ONLY string

Parameter

SORT data
FUN < : data ** data -> bool

Converting into Textual Representation

Heaps are represented as follows:

empty Heaps
are translated to "H[/\]"
leaves
are translated to "H[/data\]"
other heaps
are represented as "H[/data,left child,right child\]"
FUN ` : (data -> denotation) -> heap -> denotation

FUN ` : (data -> string)     -> heap -> string

These functions produce a twodimensional output of the heap. This works only for fixed width fonts, of course. The output assumes arbitrarily long lines. The function aborts, if one representation has zero length.

FUN graphic : (data -> denotation) -> heap -> denotation
FUN graphic : (data -> string    ) -> heap -> string

Converting into a Sequence

There are three possibilities: you can get the datas either in inorder -- left/node/right, in preorder -- node/left/right, or in postorder -- left/right/node.

FUN asSeqIn  asSeqPre asSeqPost : heap -> seq[data]

asSeqBreadth gives you a sequence of sequence of datas. The ith element of the sequence contains all elements of level i from left to right.

FUN asSeqBreadth : heap -> seq[seq[data]]

Converting into a Tree

You can get the underlying tree structure or convert a tree to a heap

FUN asHeap: tree -> heap
FUN asTree: heap -> tree


next node: HeapFilter,
prev node: HeapCompare,
up to node: Subsystem Heaps