-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
QueueInterface.php
57 lines (49 loc) 路 1.17 KB
/
QueueInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
namespace Psl\DataStructure;
use Countable;
use Psl\Default\DefaultInterface;
/**
* An interface representing a queue data structure ( FIFO ).
*
* @template T
*
* @see https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)
*/
interface QueueInterface extends Countable, DefaultInterface
{
/**
* Adds a node to the queue.
*
* @param T $node
*/
public function enqueue(mixed $node): void;
/**
* Retrieves, but does not remove, the node at the head of this queue,
* or returns null if this queue is empty.
*
* @return null|T
*/
public function peek(): mixed;
/**
* Retrieves and removes the node at the head of this queue,
* or returns null if this queue is empty.
*
* @return null|T
*/
public function pull(): mixed;
/**
* Retrieves and removes the node at the head of this queue.
*
* @throws Exception\UnderflowException If the queue is empty.
*
* @return T
*/
public function dequeue(): mixed;
/**
* Count the nodes in the queue.
*
* @return int<0, max>
*/
public function count(): int;
}