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

example: insert entries More...

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

Classes

class  MyTree
 

Public Member Functions

 BTreeExample (int m)
 create application instance More...
 
MyTree 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

MyTree 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

See also
aud.BTree

Definition at line 12 of file BTreeExample.java.

Constructor & Destructor Documentation

◆ BTreeExample()

create application instance

Definition at line 30 of file BTreeExample.java.

30 {
31 super("aud.example.BTreeExample");
32 tree_=new MyTree(m,this);
33 }

References aud.example.BTreeExample.tree_.

Member Function Documentation

◆ getTree()

MyTree aud.example.BTreeExample.getTree ( )

Definition at line 35 of file BTreeExample.java.

35{ return tree_; }

References aud.example.BTreeExample.tree_.

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

+ Here is the caller graph for this function:

◆ main()

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

start interactive example

Reimplemented from aud.util.SingleStepper.

Definition at line 43 of file BTreeExample.java.

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

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

+ Here is the call graph for this function:

◆ onHalt()

void aud.example.BTreeExample.onHalt ( )
protected

Reimplemented from aud.util.SingleStepper.

Definition at line 37 of file BTreeExample.java.

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

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

+ Here is the call graph for this function:

Member Data Documentation

◆ tree_

MyTree aud.example.BTreeExample.tree_ = null
protected

◆ viewer_

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

Definition at line 26 of file BTreeExample.java.

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


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