19 lines
1.2 KiB
Markdown
19 lines
1.2 KiB
Markdown
As you noticed, we can use our basic data-structures, to form more complex ones, which fit more specific needs.
|
|
This time we will take a look at the queue. This data-structures allows you to perform operations on your data
|
|
with the **FIFO**(**F**irst **i**n **F**irst **o**ut) principle. This is critical, if you want to
|
|
process the oldest data first, just like in a queue in the real world.
|
|
|
|
The queue data-structure is normally based on a linked list, such that it is also dynamically growing in size.
|
|
But this does not have to be true, but usually, if you are using libraries, it is.
|
|
|
|
For the queue we want to perform three basic operations.
|
|
-first we want to put something at the end of the queue. We call that ``enqueue``.
|
|
-second we want to take something of the beginning of the queue. We call that ``dequeue``.
|
|
-third we want just look at the end of the queue without taking it of. We call that ``peak``.
|
|
|
|
There are also other kinds of queues, which will not necessarily operate like a FIFO-queue.
|
|
For example the priority-queue, which will sort the member with the highest priority
|
|
to the beginning of the queue and uses a heap as it's underlying structure.
|
|
|
|
Your task is to implement the queue on the basis of a singly linked list.
|