![]() |
AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
|
A stack that outputs messages on push
and pop
.
More...
Public Member Functions | |
VerboseStack () | |
T | pop () throws NoSuchElementException |
Pop element from stack. More... | |
void | push (T x) |
Push x onto stack. More... | |
String | toString () |
Get string representation "|a|b|c" . More... | |
![]() | |
Stack () | |
boolean | is_empty () |
Is stack empty? More... | |
T | top () throws NoSuchElementException |
Get stack top. More... | |
T | pop () throws NoSuchElementException |
Pop element from stack. More... | |
void | push (T x) |
Push x onto stack. More... | |
abstract boolean | is_empty () |
Is stack empty? More... | |
abstract T | top () |
Get stack top. More... | |
abstract T | pop () |
Pop element from stack. More... | |
abstract void | push (T x) |
Push x onto stack. More... | |
String | toString () |
Get string representation "|a|b|c" . More... | |
Additional Inherited Members | |
![]() | |
AbstractStack () | |
create empty stack More... | |
A stack that outputs messages on push
and pop
.
On push
(pop
) print the pushed (popped) entry to System.err
. The printed message is indented by the height of the stack.
You can replace Stack
in any class by VerboseStack
to trace modifications of the stack. This is useful, e.g., for comparing iterative and recursive implementations of algorithms.
Definition at line 15 of file VerboseStack.java.
aud.example.VerboseStack< T >.VerboseStack | ( | ) |
Definition at line 19 of file VerboseStack.java.
T aud.example.VerboseStack< T >.pop | ( | ) | throws NoSuchElementException |
Pop element from stack.
Requires !is_empty()
.
NoSuchElementException |
Reimplemented from aud.Stack< T >.
Definition at line 21 of file VerboseStack.java.
Referenced by aud.example.IterativePreorderTraversal.iterative_traversal().
void aud.example.VerboseStack< T >.push | ( | T | x | ) |
Push x onto stack.
x | new element |
Reimplemented from aud.Stack< T >.
Definition at line 28 of file VerboseStack.java.
Referenced by aud.example.IterativePreorderTraversal.iterative_traversal().
String aud.example.VerboseStack< T >.toString | ( | ) |
Get string representation "|a|b|c"
.
(Here, "c"
is stack top. "|"
denotes empty stack.)
Reimplemented from aud.adt.AbstractStack< T >.
Definition at line 41 of file VerboseStack.java.
References aud.Stack< T >.is_empty(), and aud.example.VerboseStack< T >.toString().
Referenced by aud.example.VerboseStack< T >.toString().