• Nie Znaleziono Wyników

pop_front – removig the first value from the queue or throwing an empty queue exception (with memory deallocation

N/A
N/A
Protected

Academic year: 2021

Share "pop_front – removig the first value from the queue or throwing an empty queue exception (with memory deallocation"

Copied!
1
0
0

Pełen tekst

(1)

1. Write a program which implements an unbounded double-ended queue container (using the double-linked list) as a template structure (aimed at storing values of any type), and a set of methods operating on this structure:

• the default constructor,

• the destructor (with memory deallocation),

• the copy-constructor (with memory allocation),

• the assignment operator= (with memory dellocation and allocation),

• the comparison operator==,

• push_front – adding a value to the queue as the first (with memory allocation),

• pop_front – removig the first value from the queue or throwing an empty queue exception (with memory deallocation),

• push_back – adding a value to the queue as the last (with memory allocation),

• pop_back – removig the last value from the queue or throwing an empty queue exception (with memory deallocation),

• front – returning the first value or throwing an empty queue exception,

• back – returning the last value or throwing an empty queue exception,

• empty – informing whether the queue is empty,

• size – returning the number of items in the queue,

• clear – removing all the items from the queue (with memory deallocation).

The program should use all these methods to make the operations as follows:

1) create a queue of integers containing the numbers given by the user (placing them at the beginning or at the end of the queue, according to the user's decision),

2) print the first and the last number,

3) remove the first or the last value from the queue, 4) print the first and the last number,

5) print the number of values in the queue if it is nonempty, or an appropriate message otherwise,

6) clear the queue.

Compare your implementation of the container with the built-in containers delivered in

<deque> and <list> libraries.

2. Implement an unbounded queue (using non-sequential memory storage – the linked list) as a template structure (aimed at storing values of any type), and a set of methods operating on this structure mentioned in the task of lab 6. Compare your implementation with the built-in structure delivered in <queue> library.

3. Implement a structure of a process with an identifier (PID), a name, an execution message, the default constructor and proper setters and gettters for the attributes. Write a program which implements a queue of processes with attributes given by the user. Allow the user to:

- add a new process to the queue (at the end by default),

- execute the first process from the queue (printing its execution message and removing it from the queue),

- move the lastly added process to the beginning of the queue, - check the current number of processes in the queue,

- clear the queue.

Use the double-ended queue structure implemented in task 1.

Cytaty

Powiązane dokumenty

Define the Matrix structure implementing a square matrix (2-dimensional array) of real numbers with the following public methods:. • the constructor with two parameters – the number

Write a program which implements a bounded stack (a Last-In-First-Out structure using sequential memory storage), aimed at storing real numbers, and a set of methods operating on

Write a program which implements an unbounded queue (a First-In-First-Out structure using sequential memory storage), aimed at storing real numbers, and a set of methods operating

Write a program which implements an unbounded vector container (using sequential memory storage) as a template structure (aimed at storing values of any type), and

In this section, we prove that the work in the n-th system at time nt associated with customers in this system having lead times smaller than or equal to F n (nt) becomes

moniKa gaWlaK | doktor nauk humanistycznych, literaturoznawczy- ni, słowenistka, adiunkt w zakładzie Teorii literatury i Translacji w instytucie Filologii Słowiańskiej

The work presents the example of nondeterministic model of the operating system and optimizing the size of the queue in such a system. The work also presents a method of determining

• for trucks of low reliability the function E u (k) runs slowly towards the asymptote; the required number of repair stands for the shop is smaller than the total number of