31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6.6 Bounded Queues ( b queue )<br />

1. Definition<br />

An instance Q of the parameterized data type b queue is a queue (see section 6.4) of<br />

bounded size.<br />

#include < <strong>LEDA</strong>/core/b queue.h ><br />

2. Creation<br />

b queue Q(int n);<br />

creates an instance Q of type b queue that can hold up to n<br />

elements. Q is initialized with the empty queue.<br />

3. Operations<br />

const E& Q.top( ) returns the front element of Q.<br />

Precondition: Q is not empty.<br />

const E& Q.pop( ) deletes and returns the front element of Q.<br />

Precondition: Q is not empty.<br />

void Q.del top( ) deletes the front element of Q.<br />

Precondition: Q is not empty.<br />

void Q.append(const E& x) appends x to the rear end of Q.<br />

Precondition: Q.size()< n.<br />

void Q.clear( ) makes Q the empty queue.<br />

int Q.size( ) returns the size of Q.<br />

bool Q.empty( ) returns true if Q is empty, false otherwise.<br />

4. Implementation<br />

Bounded queues are implemented by circular arrays. All operations take time O(1). <strong>The</strong><br />

space requirement is O(n).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!