6import java.util.Scanner;
13 class MyRedBlackTree
extends RedBlackTree<String,String> {
17 @Override
protected void onInsert(Node node) {
19 halt(
"insert '"+node.getKey()+
"' before rebalancing");
23 @Override
protected void onRestructuring() {
24 halt(
"- after restructuring");
25 super.onRestructuring();
27 @Override
protected void onRecoloring() {
28 halt(
"- after one recoloring step");
29 super.onRestructuring();
33 protected MyRedBlackTree
tree_ =
null;
35 ((String)
null,
"aud.example.RedBlackTreeExample");
39 super(
"aud.example.RedBlackTreeExample");
40 tree_=
new MyRedBlackTree(
this);
51 public static void main(String[] args) {
54 "usage: java aud.example.RedBlackTreeExample [pause]\n"+
55 " Reads and insert words from standard input.\n"+
57 "\tpause [milliseconds] set pause between animation steps\n"+
58 "\t A value of 0 requires to explicitly push the 'continue'\n"+
59 "\t button. The default value is 0 (or the value of then\n"+
60 "\t environment variable 'AUD_TIMEOUT')!\n";
67 }
catch (NumberFormatException e) {
68 System.err.println(HELP);
73 app.
halt(
"EMPTY TREE");
75 Scanner s=
new Scanner(System.in);
76 s.useDelimiter(
"\\s+");
80 if (key.compareTo(
"quit")==0)
84 app.
halt(
"inserted '"+key+
"' and rebalanced");
example: insert entries and maintain balance
static void main(String[] args)
start interactive example
RedBlackTreeExample()
create application instance
Simple viewer for Graphvizable.
void display(String code)
display dot code
Example for a simple decorator.
Simple framework for single stepping code.
void setTimeout(int timeout)
Set global timeout.
void halt(String text, int timeout)
display text and wait for user or timeout
utilities (not related to AuD lecture)
AuD lecture: Data structures, algorithms, examples.