AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
aud.adt.AbstractStack< T > Class Template Referenceabstract

Interface for an ADT stack. More...

+ Inheritance diagram for aud.adt.AbstractStack< T >:

Public Member Functions

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...
 

Protected Member Functions

 AbstractStack ()
 create empty stack More...
 

Detailed Description

Interface for an ADT stack.

Definition at line 8 of file AbstractStack.java.

Constructor & Destructor Documentation

◆ AbstractStack()

create empty stack

Definition at line 11 of file AbstractStack.java.

11{}

Member Function Documentation

◆ is_empty()

abstract boolean aud.adt.AbstractStack< T >.is_empty ( )
abstract

Is stack empty?

Reimplemented in aud.Stack< T >.

Referenced by aud.adt.AbstractStack< T >.toString().

+ Here is the caller graph for this function:

◆ pop()

abstract T aud.adt.AbstractStack< T >.pop ( )
abstract

Pop element from stack.

Requires !is_empty().

Exceptions
NoSuchElementException
Returns
removed element

Reimplemented in aud.example.VerboseStack< T >, and aud.Stack< T >.

Referenced by aud.adt.AbstractStack< T >.toString().

+ Here is the caller graph for this function:

◆ push()

abstract void aud.adt.AbstractStack< T >.push ( x)
abstract

Push x onto stack.

Parameters
xnew element

Reimplemented in aud.example.VerboseStack< T >, and aud.Stack< T >.

Referenced by aud.adt.AbstractStack< T >.toString().

+ Here is the caller graph for this function:

◆ top()

abstract T aud.adt.AbstractStack< T >.top ( )
abstract

Get stack top.

Requires !is_empty().

Exceptions
NoSuchElementException
Returns
top

Reimplemented in aud.Stack< T >.

◆ toString()

String aud.adt.AbstractStack< T >.toString ( )

Get string representation "|a|b|c".

(Here, "c" is stack top. "|" denotes empty stack.)

Reimplemented in aud.example.VerboseStack< T >.

Definition at line 40 of file AbstractStack.java.

40 {
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 }
abstract boolean is_empty()
Is stack empty?
abstract void push(T x)
Push x onto stack.
abstract T pop()
Pop element from stack.
String toString()
Get string representation "|a|b|c".

References aud.adt.AbstractStack< T >.is_empty(), aud.adt.AbstractStack< T >.pop(), aud.adt.AbstractStack< T >.push(), and aud.adt.AbstractStack< T >.toString().

Referenced by aud.adt.AbstractStack< T >.toString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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