-
Notifications
You must be signed in to change notification settings - Fork 0
/
PriorityNode.php
58 lines (53 loc) · 1.14 KB
/
PriorityNode.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
58
<?php
namespace Altair\Structure;
use Altair\Structure\Contracts\PriorityNodeInterface;
use OutOfBoundsException;
/**
* PriorityNode
*
* A node which represents a value, priority and a stamp on a PriorityQueue
*/
class PriorityNode implements PriorityNodeInterface
{
/**
* @var mixed
*/
public $value;
/**
* @var int
*/
public $priority;
/**
* @var int
*/
public $stamp;
/**
* PriorityNode constructor.
*
* @param mixed $value
* @param int $priority
* @param int $stamp
*/
public function __construct($value, int $priority, int $stamp)
{
$this->value = $value;
$this->priority = $priority;
$this->stamp = $stamp;
}
/**
* This allows unset($pair->key) to not completely remove the property,
* but be set to null instead.
*
* @param mixed $name
*
* @return mixed|null
*/
public function __get($name)
{
if ($name === 'value' || $name === 'priority' || $name === 'stamp') {
$this->$name = null;
return;
}
throw new OutOfBoundsException();
}
}