AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
aud.QueueDL< T > Class Template Reference

Impementation of AbstractQueue based on doubly linked list DList. More...

+ Inheritance diagram for aud.QueueDL< T >:
+ Collaboration diagram for aud.QueueDL< T >:

Public Member Functions

 QueueDL ()
 
boolean is_empty ()
 Is queue empty? More...
 
T front ()
 Get front element of queue. More...
 
T dequeue ()
 Remove front element from queue. More...
 
void enqueue (T x)
 Enqueue element at end of queue. More...
 
String toString ()
 
abstract boolean is_empty ()
 Is queue empty? More...
 
abstract T front ()
 Get front element of queue. More...
 
abstract T dequeue ()
 Remove front element from queue. More...
 
abstract void enqueue (T x)
 Enqueue element at end of queue. More...
 
String toString ()
 

Additional Inherited Members

- Protected Member Functions inherited from aud.adt.AbstractQueue< T >
 AbstractQueue ()
 create empty queue More...
 

Detailed Description

Impementation of AbstractQueue based on doubly linked list DList.

Definition at line 11 of file QueueDL.java.

Constructor & Destructor Documentation

◆ QueueDL()

aud.QueueDL< T >.QueueDL ( )

Definition at line 15 of file QueueDL.java.

15{ data_=new DList<T>(); }

Member Function Documentation

◆ dequeue()

T aud.QueueDL< T >.dequeue ( )

Remove front element from queue.

Requires !is_empty().

Exceptions
NoSuchElementException
Returns
removed element

Reimplemented from aud.adt.AbstractQueue< T >.

Definition at line 30 of file QueueDL.java.

30 {
31 if (data_.empty())
32 throw new NoSuchElementException();
33 T obj=data_.front();
34 data_.pop_front();
35 return obj;
36 }

Referenced by aud.test.QueueTest.testInvalid_dequeueDL().

+ Here is the caller graph for this function:

◆ enqueue()

void aud.QueueDL< T >.enqueue ( T  x)

Enqueue element at end of queue.

Parameters
xnew element

Reimplemented from aud.adt.AbstractQueue< T >.

Definition at line 38 of file QueueDL.java.

38 {
39 data_.push_back(x);
40 }

◆ front()

T aud.QueueDL< T >.front ( )

Get front element of queue.

Requires !is_empty().

Exceptions
NoSuchElementException
Returns
front element

Reimplemented from aud.adt.AbstractQueue< T >.

Definition at line 22 of file QueueDL.java.

22 {
23 if (data_.empty())
24 throw new NoSuchElementException();
25 return data_.front();
26 }

Referenced by aud.test.QueueTest.testInvalid_frontDL().

+ Here is the caller graph for this function:

◆ is_empty()

boolean aud.QueueDL< T >.is_empty ( )

Is queue empty?

Reimplemented from aud.adt.AbstractQueue< T >.

Definition at line 19 of file QueueDL.java.

19 {
20 return data_.empty();
21 }

Referenced by aud.QueueDL< T >.toString().

+ Here is the caller graph for this function:

◆ toString()

String aud.QueueDL< T >.toString ( )

Reimplemented from aud.adt.AbstractQueue< T >.

Definition at line 43 of file QueueDL.java.

43 {
44 if (is_empty())
45 return "<";
46
47 String s="";
48 DList<T>.ForwardIterator i=data_.iterator();
49 while (i.hasNext()) {
50 s+=i.next().toString()+"<";
51 }
52 return s;
53 }
boolean is_empty()
Is queue empty?
Definition: QueueDL.java:19

References aud.QueueDL< T >.is_empty().

+ Here is the call graph for this function:

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