AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
aud.example.AVLTreeExample Class Reference

example: insert entries and maintain balance More...

+ Inheritance diagram for aud.example.AVLTreeExample:
+ Collaboration diagram for aud.example.AVLTreeExample:

Classes

class  MyAVLTree
 

Public Member Functions

 AVLTreeExample ()
 create application instance More...
 
MyAVLTree getTree ()
 
- Public Member Functions inherited from aud.util.SingleStepper
 SingleStepper (JFrame parent)
 create new instance More...
 
 SingleStepper (String caption)
 create new instance More...
 
JFrame parent ()
 get parent widget More...
 
void halt (String text, int timeout)
 display text and wait for user or timeout
More...
 
void setTimeout (int timeout)
 Set global timeout. More...
 
SingleStepper whereAmI ()
 print location of calling code More...
 
SingleStepper showSource ()
 jmp to caller's location in editor (emacs only) More...
 
void halt (String text)
 display text and wait for user (or global timeout) More...
 
void halt ()
 wait for user More...
 

Static Public Member Functions

static void main (String[] args)
 start interactive example More...
 
static void main (String[] args)
 

Protected Member Functions

void onHalt ()
 
- Protected Member Functions inherited from aud.util.SingleStepper
JComponent createComponents ()
 
void onNext ()
 call on button pressed More...
 
void println (String text)
 print to both, text area and stdout More...
 
void onHalt ()
 

Protected Attributes

MyAVLTree tree_ = null
 
DotViewer viewer_
 
- Protected Attributes inherited from aud.util.SingleStepper
JFrame frame
 
JTextArea history
 
JButton next
 
Object monitor = new Object()
 
int timeout = 0
 

Detailed Description

example: insert entries and maintain balance

See also
AVLTree

Definition at line 11 of file AVLTreeExample.java.

Constructor & Destructor Documentation

◆ AVLTreeExample()

create application instance

Definition at line 29 of file AVLTreeExample.java.

29 {
30 super("aud.example.AVLTreeExample");
31 tree_=new MyAVLTree(this);
32 }

References aud.example.AVLTreeExample.tree_.

Referenced by aud.example.AVLTreeExample.main().

+ Here is the caller graph for this function:

Member Function Documentation

◆ getTree()

MyAVLTree aud.example.AVLTreeExample.getTree ( )

Definition at line 34 of file AVLTreeExample.java.

34{ return tree_; }

References aud.example.AVLTreeExample.tree_.

Referenced by aud.example.AVLTreeExample.main().

+ Here is the caller graph for this function:

◆ main()

static void aud.example.AVLTreeExample.main ( String[]  args)
static

start interactive example

Reimplemented from aud.util.SingleStepper.

Definition at line 42 of file AVLTreeExample.java.

42 {
43
44 final String HELP=
45 "usage: java aud.example.AVLTreeExample [pause]\n"+
46 " Reads and insert words from standard input.\n"+
47 " 'quit' quits.\n"+
48 "\tpause [milliseconds] set pause between animation steps\n"+
49 "\t A value of 0 requires to explicitly push the 'continue'\n"+
50 "\t button. The default value is 0 (or the value of then\n"+
51 "\t environment variable 'AUD_TIMEOUT')!\n";
52
54
55 if (args.length>0) {
56 try {
57 app.setTimeout(Integer.parseInt(args[0]));
58 } catch (NumberFormatException e) {
59 System.err.println(HELP);
60 System.exit(-1);
61 }
62 }
63
64 app.halt("EMPTY TREE");
65
66 Scanner s=new Scanner(System.in);
67 s.useDelimiter("\\s+");
68
69 while (s.hasNext()) {
70 String key=s.next();
71 if (key.compareTo("quit")==0)
72 break;
73 else {
74 app.getTree().insert(key,null);
75 app.halt("inserted '"+key+"' and rebalanced");
76 }
77 }
78 app.halt("QUIT");
79 System.exit(0);
80 }
AVLTreeExample()
create application instance

References aud.example.AVLTreeExample.AVLTreeExample(), aud.example.AVLTreeExample.getTree(), aud.util.SingleStepper.halt(), and aud.util.SingleStepper.setTimeout().

+ Here is the call graph for this function:

◆ onHalt()

void aud.example.AVLTreeExample.onHalt ( )
protected

Reimplemented from aud.util.SingleStepper.

Definition at line 36 of file AVLTreeExample.java.

36 {
37 if (tree_!=null)
39 }
void display(String code)
display dot code
Definition: DotViewer.java:108

References aud.util.DotViewer.display(), aud.example.AVLTreeExample.tree_, and aud.example.AVLTreeExample.viewer_.

+ Here is the call graph for this function:

Member Data Documentation

◆ tree_

MyAVLTree aud.example.AVLTreeExample.tree_ = null
protected

◆ viewer_

DotViewer aud.example.AVLTreeExample.viewer_
protected
Initial value:
= DotViewer.displayWindow
((String) null,"aud.example.AVLTreeExample")

Definition at line 25 of file AVLTreeExample.java.

Referenced by aud.example.AVLTreeExample.onHalt().


The documentation for this class was generated from the following file: