3
3
/** @generate-class-entries */
4
4
5
5
/**
6
- * A double-ended queue represented internally as a circular buffer.
6
+ * A double-ended queue (Typically abbreviated as Deque, pronounced "deck", like "cheque")
7
+ * represented internally as a circular buffer.
8
+ *
7
9
* This has much lower memory usage than SplDoublyLinkedList or its subclasses (SplStack, SplStack),
8
10
* and operations are significantly faster than SplDoublyLinkedList.
9
11
*
12
+ * See https://en.wikipedia.org/wiki/Double-ended_queue
13
+ *
10
14
* This supports amortized constant time pushing and popping onto the front or back of the array.
11
15
*
12
16
* Naming is based on https://www.php.net/spldoublylinkedlist
@@ -44,9 +48,15 @@ public static function __set_state(array $array): Deque {}
44
48
public function push (mixed $ value ): void {}
45
49
/** Prepends a value to the start of the Deque. */
46
50
public function unshift (mixed $ value ): void {}
47
- /** Pops a value from the end of the Deque. */
51
+ /**
52
+ * Pops a value from the end of the Deque.
53
+ * @throws UnderflowException if the Deque is empty
54
+ */
48
55
public function pop (): mixed {}
49
- /** Shifts a value from the front of the Deque. */
56
+ /**
57
+ * Shifts a value from the front of the Deque.
58
+ * @throws UnderflowException if the Deque is empty
59
+ */
50
60
public function shift (): mixed {}
51
61
52
62
/** Peeks at the value at the start of the Deque, throws if empty */
@@ -57,13 +67,35 @@ public function top(): mixed {}
57
67
/** Returns a list of the elements from front to back. */
58
68
public function toArray (): array {}
59
69
/* Get and set are strictly typed, unlike offsetGet/offsetSet. */
70
+ /**
71
+ * Returns the value at offset $offset (relative to the start of the Deque)
72
+ * @throws OutOfBoundsException if the value of (int)$offset is not within the bounds of this vector
73
+ */
60
74
public function get (int $ offset ): mixed {}
75
+ /**
76
+ * Sets the value at offset $offset (relative to the start of the Deque) to $value
77
+ * @throws OutOfBoundsException if the value of (int)$offset is not within the bounds of this vector
78
+ */
61
79
public function set (int $ offset , mixed $ value ): void {}
62
80
// Must be mixed for compatibility with ArrayAccess
81
+ /**
82
+ * Returns the value at offset (int)$offset (relative to the start of the Deque)
83
+ * @throws OutOfBoundsException if the value of (int)$offset is not within the bounds of this vector
84
+ */
63
85
public function offsetGet (mixed $ offset ): mixed {}
86
+ /**
87
+ * Returns true if `0 <= (int)$offset && (int)$offset < $this->count().
88
+ */
64
89
public function offsetExists (mixed $ offset ): bool {}
90
+ /**
91
+ * Sets the value at offset $offset (relative to the start of the Deque) to $value
92
+ * @throws OutOfBoundsException if the value of (int)$offset is not within the bounds of this vector
93
+ */
65
94
public function offsetSet (mixed $ offset , mixed $ value ): void {}
66
95
/** Throws unconditionally */
96
+ /**
97
+ * @throws RuntimeException unconditionally because unset and null are different things, unlike SplFixedArray
98
+ */
67
99
public function offsetUnset (mixed $ offset ): void {}
68
100
69
101
/** This is JSON serialized as a JSON array with elements from front to back */
0 commit comments