AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
AbstractStack.java
Go to the documentation of this file.
1
package
aud.adt;
2
3
import
java.util.NoSuchElementException;
4
8
public
abstract
class
AbstractStack
<T> {
9
11
protected
AbstractStack
() {}
12
14
public
abstract
boolean
is_empty
();
15
21
public
abstract
T
top
();
22
28
public
abstract
T
pop
();
29
33
public
abstract
void
push
(T x);
34
39
@Override
40
public
String
toString
() {
41
if
(!
is_empty
()) {
42
T x=
pop
();
43
String bottom=
toString
();
44
push
(x);
45
return
(bottom+(bottom.length()>1 ?
"|"
:
""
))+x;
46
}
47
else
48
return
"|"
;
49
}
50
}
aud.adt.AbstractStack
Interface for an ADT stack.
Definition:
AbstractStack.java:8
aud.adt.AbstractStack.AbstractStack
AbstractStack()
create empty stack
Definition:
AbstractStack.java:11
aud.adt.AbstractStack.top
abstract T top()
Get stack top.
aud.adt.AbstractStack.is_empty
abstract boolean is_empty()
Is stack empty?
aud.adt.AbstractStack.push
abstract void push(T x)
Push x onto stack.
aud.adt.AbstractStack.pop
abstract T pop()
Pop element from stack.
aud.adt.AbstractStack.toString
String toString()
Get string representation "|a|b|c".
Definition:
AbstractStack.java:40
adt
AbstractStack.java
Generated on Tue Apr 15 2025 13:46:54 for AuD by
1.9.5