diff --git a/reference/ds/book.xml b/reference/ds/book.xml
index 4a6d5f5db18e..5ca35a9aa7f4 100644
--- a/reference/ds/book.xml
+++ b/reference/ds/book.xml
@@ -9,30 +9,20 @@
&reftitle.intro;
- Efficient data structures for PHP 7, provided as an alternative to the &array;.
-
-
- See this blog post
- for benchmarks, discussion and frequently asked questions.
+ Efficient data structures for PHP, provided as an alternative to the &array;.
&reference.ds.setup;
&reference.ds.examples;
- &reference.ds.ds.collection;
- &reference.ds.ds.hashable;
-
- &reference.ds.ds.sequence;
- &reference.ds.ds.vector;
- &reference.ds.ds.deque;
+ &reference.ds.ds.key;
+ &reference.ds.ds.seq;
&reference.ds.ds.map;
&reference.ds.ds.pair;
&reference.ds.ds.set;
- &reference.ds.ds.stack;
- &reference.ds.ds.queue;
- &reference.ds.ds.priorityqueue;
+ &reference.ds.ds.heap;
diff --git a/reference/ds/ds.collection.xml b/reference/ds/ds.collection.xml
deleted file mode 100644
index 9a852ae8f16e..000000000000
--- a/reference/ds/ds.collection.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
-
-
-
- The Collection interface
- Ds\Collection
-
-
-
-
-
- &reftitle.intro;
-
- Collection is the base interface which covers functionality
- common to all the data structures in this library. It guarantees that all structures
- are traversable, countable, and can be converted to json using json_encode.
-
-
-
-
-
- &reftitle.interfacesynopsis;
-
-
-
- Ds\Collection
-
-
- extends
- Countable
-
-
- IteratorAggregate
-
-
- JsonSerializable
-
-
- &Methods;
-
-
- &InheritedMethods;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- &reftitle.changelog;
-
-
-
-
- &Version;
- &Description;
-
-
-
-
- PECL ds 1.4.0
-
- Collection implements
- IteratorAggregate now instead of just Traversable. (This change came to the polyfill in 1.4.1.)
-
-
-
-
-
-
-
-
-
- &reference.ds.ds.entities.collection;
-
-
-
-
diff --git a/reference/ds/ds.hashable.xml b/reference/ds/ds.hashable.xml
deleted file mode 100644
index b6f61ec2b1c5..000000000000
--- a/reference/ds/ds.hashable.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
-
- The Hashable interface
- Ds\Hashable
-
-
-
-
-
- &reftitle.intro;
-
- Hashable is an interface which allows objects to be used as keys.
- It’s an alternative to spl_object_hash,
- which determines an object’s hash based on its handle:
- this means that two objects that are considered equal by an implicit
- definition would not treated as equal because they are not the same instance.
-
-
- hash is used to return a scalar value to be used as
- the object's hash value, which determines where it goes in the hash table.
- While this value does not have to be unique, objects which are equal must
- have the same hash value.
-
-
- equals is used to determine if two objects are equal.
- It's guaranteed that the comparing object will be an instance of the same class
- as the subject.
-
-
-
-
-
-
- &reftitle.interfacesynopsis;
-
-
-
- Ds\Hashable
-
- &Methods;
-
-
-
-
-
-
-
-
- &reference.ds.ds.entities.hashable;
-
-
-
-
diff --git a/reference/ds/ds.heap.xml b/reference/ds/ds.heap.xml
new file mode 100644
index 000000000000..58626f0a2716
--- /dev/null
+++ b/reference/ds/ds.heap.xml
@@ -0,0 +1,165 @@
+
+
+
+
+
+ The Heap class
+ Ds\Heap
+
+
+
+
+
+ &reftitle.intro;
+
+ A Heap is a tree-based data structure in which the value at the top of the
+ heap is determined by a configurable comparator. By default, when no comparator
+ is provided, the heap behaves as a max-heap using standard comparison.
+
+
+ Replaces Ds\PriorityQueue from v1, providing more
+ flexibility through an optional callable comparator that can be passed to
+ the constructor.
+
+
+
+ Iterating over a Heap is destructive, equivalent to successive pop
+ operations until the heap is empty. The iterator operates on an internal
+ copy, so the original heap is not modified by foreach.
+
+
+
+
+
+
+
+
+
+
+
+ &reftitle.classsynopsis;
+
+
+
+ Ds\Heap
+
+
+
+
+ Ds\Heap
+
+
+
+ Countable
+
+
+ IteratorAggregate
+
+
+ JsonSerializable
+
+
+
+ &Constants;
+
+ const
+ int
+ Ds\Heap::MIN_CAPACITY
+ 8
+
+
+ &Methods;
+
+
+
+
+
+
+
+
+
+ &reftitle.constants;
+
+
+
+ Ds\Heap::MIN_CAPACITY
+
+
+
+
+
+
+
+
+
+
+
+
+ &reference.ds.ds.entities.heap;
+
+
+
+
diff --git a/reference/ds/ds.key.xml b/reference/ds/ds.key.xml
new file mode 100644
index 000000000000..fb613f1495e3
--- /dev/null
+++ b/reference/ds/ds.key.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
+ The Key interface
+ Ds\Key
+
+
+
+
+
+ &reftitle.intro;
+
+ Key is an interface that allows objects to be used as keys in a
+ Ds\Map or values in a Ds\Set.
+ It replaces Ds\Hashable from v1.
+
+
+ hash is used to return a scalar value to be used as
+ the object's hash value, which determines where it goes in the hash table.
+ While this value does not have to be unique, objects which are equal must
+ have the same hash value.
+
+
+ equals is used to determine if two objects are equal.
+ The argument may be any type.
+
+
+
+
+
+
+ &reftitle.interfacesynopsis;
+
+
+
+ Ds\Key
+
+ &Methods;
+
+
+
+
+
+
+
+
+ &reference.ds.ds.entities.key;
+
+
+
+
diff --git a/reference/ds/ds.map.xml b/reference/ds/ds.map.xml
index 0079ed800748..769232554a3a 100644
--- a/reference/ds/ds.map.xml
+++ b/reference/ds/ds.map.xml
@@ -57,7 +57,13 @@
- Ds\Collection
+ Countable
+
+
+ IteratorAggregate
+
+
+ JsonSerializableArrayAccess
@@ -107,6 +113,15 @@
+
+ PECL ds 2.0.0
+
+ No longer implements Ds\Collection.
+ Ds\Map::values returns Ds\Seq.
+ Ds\Map::pairs returns Ds\Seq.
+ Ds\Map::keys returns Ds\Set.
+
+ PECL ds 1.3.0
diff --git a/reference/ds/ds.pair.xml b/reference/ds/ds.pair.xml
index acff6538e0d1..ba6dee5b20b5 100644
--- a/reference/ds/ds.pair.xml
+++ b/reference/ds/ds.pair.xml
@@ -12,7 +12,8 @@
&reftitle.intro;
- A pair is used by Ds\Map to pair keys with values.
+ A pair is a readonly key-value pair used by Ds\Map.
+ Properties key and value are public and readonly.
@@ -27,6 +28,7 @@
+ readonlyDs\Pair
diff --git a/reference/ds/ds.priorityqueue.xml b/reference/ds/ds.priorityqueue.xml
deleted file mode 100644
index d47d53343790..000000000000
--- a/reference/ds/ds.priorityqueue.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
-
-
- The PriorityQueue class
- Ds\PriorityQueue
-
-
-
-
-
- &reftitle.intro;
-
- A PriorityQueue is very similar to a Queue. Values are pushed into the queue
- with an assigned priority, and the value with the highest priority will
- always be at the front of the queue.
-
-
- Implemented using a max heap.
-
-
-
- "First in, first out" ordering is preserved for values with the same priority.
-
-
-
-
- Iterating over a PriorityQueue is destructive, equivalent to successive pop operations until the queue is empty.
-
-
-
-
-
-
- &reftitle.classsynopsis;
-
-
-
- Ds\PriorityQueue
-
-
-
-
- Ds\PriorityQueue
-
-
-
- Ds\Collection
-
-
-
- &Constants;
-
- const
- int
- Ds\PriorityQueue::MIN_CAPACITY
- 8
-
-
- &Methods;
-
-
-
-
-
-
-
-
- &reftitle.constants;
-
-
-
- Ds\PriorityQueue::MIN_CAPACITY
-
-
-
-
-
-
-
-
-
-
-
-
- &reference.ds.ds.entities.priorityqueue;
-
-
-
-
diff --git a/reference/ds/ds.queue.xml b/reference/ds/ds.queue.xml
deleted file mode 100644
index 73d3b2f7a517..000000000000
--- a/reference/ds/ds.queue.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
- The Queue class
- Ds\Queue
-
-
-
-
-
- &reftitle.intro;
-
- A Queue is a “first in, first out” or “FIFO” collection that only allows
- access to the value at the front of the queue and iterates in that order,
- destructively.
-
-
-
-
-
- &reftitle.classsynopsis;
-
-
-
- Ds\Queue
-
-
-
-
- Ds\Queue
-
-
-
- Ds\Collection
-
-
- ArrayAccess
-
-
-
- &Constants;
-
- const
- int
- Ds\Queue::MIN_CAPACITY
- 8
-
-
- &Methods;
-
-
-
-
-
-
-
-
- &reftitle.constants;
-
-
-
- Ds\Queue::MIN_CAPACITY
-
-
-
-
-
-
-
-
-
-
- &reftitle.changelog;
-
-
-
-
-
- &Version;
- &Description;
-
-
-
-
- PECL ds 1.3.0
-
- The class now implements ArrayAccess.
-
-
-
-
-
-
-
-
-
-
- &reference.ds.ds.entities.queue;
-
-
-
-
diff --git a/reference/ds/ds.deque.xml b/reference/ds/ds.seq.xml
similarity index 60%
rename from reference/ds/ds.deque.xml
rename to reference/ds/ds.seq.xml
index 1eeb48359431..09f87d6ae958 100644
--- a/reference/ds/ds.deque.xml
+++ b/reference/ds/ds.seq.xml
@@ -1,27 +1,25 @@
-
+
- The Deque class
- Ds\Deque
+ The Seq class
+ Ds\Seq
-
-
+
+
&reftitle.intro;
- A Deque (pronounced “deck”) is a sequence of values
- in a contiguous buffer that grows and shrinks automatically.
- The name is a common abbreviation of “double-ended queue” and is used
- internally by Ds\Queue.
+ A Seq is an ordered sequence of values in a contiguous buffer that grows
+ and shrinks automatically. It replaces both Ds\Vector
+ and Ds\Deque from v1.
Two pointers are used to keep track of a head and a tail. The pointers can
- “wrap around” the end of the buffer, which avoids the need to move other
- values around to make room. This makes shift and unshift very fast —
- something a Ds\Vector can’t compete with.
+ "wrap around" the end of the buffer, which avoids the need to move other
+ values around to make room. This makes shift and unshift very fast.
Accessing a value by index requires a translation between the index and its
@@ -30,7 +28,7 @@
-
+Strengths
@@ -45,11 +43,14 @@
shift, and
unshift are all O(1).
+
+ copy is O(1) due to copy-on-write.
+
-
+Weaknesses
@@ -62,21 +63,27 @@
-
+
&reftitle.classsynopsis;
- Ds\Deque
+ Ds\Seq
- Ds\Deque
+ Ds\Seq
- Ds\Sequence
+ Countable
+
+
+ IteratorAggregate
+
+
+ JsonSerializableArrayAccess
@@ -87,26 +94,25 @@
constint
- Ds\Deque::MIN_CAPACITY
+ Ds\Seq::MIN_CAPACITY8&Methods;
-
-
-
+
+
-
-
+
+
&reftitle.constants;
-
- Ds\Deque::MIN_CAPACITY
+
+ Ds\Seq::MIN_CAPACITY
@@ -116,33 +122,9 @@
-
- &reftitle.changelog;
-
-
-
-
-
- &Version;
- &Description;
-
-
-
-
- PECL ds 1.3.0
-
- The class now implements ArrayAccess.
-
-
-
-
-
-
-
-
- &reference.ds.ds.entities.deque;
+ &reference.ds.ds.entities.seq;
diff --git a/reference/ds/ds.sequence.xml b/reference/ds/ds.sequence.xml
deleted file mode 100644
index 20305d074609..000000000000
--- a/reference/ds/ds.sequence.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-
-
-
-
-
- The Sequence interface
- Ds\Sequence
-
-
-
-
-
- &reftitle.intro;
-
- A Sequence describes the behaviour of values arranged in a single, linear dimension.
- Some languages refer to this as a "List". It’s similar to an array that uses
- incremental integer keys, with the exception of a few characteristics:
-
- Values will always be indexed as [0, 1, 2, …, size - 1].
- Only allowed to access values by index in the range [0, size - 1].
-
-
-
- Use cases:
-
- Wherever you would use an array as a list (not concerned with keys).
- A more efficient alternative to
- SplDoublyLinkedList and
- SplFixedArray.
-
-
-
-
-
-
-
- &reftitle.interfacesynopsis;
-
-
-
- Ds\Sequence
-
-
- extends
- Ds\Collection
-
-
- ArrayAccess
-
-
- &Methods;
-
-
- &InheritedMethods;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- &reftitle.changelog;
-
-
-
-
-
- &Version;
- &Description;
-
-
-
-
- PECL ds 1.3.0
-
- The interface now extends ArrayAccess.
-
-
-
-
-
-
-
-
-
-
- &reference.ds.ds.entities.sequence;
-
-
-
-
diff --git a/reference/ds/ds.set.xml b/reference/ds/ds.set.xml
index 70ccf2d01f85..3e586d31a8e1 100644
--- a/reference/ds/ds.set.xml
+++ b/reference/ds/ds.set.xml
@@ -70,7 +70,13 @@
- Ds\Collection
+ Countable
+
+
+ IteratorAggregate
+
+
+ JsonSerializableArrayAccess
@@ -120,6 +126,12 @@
+
+ PECL ds 2.0.0
+
+ No longer implements Ds\Collection.
+
+ PECL ds 1.3.0
diff --git a/reference/ds/ds.stack.xml b/reference/ds/ds.stack.xml
deleted file mode 100644
index 0aa2c478066e..000000000000
--- a/reference/ds/ds.stack.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-
-
-
-
-
- The Stack class
- Ds\Stack
-
-
-
-
-
- &reftitle.intro;
-
- A Stack is a “last in, first out” or “LIFO” collection that only allows
- access to the value at the top of the structure and iterates in that order,
- destructively.
-
-
- Uses a Ds\Vector internally.
-
-
-
-
-
- &reftitle.classsynopsis;
-
-
-
- Ds\Stack
-
-
-
-
- Ds\Stack
-
-
-
- Ds\Collection
-
-
- ArrayAccess
-
-
-
-
- &Methods;
-
-
-
-
-
-
-
- &reftitle.changelog;
-
-
-
-
-
- &Version;
- &Description;
-
-
-
-
- PECL ds 1.3.0
-
- The class now implements ArrayAccess.
-
-
-
-
-
-
-
-
-
-
- &reference.ds.ds.entities.stack;
-
-
-
-
diff --git a/reference/ds/ds.vector.xml b/reference/ds/ds.vector.xml
deleted file mode 100644
index efd2b0c2b037..000000000000
--- a/reference/ds/ds.vector.xml
+++ /dev/null
@@ -1,162 +0,0 @@
-
-
-
-
-
- The Vector class
- Ds\Vector
-
-
-
-
-
- &reftitle.intro;
-
- A Vector is a sequence of values in a contiguous buffer that grows and
- shrinks automatically. It’s the most efficient sequential structure because
- a value’s index is a direct mapping to its index in the buffer, and the
- growth factor isn't bound to a specific multiple or exponent.
-
-
-
-
-
-
- Strengths
-
-
- Supports array syntax (square brackets).
- Uses less overall memory than an &array; for the same number of values.
- Automatically frees allocated memory when its size drops low enough.
- Capacity does not have to be a power of 2.
-
- get,
- set,
- push,
- pop are all O(1).
-
-
-
-
-
-
- Weaknesses
-
-
-
- shift,
- unshift,
- insert and
- remove are all O(n).
-
-
-
-
-
-
- &reftitle.classsynopsis;
-
-
-
-
- Ds\Vector
-
-
-
-
-
- Ds\Vector
- Ds\Sequence
- ArrayAccess
-
-
-
- &Constants;
-
- const
- int
- Ds\Vector::MIN_CAPACITY
- 8
-
-
- &Methods;
-
-
-
-
-
-
-
-
-
-
- &reftitle.constants;
-
-
-
- Ds\Vector::MIN_CAPACITY
-
-
-
-
-
-
-
-
-
-
- &reftitle.changelog;
-
-
-
-
-
- &Version;
- &Description;
-
-
-
-
- PECL ds 1.3.0
-
- The class now implements ArrayAccess.
-
-
-
- PECL ds 1.2.0
-
- Ds\Vector::MIN_CAPACITY changed from 10 to 8.
-
-
-
-
-
-
-
-
-
-
- &reference.ds.ds.entities.vector;
-
-
-
-
diff --git a/reference/ds/ds/collection/copy.xml b/reference/ds/ds/collection/copy.xml
deleted file mode 100644
index ea4af34fb08d..000000000000
--- a/reference/ds/ds/collection/copy.xml
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
- Ds\Collection::copy
- Returns a shallow copy of the collection
-
-
-
- &reftitle.description;
-
- publicDs\CollectionDs\Collection::copy
-
-
-
- Returns a shallow copy of the collection.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- Returns a shallow copy of the collection.
-
-
-
-
- &reftitle.examples;
-
- Ds\Collection::copy example
-
-copy();
-
-$b->push(4);
-
-print_r($a);
-print_r($b);
-?>
-]]>
-
- &example.outputs.similar;
-
- 1
- [1] => 2
- [2] => 3
-)
-Ds\Vector Object
-(
- [0] => 1
- [1] => 2
- [2] => 3
- [3] => 4
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/collection/isempty.xml b/reference/ds/ds/collection/isempty.xml
deleted file mode 100644
index 418d0e292afd..000000000000
--- a/reference/ds/ds/collection/isempty.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
- Ds\Collection::isEmpty
- Returns whether the collection is empty
-
-
-
- &reftitle.description;
-
- publicboolDs\Collection::isEmpty
-
-
-
- Returns whether the collection is empty.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- Returns &true; if the collection is empty, &false; otherwise.
-
-
-
-
- &reftitle.examples;
-
- Ds\Collection::isEmpty example
-
-isEmpty());
-var_dump($b->isEmpty());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/collection/toarray.xml b/reference/ds/ds/collection/toarray.xml
deleted file mode 100644
index 44b782af7bc3..000000000000
--- a/reference/ds/ds/collection/toarray.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
- Ds\Collection::toArray
-
- Converts the collection to an &array;
-
-
-
-
- &reftitle.description;
-
- publicarrayDs\Collection::toArray
-
-
-
- Converts the collection to an &array;.
-
-
-
- Casting to an &array; is not supported yet.
-
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- An &array; containing all the values in the same order as the collection.
-
-
-
-
- &reftitle.examples;
-
- Ds\Collection::toArray example
-
-toArray());
-?>
-]]>
-
- &example.outputs.similar;
-
-
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
-}
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/deque/clear.xml b/reference/ds/ds/deque/clear.xml
deleted file mode 100644
index 742018dbc911..000000000000
--- a/reference/ds/ds/deque/clear.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
-
- Ds\Deque::clear
- Removes all values from the deque
-
-
-
- &reftitle.description;
-
- publicvoidDs\Deque::clear
-
-
-
- Removes all values from the deque.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Deque::clear example
-
-clear();
-print_r($deque);
-?>
-]]>
-
- &example.outputs.similar;
-
- 1
- [1] => 2
- [2] => 3
-)
-Ds\Deque Object
-(
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/deque/copy.xml b/reference/ds/ds/deque/copy.xml
deleted file mode 100644
index 49cfb60adba7..000000000000
--- a/reference/ds/ds/deque/copy.xml
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
- Ds\Deque::copy
- Returns a shallow copy of the deque
-
-
-
- &reftitle.description;
-
- publicDs\DequeDs\Deque::copy
-
-
-
- Returns a shallow copy of the deque.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- A shallow copy of the deque.
-
-
-
-
- &reftitle.examples;
-
- Ds\Deque::copy example
-
-copy();
-
-$b->push(4);
-
-print_r($a);
-print_r($b);
-?>
-]]>
-
- &example.outputs.similar;
-
- 1
- [1] => 2
- [2] => 3
-)
-Ds\Deque Object
-(
- [0] => 1
- [1] => 2
- [2] => 3
- [3] => 4
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/deque/count.xml b/reference/ds/ds/deque/count.xml
deleted file mode 100644
index a374bdfc4a00..000000000000
--- a/reference/ds/ds/deque/count.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
- Ds\Deque::count
- Returns the number of values in the collection
-
-
-
- &reftitle.description;
-
- See Countable::count
-
-
-
-
-
-
diff --git a/reference/ds/ds/deque/find.xml b/reference/ds/ds/deque/find.xml
deleted file mode 100644
index dfab9c66c009..000000000000
--- a/reference/ds/ds/deque/find.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
-
-
-
- Ds\Deque::find
-
- Attempts to find a value's index
-
-
-
-
- &reftitle.description;
-
- publicmixedDs\Deque::find
- mixedvalue
-
-
- Returns the index of the value, or &false; if not found.
-
-
-
-
-
- &reftitle.parameters;
-
-
- value
-
-
- The value to find.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- The index of the value, or &false; if not found.
-
-
-
- Values will be compared by value and by type.
-
-
-
-
-
- &reftitle.examples;
-
- Ds\Deque::find example
-
-find("a")); // 0
-var_dump($deque->find("b")); // false
-var_dump($deque->find("1")); // false
-var_dump($deque->find(1)); // 1
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/deque/toarray.xml b/reference/ds/ds/deque/toarray.xml
deleted file mode 100644
index 6fba07034307..000000000000
--- a/reference/ds/ds/deque/toarray.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
- Ds\Deque::toArray
-
- Converts the deque to an &array;
-
-
-
-
- &reftitle.description;
-
- publicarrayDs\Deque::toArray
-
-
-
- Converts the deque to an &array;.
-
-
-
- Casting to an &array; is not supported yet.
-
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- An &array; containing all the values in the same order as the deque.
-
-
-
-
- &reftitle.examples;
-
- Ds\Deque::toArray example
-
-toArray());
-?>
-]]>
-
- &example.outputs.similar;
-
-
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
-}
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/deque/unshift.xml b/reference/ds/ds/deque/unshift.xml
deleted file mode 100644
index 7618263ce2d2..000000000000
--- a/reference/ds/ds/deque/unshift.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
- Ds\Deque::unshift
- Adds values to the front of the deque
-
-
-
- &reftitle.description;
-
- publicvoidDs\Deque::unshift
- mixedvalues
-
-
- Adds values to the front of the deque, moving all the current
- values forward to make room for the new values.
-
-
-
-
-
- &reftitle.parameters;
-
-
- values
-
-
- The values to add to the front of the deque.
-
-
- Multiple values will be added in the same order that they are
- passed.
-
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Deque::unshift example
-
-unshift("a");
-$deque->unshift("b", "c");
-
-print_r($deque);
-?>
-]]>
-
- &example.outputs.similar;
-
- b
- [1] => c
- [2] => a
- [3] => 1
- [4] => 2
- [5] => 3
-)
-]]>
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/heap/__serialize.xml b/reference/ds/ds/heap/__serialize.xml
new file mode 100644
index 000000000000..267a854c5760
--- /dev/null
+++ b/reference/ds/ds/heap/__serialize.xml
@@ -0,0 +1,41 @@
+
+
+
+ Ds\Heap::__serialize
+ Returns the serialized representation of the heap
+
+
+
+ &reftitle.description;
+
+ See Serializable::serialize
+
+
+
+ You should never need to call this directly.
+
+
+
+
+
+
+
diff --git a/reference/ds/ds/heap/__unserialize.xml b/reference/ds/ds/heap/__unserialize.xml
new file mode 100644
index 000000000000..cff43358c72f
--- /dev/null
+++ b/reference/ds/ds/heap/__unserialize.xml
@@ -0,0 +1,41 @@
+
+
+
+ Ds\Heap::__unserialize
+ Restores the heap from its serialized form
+
+
+
+ &reftitle.description;
+
+ See Serializable::serialize
+
+
+
+ You should never need to call this directly.
+
+
+
+
+
+
+
diff --git a/reference/ds/ds/sequence/allocate.xml b/reference/ds/ds/heap/allocate.xml
similarity index 60%
rename from reference/ds/ds/sequence/allocate.xml
rename to reference/ds/ds/heap/allocate.xml
index c231d7d831ac..c759b92ec0dc 100644
--- a/reference/ds/ds/sequence/allocate.xml
+++ b/reference/ds/ds/heap/allocate.xml
@@ -1,21 +1,21 @@
-
+
- Ds\Sequence::allocate
+ Ds\Heap::allocateAllocates enough memory for a required capacity
&reftitle.description;
- abstractpublicvoidDs\Sequence::allocate
+ publicvoidDs\Heap::allocateintcapacity
- Ensures that enough memory is allocated for a required capacity.
- This removes the need to reallocate the internal as values are added.
+ Ensures that enough memory is allocated for a required capacity.
+ This removes the need to reallocate the internal as values are added.
@@ -26,14 +26,19 @@
capacity
- The number of values for which capacity should be allocated.
+ The number of values for which capacity should be allocated.
-
- Capacity will stay the same if this value is less than or equal to the
- current capacity.
-
-
+
+ Capacity will stay the same if this value is less than or equal to the
+ current capacity.
+
+
+
+
+ Capacity will always be rounded up to the nearest power of 2.
+
+
@@ -42,36 +47,36 @@
&reftitle.returnvalues;
- &return.void;
+ &return.void;
+
&reftitle.examples;
- Ds\Sequence::allocate example
+ Ds\Heap::allocate example
capacity());
+$heap = new \Ds\Heap();
+var_dump($heap->capacity());
-$vector->allocate(100);
-var_dump($sequence->capacity());
+$heap->allocate(100);
+var_dump($heap->capacity());
?>
]]>
&example.outputs.similar;
-
-
+
- Ds\PriorityQueue::capacity
+ Ds\Heap::capacityReturns the current capacity
&reftitle.description;
- publicintDs\PriorityQueue::capacity
+ publicintDs\Heap::capacity
- Returns the current capacity.
+ Returns the current capacity.
@@ -26,19 +26,19 @@
&reftitle.returnvalues;
- The current capacity.
+ The current capacity.
&reftitle.examples;
- Ds\PriorityQueue::capacity example
+ Ds\Heap::capacity example
capacity());
+$heap = new \Ds\Heap();
+var_dump($heap->capacity());
?>
]]>
diff --git a/reference/ds/ds/pair/clear.xml b/reference/ds/ds/heap/clear.xml
similarity index 73%
rename from reference/ds/ds/pair/clear.xml
rename to reference/ds/ds/heap/clear.xml
index 044d540e3b81..d0458cdfa1f1 100644
--- a/reference/ds/ds/pair/clear.xml
+++ b/reference/ds/ds/heap/clear.xml
@@ -1,20 +1,20 @@
-
+
- Ds\Pair::clear
+ Ds\Heap::clearRemoves all values
&reftitle.description;
- publicvoidDs\Pair::clear
+ publicvoidDs\Heap::clear
- Removes all values from the pair.
+ Removes all values from the heap.
@@ -33,28 +33,25 @@
&reftitle.examples;
- Ds\Pair::clear example
+ Ds\Heap::clear example
clear();
-print_r($pair);
+$heap->push(5);
+$heap->push(1);
+$heap->push(3);
+
+$heap->clear();
+print_r($heap);
?>
]]>
&example.outputs.similar;
1
- [1] => 2
- [2] => 3
-)
-Ds\Pair Object
+Ds\Heap Object
(
)
]]>
diff --git a/reference/ds/ds/heap/construct.xml b/reference/ds/ds/heap/construct.xml
new file mode 100644
index 000000000000..f1d27ed86dfc
--- /dev/null
+++ b/reference/ds/ds/heap/construct.xml
@@ -0,0 +1,139 @@
+
+
+
+
+
+ Ds\Heap::__construct
+ Creates a new instance
+
+
+
+ &reftitle.description;
+
+ publicDs\Heap::__construct
+ callablenullcomparator&null;
+
+
+ Creates a new instance using an optional comparator function.
+
+
+ When no comparator is provided (or &null;), the heap behaves as a max-heap
+ using standard comparison: the largest value will be at the top. A custom
+ comparator can be used to change the ordering, for example to create a
+ min-heap.
+
+
+ The comparator should return a positive integer, 0, or a negative integer
+ when the first argument is considered to be respectively greater than, equal
+ to, or less than the second.
+
+
+
+ Returning non-integer values from the comparator, such as &float;,
+ will result in an internal cast to &integer; of the return value.
+ So values such as 0.99 and 0.1 will
+ both be cast to an integer value of 0, which will
+ compare such values as equal.
+
+
+
+
+
+ &reftitle.parameters;
+
+
+ comparator
+
+
+ An optional comparison function to customize the heap ordering.
+ The function should accept two arguments and return an integer less than,
+ equal to, or greater than zero.
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+ Ds\Heap::__construct default max-heap example
+
+push(5);
+$heap->push(1);
+$heap->push(3);
+
+print_r($heap->toArray());
+?>
+]]>
+
+ &example.outputs.similar;
+
+ 5
+ [1] => 3
+ [2] => 1
+)
+]]>
+
+
+
+ Ds\Heap::__construct min-heap example using a comparator
+
+ $a;
+});
+
+$heap->push(5);
+$heap->push(1);
+$heap->push(3);
+
+print_r($heap->toArray());
+?>
+]]>
+
+ &example.outputs.similar;
+
+ 1
+ [1] => 3
+ [2] => 5
+)
+]]>
+
+
+
+
+
+
+
+
diff --git a/reference/ds/ds/deque/first.xml b/reference/ds/ds/heap/copy.xml
similarity index 63%
rename from reference/ds/ds/deque/first.xml
rename to reference/ds/ds/heap/copy.xml
index f3837b3ccaba..be3cc9eef46d 100644
--- a/reference/ds/ds/deque/first.xml
+++ b/reference/ds/ds/heap/copy.xml
@@ -1,20 +1,23 @@
-
+
- Ds\Deque::first
- Returns the first value in the deque
+ Ds\Heap::copy
+ Returns a shallow copy of the heap
&reftitle.description;
- publicmixedDs\Deque::first
+ publicDs\HeapDs\Heap::copy
- Returns the first value in the deque.
+ Returns a shallow copy of the heap.
+
+
+ This is an O(1) operation using copy-on-write.
@@ -26,33 +29,36 @@
&reftitle.returnvalues;
- The first value in the deque.
-
-
-
-
- &reftitle.errors;
-
- UnderflowException if empty.
+ Returns a shallow copy of the heap.
&reftitle.examples;
- Ds\Deque::first example
+ Ds\Heap::copy example
first());
+$heap = new \Ds\Heap();
+
+$heap->push(5);
+$heap->push(1);
+$heap->push(3);
+
+print_r($heap->copy());
?>
]]>
&example.outputs.similar;
5
+ [1] => 3
+ [2] => 1
+)
]]>
diff --git a/reference/ds/ds/queue/count.xml b/reference/ds/ds/heap/count.xml
similarity index 75%
rename from reference/ds/ds/queue/count.xml
rename to reference/ds/ds/heap/count.xml
index 1ec916c88320..3030ee6bb311 100644
--- a/reference/ds/ds/queue/count.xml
+++ b/reference/ds/ds/heap/count.xml
@@ -1,10 +1,10 @@
-
+
- Ds\Queue::count
- Returns the number of values in the queue
+ Ds\Heap::count
+ Returns the number of values in the heap
@@ -15,7 +15,6 @@
-
-
-
+
- Ds\Collection::clear
- Removes all values
+ Ds\Heap::getIterator
+ Returns an iterator for the heap
&reftitle.description;
- publicvoidDs\Collection::clear
-
+ publicTraversableDs\Heap::getIterator
+
- Removes all values from the collection.
+ Returns an iterator for the heap.
+
+
+ The iterator operates on an internal copy; iterating is equivalent to
+ successive pop operations but does not modify the original heap.
+
+
@@ -26,43 +30,10 @@
&reftitle.returnvalues;
- &return.void;
+ An instance of an object implementing Traversable.
-
- &reftitle.examples;
-
- Ds\Collection::clear example
-
-clear();
-print_r($collection);
-?>
-]]>
-
- &example.outputs.similar;
-
- 1
- [1] => 2
- [2] => 3
-)
-Ds\Vector Object
-(
-)
-]]>
-
-
-
-
-
-
+
- Ds\Pair::isEmpty
- Returns whether the pair is empty
+ Ds\Heap::isEmpty
+ Returns whether the heap is empty
&reftitle.description;
- publicboolDs\Pair::isEmpty
+ publicboolDs\Heap::isEmpty
- Returns whether the pair is empty.
+ Returns whether the heap is empty.
@@ -26,19 +26,23 @@
&reftitle.returnvalues;
- Returns &true; if the pair is empty, &false; otherwise.
+ Returns &true; if the heap is empty, &false; otherwise.
&reftitle.examples;
- Ds\Pair::isEmpty example
+ Ds\Heap::isEmpty example
push(5);
+$a->push(1);
+$a->push(3);
var_dump($a->isEmpty());
var_dump($b->isEmpty());
diff --git a/reference/ds/ds/stack/jsonserialize.xml b/reference/ds/ds/heap/jsonserialize.xml
similarity index 83%
rename from reference/ds/ds/stack/jsonserialize.xml
rename to reference/ds/ds/heap/jsonserialize.xml
index 6c8d8a17f8b5..2b72d4cbcd1e 100644
--- a/reference/ds/ds/stack/jsonserialize.xml
+++ b/reference/ds/ds/heap/jsonserialize.xml
@@ -1,9 +1,9 @@
-
+
- Ds\Stack::jsonSerialize
+ Ds\Heap::jsonSerializeReturns a representation that can be converted to JSON
diff --git a/reference/ds/ds/vector/pop.xml b/reference/ds/ds/heap/peek.xml
similarity index 71%
rename from reference/ds/ds/vector/pop.xml
rename to reference/ds/ds/heap/peek.xml
index 545d16b0630d..21989ee8f309 100644
--- a/reference/ds/ds/vector/pop.xml
+++ b/reference/ds/ds/heap/peek.xml
@@ -1,22 +1,21 @@
-
+
- Ds\Vector::pop
- Removes and returns the last value
+ Ds\Heap::peek
+ Returns the value at the top of the heap
&reftitle.description;
- publicmixedDs\Vector::pop
+ publicmixedDs\Heap::peek
- Removes and returns the last value.
+ Returns the value at the top of the heap, but does not remove it.
-
@@ -27,7 +26,7 @@
&reftitle.returnvalues;
- The removed last value.
+ The value at the top of the heap.
@@ -41,24 +40,24 @@
&reftitle.examples;
- Ds\Vector::pop example
+ Ds\Heap::peek example
push(5);
+$heap->push(1);
+$heap->push(3);
-var_dump($vector->pop());
-var_dump($vector->pop());
-var_dump($vector->pop());
+var_dump($heap->peek());
?>
]]>
&example.outputs.similar;
diff --git a/reference/ds/ds/vector/first.xml b/reference/ds/ds/heap/pop.xml
similarity index 69%
rename from reference/ds/ds/vector/first.xml
rename to reference/ds/ds/heap/pop.xml
index 799f99847fd7..1c490a83c8e7 100644
--- a/reference/ds/ds/vector/first.xml
+++ b/reference/ds/ds/heap/pop.xml
@@ -1,20 +1,20 @@
-
+
- Ds\Vector::first
- Returns the first value in the vector
+ Ds\Heap::pop
+ Removes and returns the value at the top of the heap
&reftitle.description;
- publicmixedDs\Vector::first
+ publicmixedDs\Heap::pop
- Returns the first value in the vector.
+ Removes and returns the value at the top of the heap.
@@ -26,7 +26,7 @@
&reftitle.returnvalues;
- The first value in the vector.
+ The removed value which was at the top of the heap.
@@ -40,18 +40,27 @@
&reftitle.examples;
- Ds\Vector::first example
+ Ds\Heap::pop example
first());
+$heap = new \Ds\Heap();
+
+$heap->push(5);
+$heap->push(1);
+$heap->push(3);
+
+print_r($heap->pop());
+print_r($heap->pop());
+print_r($heap->pop());
?>
]]>
&example.outputs.similar;
diff --git a/reference/ds/ds/deque/push.xml b/reference/ds/ds/heap/push.xml
similarity index 66%
rename from reference/ds/ds/deque/push.xml
rename to reference/ds/ds/heap/push.xml
index f42c6bccb36b..1a727f31453c 100644
--- a/reference/ds/ds/deque/push.xml
+++ b/reference/ds/ds/heap/push.xml
@@ -1,22 +1,21 @@
-
+
- Ds\Deque::push
- Adds values to the end of the deque
+ Ds\Heap::push
+ Pushes values into the heap
&reftitle.description;
- publicvoidDs\Deque::push
+ publicvoidDs\Heap::pushmixedvalues
- Adds values to the end of the deque.
+ Pushes one or more values into the heap.
-
@@ -26,7 +25,7 @@
values
- The values to add.
+ The values to push into the heap.
@@ -36,39 +35,34 @@
&reftitle.returnvalues;
- &return.void;
+ &return.void;
&reftitle.examples;
- Ds\Deque::push example
+ Ds\Heap::push example
push("a");
-$deque->push("b");
-$deque->push("c", "d");
-$deque->push(...["e", "f"]);
+$heap->push(5);
+$heap->push(1, 3);
-print_r($deque);
+print_r($heap->toArray());
?>
]]>
&example.outputs.similar;
a
- [1] => b
- [2] => c
- [3] => d
- [4] => e
- [5] => f
+ [0] => 5
+ [1] => 3
+ [2] => 1
)
]]>
diff --git a/reference/ds/ds/queue/toarray.xml b/reference/ds/ds/heap/toarray.xml
similarity index 65%
rename from reference/ds/ds/queue/toarray.xml
rename to reference/ds/ds/heap/toarray.xml
index 2da9aa766bc9..935db9f2947c 100644
--- a/reference/ds/ds/queue/toarray.xml
+++ b/reference/ds/ds/heap/toarray.xml
@@ -1,32 +1,35 @@
-
+
- Ds\Queue::toArray
+ Ds\Heap::toArray
- Converts the queue to an &array;
+ Converts the heap to an &array;
&reftitle.description;
- publicarrayDs\Queue::toArray
+ publicarrayDs\Heap::toArray
- Converts the queue to an &array;.
+ Converts the heap to an &array;.
+
+
+ Returns the values in heap order (highest priority first).
-
- Casting to an &array; is not supported yet.
-
+
+ This method is not destructive.
+
-
- This method is not destructive.
-
+
+ Casting to an &array; is not supported yet.
+
@@ -39,20 +42,24 @@
&reftitle.returnvalues;
- An &array; containing all the values in the same order as the queue.
+ An &array; containing all the values in heap order.
&reftitle.examples;
- Ds\Queue::toArray example
+ Ds\Heap::toArray example
toArray());
+$heap->push(5);
+$heap->push(1);
+$heap->push(3);
+
+var_dump($heap->toArray());
?>
]]>
@@ -61,11 +68,11 @@ var_dump($queue->toArray());
- int(1)
+ int(5)
[1]=>
- int(2)
- [2]=>
int(3)
+ [2]=>
+ int(1)
}
]]>
diff --git a/reference/ds/ds/hashable/equals.xml b/reference/ds/ds/key/equals.xml
similarity index 50%
rename from reference/ds/ds/hashable/equals.xml
rename to reference/ds/ds/key/equals.xml
index e2c56f21724f..62dbb5f03db4 100644
--- a/reference/ds/ds/hashable/equals.xml
+++ b/reference/ds/ds/key/equals.xml
@@ -1,39 +1,39 @@
-
+
- Ds\Hashable::equals
+ Ds\Key::equalsDetermines whether an object is equal to the current instance
&reftitle.description;
- abstractpublicboolDs\Hashable::equals
- objectobj
+ publicboolDs\Key::equals
+ mixedother
- Determines whether another object is equal to the current instance.
+ Determines whether another object is equal to the current instance.
- This method allows objects to be used as keys in structures such as
- Ds\Map and Ds\Set, or any
- other lookup structure that honors this interface.
+ This method allows objects to be used as keys in structures such as
+ Ds\Map and Ds\Set, or any
+ other lookup structure that honors this interface.
-
- It's guaranteed that obj is an instance of the same class.
-
+
+ The argument may be any type, not necessarily an instance of the same class.
+
-
- It's important that objects which are equal also have the same hash value.
- See Ds\Hashable::hash.
-
+
+ It's important that objects which are equal also have the same hash value.
+ See Ds\Key::hash.
+
@@ -42,11 +42,10 @@
&reftitle.parameters;
- obj
+ other
- The object to compare the current instance to, which is always an instance of
- the same class.
+ The value to compare the current instance to.
@@ -56,7 +55,7 @@
&reftitle.returnvalues;
- &true; if equal, &false; otherwise.
+ &true; if equal, &false; otherwise.
diff --git a/reference/ds/ds/hashable/hash.xml b/reference/ds/ds/key/hash.xml
similarity index 51%
rename from reference/ds/ds/hashable/hash.xml
rename to reference/ds/ds/key/hash.xml
index 386c85e05816..bcfdcdaf06ae 100644
--- a/reference/ds/ds/hashable/hash.xml
+++ b/reference/ds/ds/key/hash.xml
@@ -1,47 +1,49 @@
-
+
- Ds\Hashable::hash
+ Ds\Key::hashReturns a scalar value to be used as a hash value
&reftitle.description;
- abstractpublicmixedDs\Hashable::hash
+ publicmixedDs\Key::hash
- Returns a scalar value to be used as the hash value of the objects.
+ Returns a scalar value to be used as the hash value of the object.
- While the hash value does not define equality, all objects that are equal according to Ds\Hashable::equals
- must have the same hash value. Hash values of equal objects don't have to be unique, for example
- you could just return &true; for all objects and nothing would break - the only
- implication would be that hash tables then turn into linked lists because all
- your objects will be hashed to the same bucket. It's therefore very important
- that you pick a good hash value, such as an ID or email address.
-
+ While the hash value does not define equality, all objects that are equal
+ according to Ds\Key::equals must have the same hash
+ value. Hash values of equal objects don't have to be unique, for example
+ you could just return &true; for all objects and nothing would break - the
+ only implication would be that hash tables then turn into linked lists
+ because all your objects will be hashed to the same bucket. It's therefore
+ very important that you pick a good hash value, such as an ID or email
+ address.
+
- This method allows objects to be used as keys in structures such as
- Ds\Map and Ds\Set, or any
- other lookup structure that honors this interface.
+ This method allows objects to be used as keys in structures such as
+ Ds\Map and Ds\Set, or any
+ other lookup structure that honors this interface.
-
- Do not pick a value that might change within the object, such as a public
- property. Hash table lookups would fail because the hash has changed.
-
+
+ Do not pick a value that might change within the object, such as a public
+ property. Hash table lookups would fail because the hash has changed.
+
-
- All objects that are equal must have the same hash value.
-
+
+ All objects that are equal must have the same hash value.
+
@@ -54,18 +56,18 @@
&reftitle.returnvalues;
- A scalar value to be used as this object's hash value.
+ A scalar value to be used as this object's hash value.
&reftitle.examples;
- Ds\Hashable::hash example
+ Ds\Key::hash example
email;
}
@@ -90,10 +92,10 @@ class HashableObject implements \Ds\Hashable
* if the bucket's key matches the lookup key. The hash has to be equal if
* the objects are equal, otherwise this determination wouldn't be reached.
*/
- public function equals($obj): bool
+ public function equals(mixed $other): bool
{
- return $this->name === $obj->name
- && $this->email === $obj->email;
+ return $this->name === $other->name
+ && $this->email === $other->email;
}
}
?>
diff --git a/reference/ds/ds/deque/jsonserialize.xml b/reference/ds/ds/map/__serialize.xml
similarity index 70%
rename from reference/ds/ds/deque/jsonserialize.xml
rename to reference/ds/ds/map/__serialize.xml
index d3be59b2044f..3631f6aa7566 100644
--- a/reference/ds/ds/deque/jsonserialize.xml
+++ b/reference/ds/ds/map/__serialize.xml
@@ -1,16 +1,16 @@
-
+
- Ds\Deque::jsonSerialize
- Returns a representation that can be converted to JSON
+ Ds\Map::__serialize
+ Returns the serialized representation of the map
&reftitle.description;
- See JsonSerializable::jsonSerialize
+ See Serializable::__serialize
diff --git a/reference/ds/ds/vector/jsonserialize.xml b/reference/ds/ds/map/__unserialize.xml
similarity index 70%
rename from reference/ds/ds/vector/jsonserialize.xml
rename to reference/ds/ds/map/__unserialize.xml
index f28047ed39be..6dbd1306156d 100644
--- a/reference/ds/ds/vector/jsonserialize.xml
+++ b/reference/ds/ds/map/__unserialize.xml
@@ -1,16 +1,16 @@
-
+
- Ds\Vector::jsonSerialize
- Returns a representation that can be converted to JSON
+ Ds\Map::__unserialize
+ Restores the map from its serialized form
&reftitle.description;
- See JsonSerializable::jsonSerialize
+ See Serializable::__unserialize
diff --git a/reference/ds/ds/map/get.xml b/reference/ds/ds/map/get.xml
index 835e43f8e34a..b277177a5b56 100644
--- a/reference/ds/ds/map/get.xml
+++ b/reference/ds/ds/map/get.xml
@@ -23,10 +23,10 @@
Keys of type object are supported.
- If an object implements Ds\Hashable,
+ If an object implements Ds\Key,
equality will be determined by the object's equals function.
- If an object does not implement Ds\Hashable,
+ If an object does not implement Ds\Key,
objects must be references to the same instance to be considered equal.
diff --git a/reference/ds/ds/vector/capacity.xml b/reference/ds/ds/map/getiterator.xml
similarity index 53%
rename from reference/ds/ds/vector/capacity.xml
rename to reference/ds/ds/map/getiterator.xml
index 4a43128dfe18..c2bb46a965f2 100644
--- a/reference/ds/ds/vector/capacity.xml
+++ b/reference/ds/ds/map/getiterator.xml
@@ -1,20 +1,20 @@
-
+
- Ds\Vector::capacity
- Returns the current capacity
+ Ds\Map::getIterator
+ Returns an iterator for the map
&reftitle.description;
- publicintDs\Vector::capacity
+ publicTraversableDs\Map::getIterator
- Returns the current capacity.
+ Returns an iterator for the map.
@@ -26,40 +26,10 @@
&reftitle.returnvalues;
- The current capacity.
+ An instance of an object implementing Traversable.
-
- &reftitle.examples;
-
- Ds\Vector::capacity example
-
-capacity());
-
-$vector->push(...range(1, 50));
-var_dump($vector->capacity());
-
-$vector[] = "a";
-var_dump($vector->capacity());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
+
- Ds\Sequence::reverse
-
- Reverses the sequence in-place
-
+ Ds\Map::offsetExists
+ Returns whether a key exists
&reftitle.description;
- abstractpublicvoidDs\Sequence::reverse
-
+ publicboolDs\Map::offsetExists
+ mixedoffset
- Reverses the sequence in-place.
+ Returns whether a key exists.
-
&reftitle.parameters;
- &no.function.parameters;
+
+
+ offset
+
+
+ The offset to check.
+
+
+
+
&reftitle.returnvalues;
- &return.void;
+ &true; if the offset is valid, &false; otherwise.
-
- &reftitle.examples;
-
- Ds\Sequence::reverse example
-
-reverse();
-
-print_r($sequence);
-?>
-]]>
-
- &example.outputs.similar;
-
- c
- [1] => b
- [2] => a
-)
-]]>
-
-
-
-
-
-
+
- Ds\Queue::isEmpty
- Returns whether the queue is empty
+ Ds\Map::offsetGet
+ Returns the value associated with a key
&reftitle.description;
- publicboolDs\Queue::isEmpty
-
+ publicmixedDs\Map::offsetGet
+ mixedoffset
- Returns whether the queue is empty.
+ Returns the value associated with a key.
&reftitle.parameters;
- &no.function.parameters;
+
+
+ offset
+
+
+ The offset to get.
+
+
+
+
&reftitle.returnvalues;
- Returns &true; if the queue is empty, &false; otherwise.
+ The value at the given offset.
-
- &reftitle.examples;
-
- Ds\Queue::isEmpty example
-
-isEmpty());
-var_dump($b->isEmpty());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
+
+
+
+ Ds\Map::offsetSet
+ Associates a key with a value
+
+
+
+ &reftitle.description;
+
+ publicvoidDs\Map::offsetSet
+ mixedoffset
+ mixedvalue
+
+
+ Associates a key with a value.
+
+
+
+
+ &reftitle.parameters;
+
+
+ offset
+
+
+ The offset to set.
+
+
+
+
+ value
+
+
+ The new value.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.void;
+
+
+
+
+
+
diff --git a/reference/ds/ds/map/offsetunset.xml b/reference/ds/ds/map/offsetunset.xml
new file mode 100644
index 000000000000..ecc4530fc370
--- /dev/null
+++ b/reference/ds/ds/map/offsetunset.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+ Ds\Map::offsetUnset
+ Removes a value by key
+
+
+
+ &reftitle.description;
+
+ publicvoidDs\Map::offsetUnset
+ mixedoffset
+
+
+ Removes a value by key.
+
+
+
+
+ &reftitle.parameters;
+
+
+ offset
+
+
+ The offset to unset.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.void;
+
+
+
+
+
+
diff --git a/reference/ds/ds/map/pairs.xml b/reference/ds/ds/map/pairs.xml
index 470b099105b0..6ad24cd483c3 100644
--- a/reference/ds/ds/map/pairs.xml
+++ b/reference/ds/ds/map/pairs.xml
@@ -4,17 +4,17 @@
Ds\Map::pairs
- Returns a sequence containing all the pairs of the map
+ Returns a Ds\Seq containing all the pairs of the map
&reftitle.description;
- publicDs\SequenceDs\Map::pairs
+ publicDs\SeqDs\Map::pairs
- Returns a Ds\Sequence containing all the pairs of the map.
+ Returns a Ds\Seq containing all the pairs of the map.
@@ -27,7 +27,7 @@
&reftitle.returnvalues;
- Ds\Sequence containing all the pairs of the map.
+ Ds\Seq containing all the pairs of the map.
@@ -47,7 +47,7 @@ var_dump($map->pairs());
&example.outputs.similar;
object(Ds\Pair)#5 (2) {
["key"]=>
@@ -70,7 +70,6 @@ object(Ds\Map)#8 (3) {
int(3)
}
}
-p
]]>
diff --git a/reference/ds/ds/map/put.xml b/reference/ds/ds/map/put.xml
index 78504d2711f9..25074cfd3608 100644
--- a/reference/ds/ds/map/put.xml
+++ b/reference/ds/ds/map/put.xml
@@ -23,10 +23,10 @@
Keys of type object are supported.
- If an object implements Ds\Hashable,
+ If an object implements Ds\Key,
equality will be determined by the object's equals function.
- If an object does not implement Ds\Hashable,
+ If an object does not implement Ds\Key,
objects must be references to the same instance to be considered equal.
@@ -129,7 +129,7 @@ Ds\Map Object
value = $value;
}
- public function hash()
+ public function hash(): mixed
{
return $this->value;
}
- public function equals($obj): bool
+ public function equals(mixed $other): bool
{
- return $this->value === $obj->value;
+ return $this->value === $other->value;
}
}
@@ -164,11 +164,11 @@ $map->put($obj, 2);
$map->put(new \stdClass(), 3);
$map->put(new \stdClass(), 4);
-// Using multiple instances of equal hashable objects will overwrite previous values.
-$map->put(new \HashableObject(1), 5);
-$map->put(new \HashableObject(1), 6);
-$map->put(new \HashableObject(2), 7);
-$map->put(new \HashableObject(2), 8);
+// Using multiple instances of equal Key objects will overwrite previous values.
+$map->put(new \KeyObject(1), 5);
+$map->put(new \KeyObject(1), 6);
+$map->put(new \KeyObject(2), 7);
+$map->put(new \KeyObject(2), 8);
var_dump($map);
?>
@@ -208,8 +208,8 @@ object(Ds\Map)#1 (5) {
[3]=>
object(Ds\Pair)#10 (2) {
["key"]=>
- object(HashableObject)#5 (1) {
- ["value":"HashableObject":private]=>
+ object(KeyObject)#5 (1) {
+ ["value":"KeyObject":private]=>
int(1)
}
["value"]=>
@@ -218,8 +218,8 @@ object(Ds\Map)#1 (5) {
[4]=>
object(Ds\Pair)#11 (2) {
["key"]=>
- object(HashableObject)#6 (1) {
- ["value":"HashableObject":private]=>
+ object(KeyObject)#6 (1) {
+ ["value":"KeyObject":private]=>
int(2)
}
["value"]=>
diff --git a/reference/ds/ds/map/putAll.xml b/reference/ds/ds/map/putAll.xml
index 1f4a613db37c..39913b8a49ce 100644
--- a/reference/ds/ds/map/putAll.xml
+++ b/reference/ds/ds/map/putAll.xml
@@ -21,10 +21,10 @@
Keys of type object are supported.
- If an object implements Ds\Hashable,
+ If an object implements Ds\Key,
equality will be determined by the object's equals function.
- If an object does not implement Ds\Hashable,
+ If an object does not implement Ds\Key,
objects must be references to the same instance to be considered equal.
diff --git a/reference/ds/ds/map/remove.xml b/reference/ds/ds/map/remove.xml
index 71d8cd3bc171..26b51b426662 100644
--- a/reference/ds/ds/map/remove.xml
+++ b/reference/ds/ds/map/remove.xml
@@ -23,10 +23,10 @@
Keys of type object are supported.
- If an object implements Ds\Hashable,
+ If an object implements Ds\Key,
equality will be determined by the object's equals function.
- If an object does not implement Ds\Hashable,
+ If an object does not implement Ds\Key,
objects must be references to the same instance to be considered equal.
diff --git a/reference/ds/ds/map/values.xml b/reference/ds/ds/map/values.xml
index bf14f0206a5f..8cf2c520e2f4 100644
--- a/reference/ds/ds/map/values.xml
+++ b/reference/ds/ds/map/values.xml
@@ -10,7 +10,7 @@
&reftitle.description;
- publicDs\SequenceDs\Map::values
+ publicDs\SeqDs\Map::values
@@ -27,7 +27,7 @@
&reftitle.returnvalues;
- A Ds\Sequence containing all the values of the map.
+ A Ds\Seq containing all the values of the map.
@@ -46,7 +46,7 @@ var_dump($map->values());
&example.outputs.similar;
int(1)
[1]=>
diff --git a/reference/ds/ds/pair/__serialize.xml b/reference/ds/ds/pair/__serialize.xml
new file mode 100644
index 000000000000..1a6f76c036eb
--- /dev/null
+++ b/reference/ds/ds/pair/__serialize.xml
@@ -0,0 +1,41 @@
+
+
+
+ Ds\Pair::__serialize
+ Returns the serialized representation of the pair
+
+
+
+ &reftitle.description;
+
+ See Serializable::serialize
+
+
+
+ You should never need to call this directly.
+
+
+
+
+
+
+
diff --git a/reference/ds/ds/pair/__unserialize.xml b/reference/ds/ds/pair/__unserialize.xml
new file mode 100644
index 000000000000..fb7190521114
--- /dev/null
+++ b/reference/ds/ds/pair/__unserialize.xml
@@ -0,0 +1,41 @@
+
+
+
+ Ds\Pair::__unserialize
+ Restores the pair from its serialized form
+
+
+
+ &reftitle.description;
+
+ See Serializable::serialize
+
+
+
+ You should never need to call this directly.
+
+
+
+
+
+
+
diff --git a/reference/ds/ds/pair/construct.xml b/reference/ds/ds/pair/construct.xml
index 723822a21484..2e7f6b33c8e7 100644
--- a/reference/ds/ds/pair/construct.xml
+++ b/reference/ds/ds/pair/construct.xml
@@ -11,8 +11,8 @@
&reftitle.description;
publicDs\Pair::__construct
- mixedkey
- mixedvalue
+ mixedkey
+ mixedvalue
Creates a new instance using a given key and value.
diff --git a/reference/ds/ds/priorityqueue/allocate.xml b/reference/ds/ds/priorityqueue/allocate.xml
deleted file mode 100644
index 5dfa5b7a0e84..000000000000
--- a/reference/ds/ds/priorityqueue/allocate.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-
-
-
-
-
- Ds\PriorityQueue::allocate
- Allocates enough memory for a required capacity
-
-
-
- &reftitle.description;
-
- publicvoidDs\PriorityQueue::allocate
- intcapacity
-
-
- Ensures that enough memory is allocated for a required capacity.
- This removes the need to reallocate the internal as values are added.
-
-
-
-
- &reftitle.parameters;
-
-
- capacity
-
-
- The number of values for which capacity should be allocated.
-
-
-
- Capacity will stay the same if this value is less than or equal to the
- current capacity.
-
-
-
-
- Capacity will always be rounded up to the nearest power of 2.
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
-
- &reftitle.examples;
-
- Ds\PriorityQueue::allocate example
-
-capacity());
-
-$queue->allocate(100);
-var_dump($queue->capacity());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/priorityqueue/clear.xml b/reference/ds/ds/priorityqueue/clear.xml
deleted file mode 100644
index 326a08f377aa..000000000000
--- a/reference/ds/ds/priorityqueue/clear.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-
-
-
-
-
- Ds\PriorityQueue::clear
- Removes all values
-
-
-
- &reftitle.description;
-
- publicvoidDs\PriorityQueue::clear
-
-
-
- Removes all values from the queue.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\PriorityQueue::clear example
-
-push("a", 5);
-$queue->push("b", 15);
-$queue->push("c", 10);
-
-$queue->clear();
-print_r($queue);
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/priorityqueue/construct.xml b/reference/ds/ds/priorityqueue/construct.xml
deleted file mode 100644
index bdd9a49b6a2d..000000000000
--- a/reference/ds/ds/priorityqueue/construct.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
- Ds\PriorityQueue::__construct
- Creates a new instance
-
-
-
- &reftitle.description;
-
- publicDs\PriorityQueue::__construct
-
-
-
- Creates a new instance.
-
-
-
-
-
-
-
- &reftitle.examples;
-
- Ds\PriorityQueue::__construct example
-
-
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/priorityqueue/copy.xml b/reference/ds/ds/priorityqueue/copy.xml
deleted file mode 100644
index 559bacdb299f..000000000000
--- a/reference/ds/ds/priorityqueue/copy.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-
-
-
- Ds\PriorityQueue::copy
- Returns a shallow copy of the queue
-
-
-
- &reftitle.description;
-
- publicDs\PriorityQueueDs\PriorityQueue::copy
-
-
-
- Returns a shallow copy of the queue.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- Returns a shallow copy of the queue.
-
-
-
-
- &reftitle.examples;
-
- Ds\PriorityQueue::copy example
-
-push("a", 5);
-$queue->push("b", 15);
-$queue->push("c", 10);
-
-print_r($queue->copy());
-?>
-]]>
-
- &example.outputs.similar;
-
- b
- [1] => c
- [2] => a
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/priorityqueue/count.xml b/reference/ds/ds/priorityqueue/count.xml
deleted file mode 100644
index 0899f775af23..000000000000
--- a/reference/ds/ds/priorityqueue/count.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
- Ds\PriorityQueue::count
- Returns the number of values in the queue
-
-
-
- &reftitle.description;
-
- See Countable::count
-
-
-
-
-
diff --git a/reference/ds/ds/priorityqueue/isempty.xml b/reference/ds/ds/priorityqueue/isempty.xml
deleted file mode 100644
index b8f39f9f8794..000000000000
--- a/reference/ds/ds/priorityqueue/isempty.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-
-
-
-
-
- Ds\PriorityQueue::isEmpty
- Returns whether the queue is empty
-
-
-
- &reftitle.description;
-
- publicboolDs\PriorityQueue::isEmpty
-
-
-
- Returns whether the queue is empty.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- Returns &true; if the queue is empty, &false; otherwise.
-
-
-
-
- &reftitle.examples;
-
- Ds\PriorityQueue::isEmpty example
-
-push("a", 5);
-$a->push("b", 15);
-$a->push("c", 10);
-
-var_dump($a->isEmpty());
-var_dump($b->isEmpty());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/priorityqueue/jsonserialize.xml b/reference/ds/ds/priorityqueue/jsonserialize.xml
deleted file mode 100644
index f2bbd4d2c58f..000000000000
--- a/reference/ds/ds/priorityqueue/jsonserialize.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
- Ds\PriorityQueue::jsonSerialize
- Returns a representation that can be converted to JSON
-
-
-
- &reftitle.description;
-
- See JsonSerializable::jsonSerialize
-
-
-
- You should never need to call this directly.
-
-
-
-
-
-
diff --git a/reference/ds/ds/priorityqueue/peek.xml b/reference/ds/ds/priorityqueue/peek.xml
deleted file mode 100644
index aaad62faf226..000000000000
--- a/reference/ds/ds/priorityqueue/peek.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-
-
- Ds\PriorityQueue::peek
- Returns the value at the front of the queue
-
-
-
- &reftitle.description;
-
- publicmixedDs\PriorityQueue::peek
-
-
-
- Returns the value at the front of the queue, but does not remove it.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The value at the front of the queue.
-
-
-
-
- &reftitle.errors;
-
- UnderflowException if empty.
-
-
-
-
- &reftitle.examples;
-
- Ds\PriorityQueue::peek example
-
-push("a", 5);
-$queue->push("b", 15);
-$queue->push("c", 10);
-
-var_dump($queue->peek());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/priorityqueue/pop.xml b/reference/ds/ds/priorityqueue/pop.xml
deleted file mode 100644
index b7050f106080..000000000000
--- a/reference/ds/ds/priorityqueue/pop.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-
-
-
-
-
- Ds\PriorityQueue::pop
- Removes and returns the value with the highest priority
-
-
-
- &reftitle.description;
-
- publicmixedDs\PriorityQueue::pop
-
-
-
- Removes and returns the value at the front of the queue, ie. the value
- with the highest priority.
-
-
-
- Values with equal priority fall back to FIFO (first in first out).
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The removed value which was at the front of the queue.
-
-
-
-
- &reftitle.errors;
-
- UnderflowException if empty.
-
-
-
-
- &reftitle.examples;
-
- Ds\PriorityQueue::pop example
-
-push("a", 5);
-$queue->push("b", 15);
-$queue->push("c", 10);
-
-print_r($queue->pop());
-print_r($queue->pop());
-print_r($queue->pop());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/priorityqueue/push.xml b/reference/ds/ds/priorityqueue/push.xml
deleted file mode 100644
index f16171d87c26..000000000000
--- a/reference/ds/ds/priorityqueue/push.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
- Ds\PriorityQueue::push
- Pushes values into the queue
-
-
-
- &reftitle.description;
-
- publicvoidDs\PriorityQueue::push
- mixedvalue
- intpriority
-
-
- Pushes a value with a given priority into the queue.
-
-
-
-
-
- &reftitle.parameters;
-
-
- value
-
-
- The value to push into the queue.
-
-
-
-
- priority
-
-
- The priority associated with the value.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\PriorityQueue::push example
-
-push("a", 5);
-$queue->push("b", 15);
-$queue->push("c", 10);
-
-print_r($queue->pop());
-print_r($queue->pop());
-print_r($queue->pop());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/priorityqueue/toarray.xml b/reference/ds/ds/priorityqueue/toarray.xml
deleted file mode 100644
index f38b60466c94..000000000000
--- a/reference/ds/ds/priorityqueue/toarray.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-
-
-
-
-
- Ds\PriorityQueue::toArray
-
- Converts the queue to an &array;
-
-
-
-
- &reftitle.description;
-
- publicarrayDs\PriorityQueue::toArray
-
-
-
- Converts the queue to an &array;.
-
-
-
- This method is not destructive.
-
-
-
-
- Casting to an &array; is not supported yet.
-
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- An &array; containing all the values in the same order as the queue.
-
-
-
-
- &reftitle.examples;
-
- Ds\PriorityQueue::toArray example
-
-push("a", 5);
-$queue->push("b", 15);
-$queue->push("c", 10);
-
-var_dump($queue->toArray());
-?>
-]]>
-
- &example.outputs.similar;
-
-
- string(1) "b"
- [1]=>
- string(1) "c"
- [2]=>
- string(1) "a"
-}
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/queue/allocate.xml b/reference/ds/ds/queue/allocate.xml
deleted file mode 100644
index 9a6d17831b81..000000000000
--- a/reference/ds/ds/queue/allocate.xml
+++ /dev/null
@@ -1,106 +0,0 @@
-
-
-
-
-
- Ds\Queue::allocate
- Allocates enough memory for a required capacity
-
-
-
- &reftitle.description;
-
- publicvoidDs\Queue::allocate
- intcapacity
-
-
- Ensures that enough memory is allocated for a required capacity.
- This removes the need to reallocate the internal as values are added.
-
-
-
- Capacity will always be rounded up to the nearest power of 2.
-
-
-
-
-
- &reftitle.parameters;
-
-
- capacity
-
-
- The number of values for which capacity should be allocated.
-
-
-
- Capacity will stay the same if this value is less than or equal to the
- current capacity.
-
-
-
-
- Capacity will always be rounded up to the nearest power of 2.
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Queue::allocate example
-
-capacity());
-
-$queue->allocate(100);
-var_dump($queue->capacity());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/queue/capacity.xml b/reference/ds/ds/queue/capacity.xml
deleted file mode 100644
index d1ab1de10fc4..000000000000
--- a/reference/ds/ds/queue/capacity.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
- Ds\Queue::capacity
- Returns the current capacity
-
-
-
- &reftitle.description;
-
- publicintDs\Queue::capacity
-
-
-
- Returns the current capacity.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The current capacity.
-
-
-
-
- &reftitle.examples;
-
- Ds\Queue::capacity example
-
-capacity());
-
-$queue->push(...range(1, 50));
-var_dump($queue->capacity());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/queue/clear.xml b/reference/ds/ds/queue/clear.xml
deleted file mode 100644
index 9dfcda362e6d..000000000000
--- a/reference/ds/ds/queue/clear.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
-
- Ds\Queue::clear
- Removes all values
-
-
-
- &reftitle.description;
-
- publicvoidDs\Queue::clear
-
-
-
- Removes all values from the queue.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Queue::clear example
-
-clear();
-print_r($queue);
-?>
-]]>
-
- &example.outputs.similar;
-
- 1
- [1] => 2
- [2] => 3
-)
-Ds\Queue Object
-(
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/queue/construct.xml b/reference/ds/ds/queue/construct.xml
deleted file mode 100644
index 51d59eef4a43..000000000000
--- a/reference/ds/ds/queue/construct.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
- Ds\Queue::__construct
- Creates a new instance
-
-
-
- &reftitle.description;
-
- publicDs\Queue::__construct
- mixedvalues
-
-
- Creates a new instance, using either a traversable
- object or an &array; for the initial values.
-
-
-
-
- &reftitle.parameters;
-
-
- values
-
-
- A traversable object or an &array; to use for the initial values.
-
-
-
-
-
-
-
-
-
-
- &reftitle.examples;
-
- Ds\Queue::__construct example
-
-
-]]>
-
- &example.outputs.similar;
-
-
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
-}
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/queue/copy.xml b/reference/ds/ds/queue/copy.xml
deleted file mode 100644
index 11489c17344d..000000000000
--- a/reference/ds/ds/queue/copy.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
-
-
- Ds\Queue::copy
- Returns a shallow copy of the queue
-
-
-
- &reftitle.description;
-
- publicDs\QueueDs\Queue::copy
-
-
-
- Returns a shallow copy of the queue.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- Returns a shallow copy of the queue.
-
-
-
-
- &reftitle.examples;
-
- Ds\Queue::copy example
-
-copy();
-
-// Updating the copy doesn't affect the original
-$b->push(4);
-
-print_r($a);
-print_r($b);
-?>
-]]>
-
- &example.outputs.similar;
-
- 1
- [1] => 2
- [2] => 3
-)
-Ds\Queue Object
-(
- [0] => 1
- [1] => 2
- [2] => 3
- [3] => 4
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/queue/peek.xml b/reference/ds/ds/queue/peek.xml
deleted file mode 100644
index 57371f8febce..000000000000
--- a/reference/ds/ds/queue/peek.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-
-
- Ds\Queue::peek
- Returns the value at the front of the queue
-
-
-
- &reftitle.description;
-
- publicmixedDs\Queue::peek
-
-
-
- Returns the value at the front of the queue, but does not remove it.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The value at the front of the queue.
-
-
-
-
- &reftitle.errors;
-
- UnderflowException if empty.
-
-
-
-
- &reftitle.examples;
-
- Ds\Queue::peek example
-
-push("a");
-$queue->push("b");
-$queue->push("c");
-
-var_dump($queue->peek());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/queue/pop.xml b/reference/ds/ds/queue/pop.xml
deleted file mode 100644
index 3d098b733605..000000000000
--- a/reference/ds/ds/queue/pop.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
- Ds\Queue::pop
- Removes and returns the value at the front of the queue
-
-
-
- &reftitle.description;
-
- publicmixedDs\Queue::pop
-
-
-
- Removes and returns the value at the front of the queue.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The removed value which was at the front of the queue.
-
-
-
-
- &reftitle.errors;
-
- UnderflowException if empty.
-
-
-
-
- &reftitle.examples;
-
- Ds\Queue::pop example
-
-push("a");
-$queue->push("b");
-$queue->push("c");
-
-var_dump($queue->pop());
-var_dump($queue->pop());
-var_dump($queue->pop());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/queue/push.xml b/reference/ds/ds/queue/push.xml
deleted file mode 100644
index 759df53ec3b1..000000000000
--- a/reference/ds/ds/queue/push.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
-
-
-
- Ds\Queue::push
- Pushes values into the queue
-
-
-
- &reftitle.description;
-
- publicvoidDs\Queue::push
- mixedvalues
-
-
- Pushes values into the queue.
-
-
-
-
-
- &reftitle.parameters;
-
-
- values
-
-
- The values to push into the queue.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Queue::push example
-
-push("a");
-$queue->push("b");
-$queue->push("c", "d");
-$queue->push(...["e", "f"]);
-
-print_r($queue);
-?>
-]]>
-
- &example.outputs.similar;
-
- a
- [1] => b
- [2] => c
- [3] => d
- [4] => e
- [5] => f
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/seq/__serialize.xml b/reference/ds/ds/seq/__serialize.xml
new file mode 100644
index 000000000000..075eb36fbe18
--- /dev/null
+++ b/reference/ds/ds/seq/__serialize.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+ Ds\Seq::__serialize
+ Returns the serialized representation of the sequence
+
+
+
+ &reftitle.description;
+
+ See Serializable::__serialize
+
+
+
+ You should never need to call this directly.
+
+
+
+
+
+
+
diff --git a/reference/ds/ds/seq/__unserialize.xml b/reference/ds/ds/seq/__unserialize.xml
new file mode 100644
index 000000000000..16d57b35df1c
--- /dev/null
+++ b/reference/ds/ds/seq/__unserialize.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+ Ds\Seq::__unserialize
+ Restores the sequence from its serialized form
+
+
+
+ &reftitle.description;
+
+ See Serializable::__unserialize
+
+
+
+ You should never need to call this directly.
+
+
+
+
+
+
+
diff --git a/reference/ds/ds/deque/allocate.xml b/reference/ds/ds/seq/allocate.xml
similarity index 83%
rename from reference/ds/ds/deque/allocate.xml
rename to reference/ds/ds/seq/allocate.xml
index a98192955c29..9de22e0f6899 100644
--- a/reference/ds/ds/deque/allocate.xml
+++ b/reference/ds/ds/seq/allocate.xml
@@ -1,16 +1,16 @@
-
+
- Ds\Deque::allocate
+ Ds\Seq::allocateAllocates enough memory for a required capacity
&reftitle.description;
- publicvoidDs\Deque::allocate
+ publicvoidDs\Seq::allocateintcapacity
@@ -54,15 +54,15 @@
&reftitle.examples;
- Ds\Deque::allocate example
+ Ds\Seq::allocate example
capacity());
+$seq = new \Ds\Seq();
+var_dump($seq->capacity());
-$deque->allocate(100);
-var_dump($deque->capacity());
+$seq->allocate(100);
+var_dump($seq->capacity());
?>
]]>
diff --git a/reference/ds/ds/deque/apply.xml b/reference/ds/ds/seq/apply.xml
similarity index 81%
rename from reference/ds/ds/deque/apply.xml
rename to reference/ds/ds/seq/apply.xml
index 8d39690988e1..b5da0e092c7e 100644
--- a/reference/ds/ds/deque/apply.xml
+++ b/reference/ds/ds/seq/apply.xml
@@ -1,21 +1,21 @@
-
+
- Ds\Deque::apply
+ Ds\Seq::applyUpdates all values by applying a callback function to each value
&reftitle.description;
- publicvoidDs\Deque::apply
+ publicvoidDs\Seq::applycallablecallback
Updates all values by applying a callback function to
- each value in the deque.
+ each value in the seq.
@@ -34,7 +34,7 @@
- A callable to apply to each value in the deque.
+ A callable to apply to each value in the seq.
@@ -56,21 +56,21 @@
&reftitle.examples;
- Ds\Deque::apply example
+ Ds\Seq::apply example
apply(function($value) { return $value * 2; });
+$seq = new \Ds\Seq([1, 2, 3]);
+$seq->apply(function($value) { return $value * 2; });
-print_r($deque);
+print_r($seq);
?>
]]>
&example.outputs.similar;
2
[1] => 4
diff --git a/reference/ds/ds/deque/capacity.xml b/reference/ds/ds/seq/capacity.xml
similarity index 75%
rename from reference/ds/ds/deque/capacity.xml
rename to reference/ds/ds/seq/capacity.xml
index 3672eda1af38..ca55cb0a732f 100644
--- a/reference/ds/ds/deque/capacity.xml
+++ b/reference/ds/ds/seq/capacity.xml
@@ -1,16 +1,16 @@
-
+
- Ds\Deque::capacity
+ Ds\Seq::capacityReturns the current capacity
&reftitle.description;
- publicintDs\Deque::capacity
+ publicintDs\Seq::capacity
@@ -33,15 +33,12 @@
&reftitle.examples;
- Ds\Deque::capacity example
+ Ds\Seq::capacity example
capacity());
-
-$deque->push(...range(1, 50));
-var_dump($deque->capacity());
+$seq = new \Ds\Seq();
+var_dump($seq->capacity());
?>
]]>
@@ -49,7 +46,6 @@ var_dump($deque->capacity());
diff --git a/reference/ds/ds/stack/clear.xml b/reference/ds/ds/seq/clear.xml
similarity index 74%
rename from reference/ds/ds/stack/clear.xml
rename to reference/ds/ds/seq/clear.xml
index d02e578f3e02..3dfe460a280f 100644
--- a/reference/ds/ds/stack/clear.xml
+++ b/reference/ds/ds/seq/clear.xml
@@ -1,20 +1,20 @@
-
+
- Ds\Stack::clear
+ Ds\Seq::clearRemoves all values
&reftitle.description;
- publicvoidDs\Stack::clear
+ publicvoidDs\Seq::clear
- Removes all values from the stack.
+ Removes all values from the seq.
@@ -33,28 +33,28 @@
&reftitle.examples;
- Ds\Stack::clear example
+ Ds\Seq::clear example
clear();
-print_r($stack);
+$seq->clear();
+print_r($seq);
?>
]]>
&example.outputs.similar;
3
+ [0] => 1
[1] => 2
- [2] => 1
+ [2] => 3
)
-Ds\Stack Object
+Ds\Seq Object
(
)
]]>
diff --git a/reference/ds/ds/deque/construct.xml b/reference/ds/ds/seq/construct.xml
similarity index 63%
rename from reference/ds/ds/deque/construct.xml
rename to reference/ds/ds/seq/construct.xml
index 9579cc6b1c5d..5a9a982878a1 100644
--- a/reference/ds/ds/deque/construct.xml
+++ b/reference/ds/ds/seq/construct.xml
@@ -1,17 +1,17 @@
-
+
- Ds\Deque::__construct
+ Ds\Seq::__constructCreates a new instance
&reftitle.description;
- publicDs\Deque::__construct
- mixedvalues
+ publicDs\Seq::__construct
+ mixedvalues
Creates a new instance, using either a traversable
@@ -33,39 +33,27 @@
-
-
-
&reftitle.examples;
- Ds\Deque::__construct example
+ Ds\Seq::__construct example
]]>
&example.outputs.similar;
int(1)
[1]=>
diff --git a/reference/ds/ds/deque/contains.xml b/reference/ds/ds/seq/contains.xml
similarity index 62%
rename from reference/ds/ds/deque/contains.xml
rename to reference/ds/ds/seq/contains.xml
index 396ad121cc97..0024d9f90536 100644
--- a/reference/ds/ds/deque/contains.xml
+++ b/reference/ds/ds/seq/contains.xml
@@ -1,20 +1,20 @@
-
+
- Ds\Deque::contains
- Determines if the deque contains given values
+ Ds\Seq::contains
+ Determines if the seq contains given values
&reftitle.description;
- publicboolDs\Deque::contains
+ publicboolDs\Seq::containsmixedvalues
- Determines if the deque contains all values.
+ Determines if the seq contains all values.
@@ -36,30 +36,30 @@
&reftitle.returnvalues;
&false; if any of the provided values are not in the
- deque, &true; otherwise.
+ seq, &true; otherwise.
&reftitle.examples;
- Ds\Deque::contains example
+ Ds\Seq::contains example
contains('a')); // true
-var_dump($deque->contains('a', 'b')); // true
-var_dump($deque->contains('c', 'd')); // false
+var_dump($seq->contains('a')); // true
+var_dump($seq->contains('a', 'b')); // true
+var_dump($seq->contains('c', 'd')); // false
-var_dump($deque->contains(...['c', 'b', 'a'])); // true
+var_dump($seq->contains(...['c', 'b', 'a'])); // true
// Always strict
-var_dump($deque->contains(1)); // true
-var_dump($deque->contains('1')); // false
+var_dump($seq->contains(1)); // true
+var_dump($seq->contains('1')); // false
-var_dump($sequece->contains(...[])); // true
+var_dump($seq->contains(...[])); // true
?>
]]>
diff --git a/reference/ds/ds/vector/copy.xml b/reference/ds/ds/seq/copy.xml
similarity index 65%
rename from reference/ds/ds/vector/copy.xml
rename to reference/ds/ds/seq/copy.xml
index e002980c5d2b..02648b46e6fd 100644
--- a/reference/ds/ds/vector/copy.xml
+++ b/reference/ds/ds/seq/copy.xml
@@ -1,21 +1,27 @@
-
+
- Ds\Vector::copy
- Returns a shallow copy of the vector
+ Ds\Seq::copy
+ Returns a shallow copy of the seq
&reftitle.description;
- publicDs\VectorDs\Vector::copy
+ publicDs\SeqDs\Seq::copy
- Returns a shallow copy of the vector.
+ Returns a shallow copy of the seq.
+
+
+ This operation is O(1) due to copy-on-write. The internal buffer will
+ only be copied when either the original or the copy is modified.
+
+
@@ -26,21 +32,20 @@
&reftitle.returnvalues;
- Returns a shallow copy of the vector.
+ A shallow copy of the seq.
&reftitle.examples;
- Ds\Vector::copy example
+ Ds\Seq::copy example
copy();
-// Updating the copy doesn't affect the original
$b->push(4);
print_r($a);
@@ -51,13 +56,13 @@ print_r($b);
&example.outputs.similar;
1
[1] => 2
[2] => 3
)
-Ds\Vector Object
+Ds\Seq Object
(
[0] => 1
[1] => 2
diff --git a/reference/ds/ds/pair/copy.xml b/reference/ds/ds/seq/count.xml
similarity index 66%
rename from reference/ds/ds/pair/copy.xml
rename to reference/ds/ds/seq/count.xml
index f2b8481072be..f7c74a06c7bf 100644
--- a/reference/ds/ds/pair/copy.xml
+++ b/reference/ds/ds/seq/count.xml
@@ -1,20 +1,20 @@
-
+
- Ds\Pair::copy
- Returns a shallow copy of the pair
+ Ds\Seq::count
+ Returns the number of values in the seq
&reftitle.description;
- publicDs\PairDs\Pair::copy
+ publicintDs\Seq::count
- Returns a shallow copy of the pair.
+ Returns the number of values in the seq.
@@ -26,40 +26,26 @@
&reftitle.returnvalues;
- Returns a shallow copy of the pair.
+ The number of values in the seq.
&reftitle.examples;
- Ds\Pair::copy example
+ Ds\Seq::count example
copy();
-
-$a->key = "x";
-
-print_r($a);
-print_r($b);
+$seq = new \Ds\Seq([1, 2, 3]);
+var_dump($seq->count());
?>
]]>
&example.outputs.similar;
x
- [value] => 1
-)
-Ds\Pair Object
-(
- [key] => a
- [value] => 1
-)
+int(3)
]]>
diff --git a/reference/ds/ds/deque/filter.xml b/reference/ds/ds/seq/filter.xml
similarity index 75%
rename from reference/ds/ds/deque/filter.xml
rename to reference/ds/ds/seq/filter.xml
index b61b5934f738..50e3cb01f4d9 100644
--- a/reference/ds/ds/deque/filter.xml
+++ b/reference/ds/ds/seq/filter.xml
@@ -1,11 +1,11 @@
-
+
- Ds\Deque::filter
+ Ds\Seq::filter
- Creates a new deque using a callable to
+ Creates a new seq using a callable to
determine which values to include
@@ -13,11 +13,11 @@
&reftitle.description;
- publicDs\DequeDs\Deque::filter
- callablecallback
+ publicDs\SeqDs\Seq::filter
+ callablecallback&null;
- Creates a new deque using a callable to
+ Creates a new seq using a callable to
determine which values to include.
@@ -54,7 +54,7 @@
&reftitle.returnvalues;
- A new deque containing all the values for which
+ A new seq containing all the values for which
either the callback returned &true;, or all values that
convert to &true; if a callback was not provided.
@@ -63,13 +63,13 @@
&reftitle.examples;
- Ds\Deque::filter example using callback function
+ Ds\Seq::filter example using callback function
filter(function($value) {
+var_dump($seq->filter(function($value) {
return $value % 2 == 0;
}));
?>
@@ -78,7 +78,7 @@ var_dump($deque->filter(function($value) {
&example.outputs.similar;
int(2)
[1]=>
@@ -88,20 +88,20 @@ object(Ds\Deque)#3 (2) {
- Ds\Deque::filter example without a callback function
+ Ds\Seq::filter example without a callback function
filter());
+var_dump($seq->filter());
?>
]]>
&example.outputs.similar;
int(1)
[1]=>
diff --git a/reference/ds/ds/vector/find.xml b/reference/ds/ds/seq/find.xml
similarity index 77%
rename from reference/ds/ds/vector/find.xml
rename to reference/ds/ds/seq/find.xml
index 3678176bf9fb..527b9e411f72 100644
--- a/reference/ds/ds/vector/find.xml
+++ b/reference/ds/ds/seq/find.xml
@@ -1,9 +1,9 @@
-
+
- Ds\Vector::find
+ Ds\Seq::find
Attempts to find a value's index
@@ -12,7 +12,7 @@
&reftitle.description;
- publicmixedDs\Vector::find
+ publicintfalseDs\Seq::findmixedvalue
@@ -50,16 +50,16 @@
&reftitle.examples;
- Ds\Vector::find example
+ Ds\Seq::find example
find("a")); // 0
-var_dump($vector->find("b")); // false
-var_dump($vector->find("1")); // false
-var_dump($vector->find(1)); // 1
+var_dump($seq->find("a")); // 0
+var_dump($seq->find("b")); // false
+var_dump($seq->find("1")); // false
+var_dump($seq->find(1)); // 1
?>
]]>
diff --git a/reference/ds/ds/vector/last.xml b/reference/ds/ds/seq/first.xml
similarity index 74%
rename from reference/ds/ds/vector/last.xml
rename to reference/ds/ds/seq/first.xml
index b8d6b68465cf..bd57c9483ae1 100644
--- a/reference/ds/ds/vector/last.xml
+++ b/reference/ds/ds/seq/first.xml
@@ -1,20 +1,20 @@
-
+
- Ds\Vector::last
- Returns the last value
+ Ds\Seq::first
+ Returns the first value in the seq
&reftitle.description;
- publicmixedDs\Vector::last
+ publicmixedDs\Seq::first
- Returns the last value in the vector.
+ Returns the first value in the seq.
@@ -26,7 +26,7 @@
&reftitle.returnvalues;
- The last value in the vector.
+ The first value in the seq.
@@ -40,19 +40,19 @@
&reftitle.examples;
- Ds\Vector::last example
+ Ds\Seq::first example
last());
+$seq = new \Ds\Seq([1, 2, 3]);
+var_dump($seq->first());
?>
]]>
&example.outputs.similar;
diff --git a/reference/ds/ds/deque/get.xml b/reference/ds/ds/seq/get.xml
similarity index 78%
rename from reference/ds/ds/deque/get.xml
rename to reference/ds/ds/seq/get.xml
index 374a3738380e..45d1dbdb214c 100644
--- a/reference/ds/ds/deque/get.xml
+++ b/reference/ds/ds/seq/get.xml
@@ -1,16 +1,16 @@
-
+
- Ds\Deque::get
+ Ds\Seq::getReturns the value at a given index
&reftitle.description;
- publicmixedDs\Deque::get
+ publicmixedDs\Seq::getintindex
@@ -50,15 +50,15 @@
&reftitle.examples;
- Ds\Deque::get example
+ Ds\Seq::get example
get(0));
-var_dump($deque->get(1));
-var_dump($deque->get(2));
+var_dump($seq->get(0));
+var_dump($seq->get(1));
+var_dump($seq->get(2));
?>
]]>
@@ -72,15 +72,15 @@ string(1) "c"
- Ds\Deque::get example using array syntax
+ Ds\Seq::get example using array syntax
]]>
diff --git a/reference/ds/ds/seq/getiterator.xml b/reference/ds/ds/seq/getiterator.xml
new file mode 100644
index 000000000000..be76a1ff7ccc
--- /dev/null
+++ b/reference/ds/ds/seq/getiterator.xml
@@ -0,0 +1,54 @@
+
+
+
+
+
+ Ds\Seq::getIterator
+ Returns an iterator for the sequence
+
+
+
+ &reftitle.description;
+
+ publicTraversableDs\Seq::getIterator
+
+
+
+ Returns an iterator for the sequence.
+
+
+
+
+ &reftitle.parameters;
+ &no.function.parameters;
+
+
+
+ &reftitle.returnvalues;
+
+ An instance of an object implementing Traversable.
+
+
+
+
+
+
diff --git a/reference/ds/ds/deque/insert.xml b/reference/ds/ds/seq/insert.xml
similarity index 76%
rename from reference/ds/ds/deque/insert.xml
rename to reference/ds/ds/seq/insert.xml
index 136ec85ce9cb..302d6cd7d501 100644
--- a/reference/ds/ds/deque/insert.xml
+++ b/reference/ds/ds/seq/insert.xml
@@ -1,21 +1,21 @@
-
+
- Ds\Deque::insert
+ Ds\Seq::insertInserts values at a given index
&reftitle.description;
- publicvoidDs\Deque::insert
+ publicvoidDs\Seq::insertintindexmixedvalues
- Inserts values into the deque at a given index.
+ Inserts values into the seq at a given index.
@@ -64,26 +64,26 @@
&reftitle.examples;
- Ds\Deque::insert example
+ Ds\Seq::insert example
insert(0, "e"); // [e]
-$deque->insert(1, "f"); // [e, f]
-$deque->insert(2, "g"); // [e, f, g]
-$deque->insert(0, "a", "b"); // [a, b, e, f, g]
-$deque->insert(2, ...["c", "d"]); // [a, b, c, d, e, f, g]
+$seq->insert(0, "e"); // [e]
+$seq->insert(1, "f"); // [e, f]
+$seq->insert(2, "g"); // [e, f, g]
+$seq->insert(0, "a", "b"); // [a, b, e, f, g]
+$seq->insert(2, ...["c", "d"]); // [a, b, c, d, e, f, g]
-var_dump($deque);
+var_dump($seq);
?>
]]>
&example.outputs.similar;
string(1) "a"
[1]=>
diff --git a/reference/ds/ds/stack/isempty.xml b/reference/ds/ds/seq/isempty.xml
similarity index 70%
rename from reference/ds/ds/stack/isempty.xml
rename to reference/ds/ds/seq/isempty.xml
index 09287137b26c..4c287a901761 100644
--- a/reference/ds/ds/stack/isempty.xml
+++ b/reference/ds/ds/seq/isempty.xml
@@ -1,20 +1,20 @@
-
+
- Ds\Stack::isEmpty
- Returns whether the stack is empty
+ Ds\Seq::isEmpty
+ Returns whether the seq is empty
&reftitle.description;
- publicboolDs\Stack::isEmpty
+ publicboolDs\Seq::isEmpty
- Returns whether the stack is empty.
+ Returns whether the seq is empty.
@@ -26,22 +26,22 @@
&reftitle.returnvalues;
- Returns &true; if the stack is empty, &false; otherwise.
+ Returns &true; if the seq is empty, &false; otherwise.
&reftitle.examples;
- Ds\Stack::isEmpty example
+ Ds\Seq::isEmpty example
isEmpty());
-var_dump($a->isEmpty());
-var_dump($b->isEmpty());
+$seq->clear();
+var_dump($seq->isEmpty());
?>
]]>
diff --git a/reference/ds/ds/deque/join.xml b/reference/ds/ds/seq/join.xml
similarity index 74%
rename from reference/ds/ds/deque/join.xml
rename to reference/ds/ds/seq/join.xml
index 6eef2d348814..a970215d576d 100644
--- a/reference/ds/ds/deque/join.xml
+++ b/reference/ds/ds/seq/join.xml
@@ -1,17 +1,17 @@
-
+
- Ds\Deque::join
+ Ds\Seq::joinJoins all values together as a string
&reftitle.description;
- publicstringDs\Deque::join
- stringglue
+ publicstringDs\Seq::join
+ stringglue&null;
Joins all values together as a string using an optional separator between each value.
@@ -35,20 +35,20 @@
&reftitle.returnvalues;
- All values of the deque joined together as a string.
+ All values of the seq joined together as a string.
&reftitle.examples;
- Ds\Deque::join example using a separator string
+ Ds\Seq::join example using a separator string
join("|"));
+var_dump($seq->join("|"));
?>
]]>
@@ -60,20 +60,20 @@ string(11) "a|b|c|1|2|3"
- Ds\Deque::join example without a separator string
+ Ds\Seq::join example without a separator string
join());
+var_dump($seq->join());
?>
]]>
&example.outputs.similar;
diff --git a/reference/ds/ds/queue/jsonserialize.xml b/reference/ds/ds/seq/jsonserialize.xml
similarity index 83%
rename from reference/ds/ds/queue/jsonserialize.xml
rename to reference/ds/ds/seq/jsonserialize.xml
index 26513d0511a7..9ac0b3210674 100644
--- a/reference/ds/ds/queue/jsonserialize.xml
+++ b/reference/ds/ds/seq/jsonserialize.xml
@@ -1,9 +1,9 @@
-
+
- Ds\Queue::jsonSerialize
+ Ds\Seq::jsonSerializeReturns a representation that can be converted to JSON
diff --git a/reference/ds/ds/deque/last.xml b/reference/ds/ds/seq/last.xml
similarity index 75%
rename from reference/ds/ds/deque/last.xml
rename to reference/ds/ds/seq/last.xml
index 8718c8041505..a38de9f2903e 100644
--- a/reference/ds/ds/deque/last.xml
+++ b/reference/ds/ds/seq/last.xml
@@ -1,20 +1,20 @@
-
+
- Ds\Deque::last
- Returns the last value
+ Ds\Seq::last
+ Returns the last value in the seq
&reftitle.description;
- publicmixedDs\Deque::last
+ publicmixedDs\Seq::last
- Returns the last value in the deque.
+ Returns the last value in the seq.
@@ -26,7 +26,7 @@
&reftitle.returnvalues;
- The last value in the deque.
+ The last value in the seq.
@@ -40,12 +40,12 @@
&reftitle.examples;
- Ds\Deque::last example
+ Ds\Seq::last example
last());
+$seq = new \Ds\Seq([1, 2, 3]);
+var_dump($seq->last());
?>
]]>
diff --git a/reference/ds/ds/deque/map.xml b/reference/ds/ds/seq/map.xml
similarity index 81%
rename from reference/ds/ds/deque/map.xml
rename to reference/ds/ds/seq/map.xml
index def1d450e67e..ace92557fa4f 100644
--- a/reference/ds/ds/deque/map.xml
+++ b/reference/ds/ds/seq/map.xml
@@ -1,21 +1,21 @@
-
+
- Ds\Deque::map
+ Ds\Seq::mapReturns the result of applying a callback to each value
&reftitle.description;
- publicDs\DequeDs\Deque::map
+ publicDs\SeqDs\Seq::mapcallablecallback
Returns the result of applying a callback function to
- each value in the deque.
+ each value in the seq.
@@ -34,11 +34,11 @@
- A callable to apply to each value in the deque.
+ A callable to apply to each value in the seq.
- The callable should return what the new value will be in the new deque.
+ The callable should return what the new value will be in the new seq.
@@ -50,7 +50,7 @@
&reftitle.returnvalues;
The result of applying a callback to each value in
- the deque.
+ the seq.
@@ -62,27 +62,27 @@
&reftitle.examples;
- Ds\Deque::map example
+ Ds\Seq::map example
map(function($value) { return $value * 2; }));
-print_r($deque);
+print_r($seq->map(function($value) { return $value * 2; }));
+print_r($seq);
?>
]]>
&example.outputs.similar;
2
[1] => 4
[2] => 6
)
-Ds\Deque Object
+Ds\Seq Object
(
[0] => 1
[1] => 2
diff --git a/reference/ds/ds/deque/merge.xml b/reference/ds/ds/seq/merge.xml
similarity index 75%
rename from reference/ds/ds/deque/merge.xml
rename to reference/ds/ds/seq/merge.xml
index 02412b276f02..8675255420d9 100644
--- a/reference/ds/ds/deque/merge.xml
+++ b/reference/ds/ds/seq/merge.xml
@@ -1,20 +1,20 @@
-
+
- Ds\Deque::merge
- Returns the result of adding all given values to the deque
+ Ds\Seq::merge
+ Returns the result of adding all given values to the seq
&reftitle.description;
- publicDs\DequeDs\Deque::merge
+ publicDs\SeqDs\Seq::mergemixedvalues
- Returns the result of adding all given values to the deque.
+ Returns the result of adding all given values to the seq.
@@ -36,7 +36,7 @@
&reftitle.returnvalues;
- The result of adding all given values to the deque,
+ The result of adding all given values to the seq,
effectively the same as adding the values to a copy, then returning that copy.
@@ -49,21 +49,21 @@
&reftitle.examples;
- Ds\Deque::merge example
+ Ds\Seq::merge example
merge([4, 5, 6]));
-var_dump($deque);
+var_dump($seq->merge([4, 5, 6]));
+var_dump($seq);
?>
]]>
&example.outputs.similar;
int(1)
[1]=>
@@ -77,7 +77,7 @@ object(Ds\Deque)#2 (6) {
[5]=>
int(6)
}
-object(Ds\Deque)#1 (3) {
+object(Ds\Seq)#1 (3) {
[0]=>
int(1)
[1]=>
diff --git a/reference/ds/ds/seq/offsetexists.xml b/reference/ds/ds/seq/offsetexists.xml
new file mode 100644
index 000000000000..02d0ec35d0a4
--- /dev/null
+++ b/reference/ds/ds/seq/offsetexists.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+ Ds\Seq::offsetExists
+ Returns whether an offset exists
+
+
+
+ &reftitle.description;
+
+ publicboolDs\Seq::offsetExists
+ mixedoffset
+
+
+ Returns whether an offset exists.
+
+
+
+
+ &reftitle.parameters;
+
+
+ offset
+
+
+ The offset to check.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &true; if the offset is valid, &false; otherwise.
+
+
+
+
+
+
diff --git a/reference/ds/ds/deque/isempty.xml b/reference/ds/ds/seq/offsetget.xml
similarity index 52%
rename from reference/ds/ds/deque/isempty.xml
rename to reference/ds/ds/seq/offsetget.xml
index 8fcf23f7eeea..6c18a9fafb07 100644
--- a/reference/ds/ds/deque/isempty.xml
+++ b/reference/ds/ds/seq/offsetget.xml
@@ -1,61 +1,44 @@
-
+
- Ds\Deque::isEmpty
- Returns whether the deque is empty
+ Ds\Seq::offsetGet
+ Returns the value at a given offset
&reftitle.description;
- publicboolDs\Deque::isEmpty
-
+ publicmixedDs\Seq::offsetGet
+ mixedoffset
- Returns whether the deque is empty.
+ Returns the value at a given offset.
&reftitle.parameters;
- &no.function.parameters;
+
+
+ offset
+
+
+ The offset to get.
+
+
+
+
&reftitle.returnvalues;
- Returns &true; if the deque is empty, &false; otherwise.
+ The value at the given offset.
-
- &reftitle.examples;
-
- Ds\Deque::isEmpty example
-
-isEmpty());
-var_dump($b->isEmpty());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
+
+
+
+ Ds\Seq::offsetSet
+ Sets the value at a given offset
+
+
+
+ &reftitle.description;
+
+ publicvoidDs\Seq::offsetSet
+ mixedoffset
+ mixedvalue
+
+
+ Sets the value at a given offset.
+
+
+
+
+ &reftitle.parameters;
+
+
+ offset
+
+
+ The offset to set.
+
+
+
+
+ value
+
+
+ The new value.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.void;
+
+
+
+
+
+
diff --git a/reference/ds/ds/seq/offsetunset.xml b/reference/ds/ds/seq/offsetunset.xml
new file mode 100644
index 000000000000..8c23f6a7729a
--- /dev/null
+++ b/reference/ds/ds/seq/offsetunset.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+ Ds\Seq::offsetUnset
+ Removes a value by offset
+
+
+
+ &reftitle.description;
+
+ publicvoidDs\Seq::offsetUnset
+ mixedoffset
+
+
+ Removes a value by offset.
+
+
+
+
+ &reftitle.parameters;
+
+
+ offset
+
+
+ The offset to unset.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.void;
+
+
+
+
+
+
diff --git a/reference/ds/ds/deque/pop.xml b/reference/ds/ds/seq/pop.xml
similarity index 80%
rename from reference/ds/ds/deque/pop.xml
rename to reference/ds/ds/seq/pop.xml
index 44960b60dac0..ea0e209c4206 100644
--- a/reference/ds/ds/deque/pop.xml
+++ b/reference/ds/ds/seq/pop.xml
@@ -1,16 +1,16 @@
-
+
- Ds\Deque::pop
+ Ds\Seq::popRemoves and returns the last value
&reftitle.description;
- publicmixedDs\Deque::pop
+ publicmixedDs\Seq::pop
@@ -41,15 +41,15 @@
&reftitle.examples;
- Ds\Deque::pop example
+ Ds\Seq::pop example
pop());
-var_dump($deque->pop());
-var_dump($deque->pop());
+var_dump($seq->pop());
+var_dump($seq->pop());
+var_dump($seq->pop());
?>
]]>
diff --git a/reference/ds/ds/stack/push.xml b/reference/ds/ds/seq/push.xml
similarity index 73%
rename from reference/ds/ds/stack/push.xml
rename to reference/ds/ds/seq/push.xml
index e00ba4c5d58b..9d20cfcdb88b 100644
--- a/reference/ds/ds/stack/push.xml
+++ b/reference/ds/ds/seq/push.xml
@@ -1,20 +1,20 @@
-
+
- Ds\Stack::push
- Pushes values onto the stack
+ Ds\Seq::push
+ Adds values to the end of the seq
&reftitle.description;
- publicvoidDs\Stack::push
+ publicvoidDs\Seq::pushmixedvalues
- Pushes values onto the stack.
+ Adds values to the end of the seq.
@@ -26,7 +26,7 @@
values
- The values to push onto the stack.
+ The values to add.
@@ -43,25 +43,25 @@
&reftitle.examples;
- Ds\Stack::push example
+ Ds\Seq::push example
push("a");
-$stack->push("b");
-$stack->push("c", "d");
-$stack->push(...["e", "f"]);
+$seq->push("a");
+$seq->push("b");
+$seq->push("c", "d");
+$seq->push(...["e", "f"]);
-print_r($stack);
+print_r($seq);
?>
]]>
&example.outputs.similar;
a
[1] => b
diff --git a/reference/ds/ds/deque/reduce.xml b/reference/ds/ds/seq/reduce.xml
similarity index 82%
rename from reference/ds/ds/deque/reduce.xml
rename to reference/ds/ds/seq/reduce.xml
index 745bcf683fb4..cf3f12fdbe6d 100644
--- a/reference/ds/ds/deque/reduce.xml
+++ b/reference/ds/ds/seq/reduce.xml
@@ -1,21 +1,21 @@
-
+
- Ds\Deque::reduce
- Reduces the deque to a single value using a callback function
+ Ds\Seq::reduce
+ Reduces the seq to a single value using a callback function
&reftitle.description;
- publicmixedDs\Deque::reduce
+ publicmixedDs\Seq::reducecallablecallbackmixedinitial
- Reduces the deque to a single value using a callback function.
+ Reduces the seq to a single value using a callback function.
@@ -75,17 +75,17 @@
&reftitle.examples;
- Ds\Deque::reduce with initial value example
+ Ds\Seq::reduce with initial value example
reduce($callback, 5));
+var_dump($seq->reduce($callback, 5));
// Iterations:
//
@@ -105,13 +105,13 @@ int(30)
- Ds\Deque::reduce without an initial value example
+ Ds\Seq::reduce without an initial value example
reduce(function($carry, $value) {
+var_dump($seq->reduce(function($carry, $value) {
return $carry + $value + 5;
}));
diff --git a/reference/ds/ds/deque/remove.xml b/reference/ds/ds/seq/remove.xml
similarity index 82%
rename from reference/ds/ds/deque/remove.xml
rename to reference/ds/ds/seq/remove.xml
index 100470a89dff..f7269fc0cce1 100644
--- a/reference/ds/ds/deque/remove.xml
+++ b/reference/ds/ds/seq/remove.xml
@@ -1,16 +1,16 @@
-
+
- Ds\Deque::remove
+ Ds\Seq::removeRemoves and returns a value by index
&reftitle.description;
- publicmixedDs\Deque::remove
+ publicmixedDs\Seq::removeintindex
@@ -50,15 +50,15 @@
&reftitle.examples;
- Ds\Deque::remove example
+ Ds\Seq::remove example
remove(1));
-var_dump($deque->remove(0));
-var_dump($deque->remove(0));
+var_dump($seq->remove(1));
+var_dump($seq->remove(0));
+var_dump($seq->remove(0));
?>
]]>
diff --git a/reference/ds/ds/deque/reverse.xml b/reference/ds/ds/seq/reverse.xml
similarity index 71%
rename from reference/ds/ds/deque/reverse.xml
rename to reference/ds/ds/seq/reverse.xml
index c530d5176a23..6f9d5ebbd0ca 100644
--- a/reference/ds/ds/deque/reverse.xml
+++ b/reference/ds/ds/seq/reverse.xml
@@ -1,22 +1,22 @@
-
+
- Ds\Deque::reverse
+ Ds\Seq::reverse
- Reverses the deque in-place
+ Reverses the seq in-place
&reftitle.description;
- publicvoidDs\Deque::reverse
+ publicvoidDs\Seq::reverse
- Reverses the deque in-place.
+ Reverses the seq in-place.
@@ -36,21 +36,21 @@
&reftitle.examples;
- Ds\Deque::reverse example
+ Ds\Seq::reverse example
reverse();
+$seq = new \Ds\Seq(["a", "b", "c"]);
+$seq->reverse();
-print_r($deque);
+print_r($seq);
?>
]]>
&example.outputs.similar;
c
[1] => b
diff --git a/reference/ds/ds/deque/reversed.xml b/reference/ds/ds/seq/reversed.xml
similarity index 66%
rename from reference/ds/ds/deque/reversed.xml
rename to reference/ds/ds/seq/reversed.xml
index f08000242a3e..b0defa81460e 100644
--- a/reference/ds/ds/deque/reversed.xml
+++ b/reference/ds/ds/seq/reversed.xml
@@ -1,20 +1,20 @@
-
+
- Ds\Deque::reversed
+ Ds\Seq::reversedReturns a reversed copy
&reftitle.description;
- publicDs\DequeDs\Deque::reversed
+ publicDs\SeqDs\Seq::reversed
- Returns a reversed copy of the deque.
+ Returns a reversed copy of the seq.
@@ -27,40 +27,39 @@
&reftitle.returnvalues;
- A reversed copy of the deque.
-
-
-
- The current instance is not affected.
-
-
+ A reversed copy of the seq.
+
+
+ The current instance is not affected.
+
+
&reftitle.examples;
- Ds\Deque::reversed example
+ Ds\Seq::reversed example
reversed());
-print_r($deque);
+print_r($seq->reversed());
+print_r($seq);
?>
]]>
&example.outputs.similar;
c
[1] => b
[2] => a
)
-Ds\Deque Object
+Ds\Seq Object
(
[0] => a
[1] => b
diff --git a/reference/ds/ds/deque/rotate.xml b/reference/ds/ds/seq/rotate.xml
similarity index 59%
rename from reference/ds/ds/deque/rotate.xml
rename to reference/ds/ds/seq/rotate.xml
index a053eb65ae6f..6f880a44ec5e 100644
--- a/reference/ds/ds/deque/rotate.xml
+++ b/reference/ds/ds/seq/rotate.xml
@@ -1,22 +1,22 @@
-
+
- Ds\Deque::rotate
- Rotates the deque by a given number of rotations
+ Ds\Seq::rotate
+ Rotates the seq by a given number of rotations
&reftitle.description;
- publicvoidDs\Deque::rotate
+ publicvoidDs\Seq::rotateintrotations
- Rotates the deque by a given number of rotations, which is equivalent
- to successively calling $deque->push($deque->shift()) if the number
- of rotations is positive, or $deque->unshift($deque->pop()) if negative.
+ Rotates the seq by a given number of rotations, which is equivalent
+ to successively calling $seq->push($seq->shift()) if the number
+ of rotations is positive, or $seq->unshift($seq->pop()) if negative.
@@ -28,7 +28,7 @@
rotations
- The number of times the deque should be rotated.
+ The number of times the seq should be rotated.
@@ -38,37 +38,38 @@
&reftitle.returnvalues;
- &return.void;. The deque of the current instance will be rotated.
+ &return.void;. The seq of the current instance will be rotated.
&reftitle.examples;
- Ds\Deque::rotate example
+ Ds\Seq::rotate example
rotate(1); // "a" is shifted, then pushed.
-print_r($deque);
+$seq->rotate(1); // "a" is shifted, then pushed.
+print_r($seq);
-$deque->rotate(2); // "b" and "c" are both shifted, the pushed.
-print_r($deque);
+$seq->rotate(2); // "b" and "c" are shifted, then pushed.
+print_r($seq);
?>
]]>
&example.outputs.similar;
b
[1] => c
[2] => d
[3] => a
)
-Ds\Deque Object
+Ds\Seq Object
(
[0] => d
[1] => a
diff --git a/reference/ds/ds/deque/set.xml b/reference/ds/ds/seq/set.xml
similarity index 76%
rename from reference/ds/ds/deque/set.xml
rename to reference/ds/ds/seq/set.xml
index 1555e6951a8f..6995f4187a46 100644
--- a/reference/ds/ds/deque/set.xml
+++ b/reference/ds/ds/seq/set.xml
@@ -1,16 +1,16 @@
-
+
- Ds\Deque::set
+ Ds\Seq::setUpdates a value at a given index
&reftitle.description;
- publicvoidDs\Deque::set
+ publicvoidDs\Seq::setintindexmixedvalue
@@ -43,10 +43,10 @@
- &reftitle.returnvalues;
-
- &return.void;
-
+ &reftitle.returnvalues;
+
+ &return.void;
+
@@ -59,21 +59,21 @@
&reftitle.examples;
- Ds\Deque::set example
+ Ds\Seq::set example
set(1, "_");
-print_r($deque);
+$seq->set(1, "_");
+print_r($seq);
?>
]]>
&example.outputs.similar;
a
[1] => _
@@ -83,21 +83,21 @@ Ds\Deque Object
- Ds\Deque::set example using array syntax
+ Ds\Seq::set example using array syntax
]]>
&example.outputs.similar;
a
[1] => _
diff --git a/reference/ds/ds/deque/shift.xml b/reference/ds/ds/seq/shift.xml
similarity index 80%
rename from reference/ds/ds/deque/shift.xml
rename to reference/ds/ds/seq/shift.xml
index ad76fb929a03..8712596f9a84 100644
--- a/reference/ds/ds/deque/shift.xml
+++ b/reference/ds/ds/seq/shift.xml
@@ -1,16 +1,16 @@
-
+
- Ds\Deque::shift
+ Ds\Seq::shiftRemoves and returns the first value
&reftitle.description;
- publicmixedDs\Deque::shift
+ publicmixedDs\Seq::shift
@@ -41,15 +41,15 @@
&reftitle.examples;
- Ds\Deque::shift example
+ Ds\Seq::shift example
shift());
-var_dump($deque->shift());
-var_dump($deque->shift());
+var_dump($seq->shift());
+var_dump($seq->shift());
+var_dump($seq->shift());
?>
]]>
diff --git a/reference/ds/ds/deque/slice.xml b/reference/ds/ds/seq/slice.xml
similarity index 65%
rename from reference/ds/ds/deque/slice.xml
rename to reference/ds/ds/seq/slice.xml
index f8191128f8fd..5e6a37d02b04 100644
--- a/reference/ds/ds/deque/slice.xml
+++ b/reference/ds/ds/seq/slice.xml
@@ -1,23 +1,23 @@
-
+
- Ds\Deque::slice
+ Ds\Seq::slice
- Returns a sub-deque of a given range
+ Returns a sub-seq of a given range
&reftitle.description;
- publicDs\DequeDs\Deque::slice
+ publicDs\SeqDs\Seq::sliceintindex
- intlength
+ intlength&null;
- Creates a sub-deque of a given range.
+ Creates a sub-seq of a given range.
@@ -29,11 +29,11 @@
index
- The index at which the sub-deque starts.
+ The index at which the sub-seq starts.
- If positive, the deque will start at that index in the deque.
- If negative, the deque will start that far from the end.
+ If positive, the seq will start at that index in the seq.
+ If negative, the seq will start that far from the end.
@@ -42,17 +42,17 @@
If a length is given and is positive, the resulting
- deque will have up to that many values in it.
+ seq will have up to that many values in it.
If the length results in an overflow, only
- values up to the end of the deque will be included.
+ values up to the end of the seq will be included.
- If a length is given and is negative, the deque
+ If a length is given and is negative, the seq
will stop that many values from the end.
- If a length is not provided, the resulting deque
+ If a length is not provided, the resulting seq
will contain all values between the index and the
- end of the deque.
+ end of the seq.
@@ -62,64 +62,64 @@
&reftitle.returnvalues;
- A sub-deque of the given range.
+ A sub-seq of the given range.
&reftitle.examples;
- Ds\Deque::slice example
+ Ds\Seq::slice example
slice(2));
+print_r($seq->slice(2));
// Slice from 1, for a length of 3
-print_r($deque->slice(1, 3));
+print_r($seq->slice(1, 3));
// Slice from 1 onwards
-print_r($deque->slice(1));
+print_r($seq->slice(1));
// Slice from 2 from the end onwards
-print_r($deque->slice(-2));
+print_r($seq->slice(-2));
// Slice from 1 to 1 from the end
-print_r($deque->slice(1, -1));
+print_r($seq->slice(1, -1));
?>
]]>
&example.outputs.similar;
c
[1] => d
[2] => e
)
-Ds\Deque Object
+Ds\Seq Object
(
[0] => b
[1] => c
[2] => d
)
-Ds\Deque Object
+Ds\Seq Object
(
[0] => b
[1] => c
[2] => d
[3] => e
)
-Ds\Deque Object
+Ds\Seq Object
(
[0] => d
[1] => e
)
-Ds\Deque Object
+Ds\Seq Object
(
[0] => b
[1] => c
diff --git a/reference/ds/ds/deque/sort.xml b/reference/ds/ds/seq/sort.xml
similarity index 70%
rename from reference/ds/ds/deque/sort.xml
rename to reference/ds/ds/seq/sort.xml
index b50d2c2fdab6..7167dc532cb2 100644
--- a/reference/ds/ds/deque/sort.xml
+++ b/reference/ds/ds/seq/sort.xml
@@ -1,22 +1,22 @@
-
+
- Ds\Deque::sort
+ Ds\Seq::sort
- Sorts the deque in-place
+ Sorts the seq in-place
&reftitle.description;
- publicvoidDs\Deque::sort
- callablecomparator
+ publicvoidDs\Seq::sort
+ callablecomparator&null;
- Sorts the deque in-place, using an optional comparator function.
+ Sorts the seq in-place, using an optional comparator function.
@@ -43,21 +43,21 @@
&reftitle.examples;
- Ds\Deque::sort example
+ Ds\Seq::sort example
sort();
+$seq = new \Ds\Seq([4, 5, 1, 3, 2]);
+$seq->sort();
-print_r($deque);
+print_r($seq);
?>
]]>
&example.outputs.similar;
1
[1] => 2
@@ -69,24 +69,24 @@ Ds\Deque Object
- Ds\Deque::sort example using a comparator
+ Ds\Seq::sort example using a comparator
sort(function($a, $b) {
+$seq->sort(function($a, $b) {
return $b <=> $a;
});
-print_r($deque);
+print_r($seq);
?>
]]>
&example.outputs.similar;
5
[1] => 4
diff --git a/reference/ds/ds/deque/sorted.xml b/reference/ds/ds/seq/sorted.xml
similarity index 72%
rename from reference/ds/ds/deque/sorted.xml
rename to reference/ds/ds/seq/sorted.xml
index 93241d67bcba..669cae838b99 100644
--- a/reference/ds/ds/deque/sorted.xml
+++ b/reference/ds/ds/seq/sorted.xml
@@ -1,17 +1,17 @@
-
+
- Ds\Deque::sorted
+ Ds\Seq::sortedReturns a sorted copy
&reftitle.description;
- publicDs\DequeDs\Deque::sorted
- callablecomparator
+ publicDs\SeqDs\Seq::sorted
+ callablecomparator&null;
Returns a sorted copy, using an optional comparator function.
@@ -34,27 +34,27 @@
&reftitle.returnvalues;
- Returns a sorted copy of the deque.
+ Returns a sorted copy of the seq.
&reftitle.examples;
- Ds\Deque::sorted example
+ Ds\Seq::sorted example
sorted());
+print_r($seq->sorted());
?>
]]>
&example.outputs.similar;
1
[1] => 2
@@ -66,24 +66,22 @@ Ds\Deque Object
- Ds\Deque::sorted example using a comparator
+ Ds\Seq::sorted example using a comparator
sorted(function($a, $b) {
+print_r($seq->sorted(function($a, $b) {
return $b <=> $a;
-});
-
-print_r($sorted);
+}));
?>
]]>
&example.outputs.similar;
5
[1] => 4
diff --git a/reference/ds/ds/deque/sum.xml b/reference/ds/ds/seq/sum.xml
similarity index 62%
rename from reference/ds/ds/deque/sum.xml
rename to reference/ds/ds/seq/sum.xml
index 5ae0a7135f6a..e1617f37d522 100644
--- a/reference/ds/ds/deque/sum.xml
+++ b/reference/ds/ds/seq/sum.xml
@@ -1,25 +1,25 @@
-
+
- Ds\Deque::sum
- Returns the sum of all values in the deque
+ Ds\Seq::sum
+ Returns the sum of all values in the seq
&reftitle.description;
- publicintfloatDs\Deque::sum
+ publicintfloatDs\Seq::sum
- Returns the sum of all values in the deque.
+ Returns the sum of all values in the seq.
-
- Arrays and objects are considered equal to zero when calculating the sum.
-
+
+ Arrays and objects are considered equal to zero.
+
@@ -32,20 +32,20 @@
&reftitle.returnvalues;
- The sum of all the values in the deque as either a float or int
- depending on the values in the deque.
+ The sum of all the values in the seq as either a float or int
+ depending on the values in the seq.
&reftitle.examples;
- Ds\Deque::sum integer example
+ Ds\Seq::sum integer example
sum());
+$seq = new \Ds\Seq([1, 2, 3]);
+var_dump($seq->sum());
?>
]]>
@@ -57,12 +57,12 @@ int(6)
- Ds\Deque::sum float example
+ Ds\Seq::sum float example
sum());
+$seq = new \Ds\Seq([1, 2.5, 3]);
+var_dump($seq->sum());
?>
]]>
diff --git a/reference/ds/ds/stack/toarray.xml b/reference/ds/ds/seq/toarray.xml
similarity index 74%
rename from reference/ds/ds/stack/toarray.xml
rename to reference/ds/ds/seq/toarray.xml
index 7c408173769b..a7311cdfc20d 100644
--- a/reference/ds/ds/stack/toarray.xml
+++ b/reference/ds/ds/seq/toarray.xml
@@ -1,27 +1,27 @@
-
+
- Ds\Stack::toArray
+ Ds\Seq::toArray
- Converts the stack to an &array;
+ Converts the seq to an &array;
&reftitle.description;
- publicarrayDs\Stack::toArray
+ publicarrayDs\Seq::toArray
- Converts the stack to an &array;.
+ Converts the seq to an &array;.
-
- Casting to an &array; is not supported yet.
-
+
+ Casting to an &array; is not supported yet.
+
@@ -34,20 +34,20 @@
&reftitle.returnvalues;
- An &array; containing all the values in the same order as the stack.
+ An &array; containing all the values in the same order as the seq.
&reftitle.examples;
- Ds\Stack::toArray example
+ Ds\Seq::toArray example
toArray());
+var_dump($seq->toArray());
?>
]]>
@@ -56,11 +56,11 @@ var_dump($stack->toArray());
- int(3)
+ int(1)
[1]=>
int(2)
[2]=>
- int(1)
+ int(3)
}
]]>
diff --git a/reference/ds/ds/vector/push.xml b/reference/ds/ds/seq/unshift.xml
similarity index 62%
rename from reference/ds/ds/vector/push.xml
rename to reference/ds/ds/seq/unshift.xml
index 248b9ebca859..2f631815309b 100644
--- a/reference/ds/ds/vector/push.xml
+++ b/reference/ds/ds/seq/unshift.xml
@@ -1,20 +1,21 @@
-
+
- Ds\Vector::push
- Adds values to the end of the vector
+ Ds\Seq::unshift
+ Adds values to the front of the seq
&reftitle.description;
- publicvoidDs\Vector::push
+ publicvoidDs\Seq::unshiftmixedvalues
- Adds values to the end of the vector.
+ Adds values to the front of the seq, moving all current values forward to
+ make room for the new values.
@@ -26,8 +27,13 @@
values
- The values to add.
+ The values to add to the front of the seq.
+
+
+ Multiple values will be added in the same order that they are passed.
+
+
@@ -43,32 +49,38 @@
&reftitle.examples;
- Ds\Vector::push example
+ Ds\Seq::unshift example
push("a");
-$vector->push("b");
-$vector->push("c", "d");
-$vector->push(...["e", "f"]);
+$seq->unshift("a");
+print_r($seq);
-print_r($vector);
+$seq->unshift("x", "y");
+print_r($seq);
?>
]]>
&example.outputs.similar;
a
- [1] => b
- [2] => c
- [3] => d
- [4] => e
- [5] => f
+ [1] => 1
+ [2] => 2
+ [3] => 3
+)
+Ds\Seq Object
+(
+ [0] => x
+ [1] => y
+ [2] => a
+ [3] => 1
+ [4] => 2
+ [5] => 3
)
]]>
diff --git a/reference/ds/ds/sequence/apply.xml b/reference/ds/ds/sequence/apply.xml
deleted file mode 100644
index 202f3bdd6b3a..000000000000
--- a/reference/ds/ds/sequence/apply.xml
+++ /dev/null
@@ -1,106 +0,0 @@
-
-
-
-
-
- Ds\Sequence::apply
- Updates all values by applying a callback function to each value
-
-
-
- &reftitle.description;
-
- abstractpublicvoidDs\Sequence::apply
- callablecallback
-
-
- Updates all values by applying a callback function to
- each value in the sequence.
-
-
-
-
- &reftitle.parameters;
-
-
- callback
-
-
-
-
- mixed
- callback
- mixedvalue
-
-
-
- A callable to apply to each value in the sequence.
-
-
-
- The callback should return what the value should be replaced by.
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::apply example
-
-apply(function($value) { return $value * 2; });
-
-print_r($sequence);
-?>
-]]>
-
- &example.outputs.similar;
-
- 2
- [1] => 4
- [2] => 6
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/capacity.xml b/reference/ds/ds/sequence/capacity.xml
deleted file mode 100644
index 8ac7a11244e3..000000000000
--- a/reference/ds/ds/sequence/capacity.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-
-
-
-
-
- Ds\Sequence::capacity
- Returns the current capacity
-
-
-
- &reftitle.description;
-
- abstractpublicintDs\Sequence::capacity
-
-
-
- Returns the current capacity.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The current capacity.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::capacity example
-
-capacity());
-
-$sequence->push(...range(1, 50));
-var_dump($sequence->capacity());
-
-$sequence[] = "a";
-var_dump($sequence->capacity());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/contains.xml b/reference/ds/ds/sequence/contains.xml
deleted file mode 100644
index 30772474d63f..000000000000
--- a/reference/ds/ds/sequence/contains.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-
-
-
-
-
- Ds\Sequence::contains
- Determines if the sequence contains given values
-
-
-
- &reftitle.description;
-
- abstractpublicboolDs\Sequence::contains
- mixedvalues
-
-
- Determines if the sequence contains all values.
-
-
-
-
- &reftitle.parameters;
-
-
- values
-
-
- Values to check.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &false; if any of the provided values are not in the
- sequence, &true; otherwise.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::contains example
-
-contains('a')); // true
-var_dump($sequence->contains('a', 'b')); // true
-var_dump($sequence->contains('c', 'd')); // false
-
-var_dump($sequence->contains(...['c', 'b', 'a'])); // true
-
-// Always strict
-var_dump($sequence->contains(1)); // true
-var_dump($sequence->contains('1')); // false
-
-var_dump($sequece->contains(...[])); // true
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/filter.xml b/reference/ds/ds/sequence/filter.xml
deleted file mode 100644
index 5d2307928558..000000000000
--- a/reference/ds/ds/sequence/filter.xml
+++ /dev/null
@@ -1,139 +0,0 @@
-
-
-
-
-
- Ds\Sequence::filter
-
- Creates a new sequence using a callable to
- determine which values to include
-
-
-
-
- &reftitle.description;
-
- abstractpublicDs\SequenceDs\Sequence::filter
- callablecallback
-
-
- Creates a new sequence using a callable to
- determine which values to include.
-
-
-
-
- &reftitle.parameters;
-
-
-
- callback
-
-
-
-
- bool
- callback
- mixedvalue
-
-
-
- Optional callable which returns &true; if the value should be included, &false; otherwise.
-
-
- If a callback is not provided, only values which are &true;
- (see converting to boolean)
- will be included.
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- A new sequence containing all the values for which
- either the callback returned &true;, or all values that
- convert to &true; if a callback was not provided.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::filter example using callback function
-
-filter(function($value) {
- return $value % 2 == 0;
-}));
-?>
-]]>
-
- &example.outputs.similar;
-
-
- int(2)
- [1]=>
- int(4)
-}
-]]>
-
-
-
- Ds\Sequence::filter example without a callback function
-
-filter());
-?>
-]]>
-
- &example.outputs.similar;
-
-
- int(1)
- [1]=>
- string(1) "a"
- [2]=>
- bool(true)
-}
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/find.xml b/reference/ds/ds/sequence/find.xml
deleted file mode 100644
index 7f0187768566..000000000000
--- a/reference/ds/ds/sequence/find.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
-
-
-
- Ds\Sequence::find
-
- Attempts to find a value's index
-
-
-
-
- &reftitle.description;
-
- abstractpublicmixedDs\Sequence::find
- mixedvalue
-
-
- Returns the index of the value, or &false; if not found.
-
-
-
-
-
- &reftitle.parameters;
-
-
- value
-
-
- The value to find.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- The index of the value, or &false; if not found.
-
-
-
- Values will be compared by value and by type.
-
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::find example
-
-find("a")); // 0
-var_dump($sequence->find("b")); // false
-var_dump($sequence->find("1")); // false
-var_dump($sequence->find(1)); // 1
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/first.xml b/reference/ds/ds/sequence/first.xml
deleted file mode 100644
index 883074d13684..000000000000
--- a/reference/ds/ds/sequence/first.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
-
- Ds\Sequence::first
- Returns the first value in the sequence
-
-
-
- &reftitle.description;
-
- abstractpublicmixedDs\Sequence::first
-
-
-
- Returns the first value in the sequence.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The first value in the sequence.
-
-
-
-
- &reftitle.errors;
-
- UnderflowException if empty.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::first example
-
-first());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/get.xml b/reference/ds/ds/sequence/get.xml
deleted file mode 100644
index 49a0b6c2dbd9..000000000000
--- a/reference/ds/ds/sequence/get.xml
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
- Ds\Sequence::get
- Returns the value at a given index
-
-
-
- &reftitle.description;
-
- abstractpublicmixedDs\Sequence::get
- intindex
-
-
- Returns the value at a given index.
-
-
-
-
-
- &reftitle.parameters;
-
-
- index
-
-
- The index to access, starting at 0.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- The value at the requested index.
-
-
-
-
- &reftitle.errors;
-
- OutOfRangeException if the index is not valid.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::get example
-
-get(0));
-var_dump($sequence->get(1));
-var_dump($sequence->get(2));
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
- Ds\Sequence::get example using array syntax
-
-
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/insert.xml b/reference/ds/ds/sequence/insert.xml
deleted file mode 100644
index c0b3171653f3..000000000000
--- a/reference/ds/ds/sequence/insert.xml
+++ /dev/null
@@ -1,129 +0,0 @@
-
-
-
-
-
- Ds\Sequence::insert
- Inserts values at a given index
-
-
-
- &reftitle.description;
-
- abstractpublicvoidDs\Sequence::insert
- intindex
- mixedvalues
-
-
- Inserts values into the sequence at a given index.
-
-
-
-
-
- &reftitle.parameters;
-
-
- index
-
-
- The index at which to insert. 0 <= index <= count
-
-
-
- You can insert at the index equal to the number of values.
-
-
-
-
-
- values
-
-
- The value or values to insert.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.errors;
-
- OutOfRangeException if the index is not valid.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::insert example
-
-insert(0, "e"); // [e]
-$sequence->insert(1, "f"); // [e, f]
-$sequence->insert(2, "g"); // [e, f, g]
-$sequence->insert(0, "a", "b"); // [a, b, e, f, g]
-$sequence->insert(2, ...["c", "d"]); // [a, b, c, d, e, f, g]
-
-var_dump($sequence);
-?>
-]]>
-
- &example.outputs.similar;
-
-
- string(1) "a"
- [1]=>
- string(1) "b"
- [2]=>
- string(1) "c"
- [3]=>
- string(1) "d"
- [4]=>
- string(1) "e"
- [5]=>
- string(1) "f"
- [6]=>
- string(1) "g"
-}
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/join.xml b/reference/ds/ds/sequence/join.xml
deleted file mode 100644
index db09f84a426f..000000000000
--- a/reference/ds/ds/sequence/join.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
- Ds\Sequence::join
- Joins all values together as a string
-
-
-
- &reftitle.description;
-
- abstractpublicstringDs\Sequence::join
- stringglue
-
-
- Joins all values together as a string using an optional separator between each value.
-
-
-
-
- &reftitle.parameters;
-
-
- glue
-
-
- An optional string to separate each value.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- All values of the sequence joined together as a string.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::join example using a separator string
-
-join("|"));
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
- Ds\Sequence::join example without a separator string
-
-join());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/last.xml b/reference/ds/ds/sequence/last.xml
deleted file mode 100644
index 8455c938a634..000000000000
--- a/reference/ds/ds/sequence/last.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
-
- Ds\Sequence::last
- Returns the last value
-
-
-
- &reftitle.description;
-
- abstractpublicmixedDs\Sequence::last
-
-
-
- Returns the last value in the sequence.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The last value in the sequence.
-
-
-
-
- &reftitle.errors;
-
- UnderflowException if empty.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::last example
-
-last());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/map.xml b/reference/ds/ds/sequence/map.xml
deleted file mode 100644
index 310cfbff8839..000000000000
--- a/reference/ds/ds/sequence/map.xml
+++ /dev/null
@@ -1,118 +0,0 @@
-
-
-
-
-
- Ds\Sequence::map
- Returns the result of applying a callback to each value
-
-
-
- &reftitle.description;
-
- abstractpublicDs\SequenceDs\Sequence::map
- callablecallback
-
-
- Returns the result of applying a callback function to
- each value in the sequence.
-
-
-
-
- &reftitle.parameters;
-
-
- callback
-
-
-
-
- mixed
- callback
- mixedvalue
-
-
-
- A callable to apply to each value in the sequence.
-
-
-
- The callable should return what the new value will be in the new sequence.
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- The result of applying a callback to each value in
- the sequence.
-
-
-
- The values of the current instance won't be affected.
-
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::map example
-
-map(function($value) { return $value * 2; }));
-print_r($sequence);
-?>
-]]>
-
- &example.outputs.similar;
-
- 2
- [1] => 4
- [2] => 6
-)
-Ds\Vector Object
-(
- [0] => 1
- [1] => 2
- [2] => 3
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/merge.xml b/reference/ds/ds/sequence/merge.xml
deleted file mode 100644
index 0c8620b83626..000000000000
--- a/reference/ds/ds/sequence/merge.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-
-
-
-
-
- Ds\Sequence::merge
- Returns the result of adding all given values to the sequence
-
-
-
- &reftitle.description;
-
- abstractpublicDs\SequenceDs\Sequence::merge
- mixedvalues
-
-
- Returns the result of adding all given values to the sequence.
-
-
-
-
-
- &reftitle.parameters;
-
-
- values
-
-
- A traversable object or an &array;.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- The result of adding all given values to the sequence,
- effectively the same as adding the values to a copy, then returning that copy.
-
-
-
- The current instance won't be affected.
-
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::merge example
-
-merge([4, 5, 6]));
-var_dump($sequence);
-?>
-]]>
-
- &example.outputs.similar;
-
-
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
-}
-object(Ds\Vector)#1 (3) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
-}
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/pop.xml b/reference/ds/ds/sequence/pop.xml
deleted file mode 100644
index a2a10974c5b9..000000000000
--- a/reference/ds/ds/sequence/pop.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-
- Ds\Sequence::pop
- Removes and returns the last value
-
-
-
- &reftitle.description;
-
- abstractpublicmixedDs\Sequence::pop
-
-
-
- Removes and returns the last value.
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The removed last value.
-
-
-
-
- &reftitle.errors;
-
- UnderflowException if empty.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::pop example
-
-pop());
-var_dump($sequence->pop());
-var_dump($sequence->pop());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/push.xml b/reference/ds/ds/sequence/push.xml
deleted file mode 100644
index 607b759e9d04..000000000000
--- a/reference/ds/ds/sequence/push.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
-
-
-
- Ds\Sequence::push
- Adds values to the end of the sequence
-
-
-
- &reftitle.description;
-
- abstractpublicvoidDs\Sequence::push
- mixedvalues
-
-
- Adds values to the end of the sequence.
-
-
-
-
-
- &reftitle.parameters;
-
-
- values
-
-
- The values to add.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::push example
-
-push("a");
-$sequence->push("b");
-$sequence->push("c", "d");
-$sequence->push(...["e", "f"]);
-
-print_r($sequence);
-?>
-]]>
-
- &example.outputs.similar;
-
- a
- [1] => b
- [2] => c
- [3] => d
- [4] => e
- [5] => f
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/reduce.xml b/reference/ds/ds/sequence/reduce.xml
deleted file mode 100644
index ea8c3828911a..000000000000
--- a/reference/ds/ds/sequence/reduce.xml
+++ /dev/null
@@ -1,159 +0,0 @@
-
-
-
-
-
- Ds\Sequence::reduce
- Reduces the sequence to a single value using a callback function
-
-
-
- &reftitle.description;
-
- abstractpublicmixedDs\Sequence::reduce
- callablecallback
- mixedinitial
-
-
- Reduces the sequence to a single value using a callback function.
-
-
-
-
-
- &reftitle.parameters;
-
-
- callback
-
-
-
- mixedcallback
- mixedcarry
- mixedvalue
-
-
-
- carry
-
-
- The return value of the previous callback, or initial if
- it's the first iteration.
-
-
-
-
- value
-
-
- The value of the current iteration.
-
-
-
-
-
-
-
-
- initial
-
-
- The initial value of the carry value. Can be &null;.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- The return value of the final callback.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::reduce with initial value example
-
-reduce($callback, 5));
-
-// Iterations:
-//
-// $carry = $initial = 5
-//
-// $carry = $carry * 1 = 5
-// $carry = $carry * 2 = 10
-// $carry = $carry * 3 = 30
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
- Ds\Sequence::reduce without an initial value example
-
-reduce(function($carry, $value) {
- return $carry + $value + 5;
-}));
-
-// Iterations:
-//
-// $carry = $initial = null
-//
-// $carry = $carry + 1 + 5 = 6
-// $carry = $carry + 2 + 5 = 13
-// $carry = $carry + 3 + 5 = 21
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/remove.xml b/reference/ds/ds/sequence/remove.xml
deleted file mode 100644
index c5a21ffb0f62..000000000000
--- a/reference/ds/ds/sequence/remove.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-
-
-
-
-
- Ds\Sequence::remove
- Removes and returns a value by index
-
-
-
- &reftitle.description;
-
- abstractpublicmixedDs\Sequence::remove
- intindex
-
-
- Removes and returns a value by index.
-
-
-
-
-
- &reftitle.parameters;
-
-
- index
-
-
- The index of the value to remove.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- The value that was removed.
-
-
-
-
- &reftitle.errors;
-
- OutOfRangeException if the index is not valid.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::remove example
-
-remove(1));
-var_dump($sequence->remove(0));
-var_dump($sequence->remove(0));
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/reversed.xml b/reference/ds/ds/sequence/reversed.xml
deleted file mode 100644
index aff581c7cc15..000000000000
--- a/reference/ds/ds/sequence/reversed.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
-
- Ds\Sequence::reversed
- Returns a reversed copy
-
-
-
- &reftitle.description;
-
- abstractpublicDs\SequenceDs\Sequence::reversed
-
-
-
- Returns a reversed copy of the sequence.
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- A reversed copy of the sequence.
-
-
-
- The current instance is not affected.
-
-
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::reversed example
-
-reversed());
-print_r($sequence);
-?>
-]]>
-
- &example.outputs.similar;
-
- c
- [1] => b
- [2] => a
-)
-Ds\Vector Object
-(
- [0] => a
- [1] => b
- [2] => c
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/rotate.xml b/reference/ds/ds/sequence/rotate.xml
deleted file mode 100644
index 71c50973ca2e..000000000000
--- a/reference/ds/ds/sequence/rotate.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
-
-
-
- Ds\Sequence::rotate
- Rotates the sequence by a given number of rotations
-
-
-
- &reftitle.description;
-
- abstractpublicvoidDs\Sequence::rotate
- introtations
-
-
- Rotates the sequence by a given number of rotations, which is equivalent
- to successively calling $sequence->push($sequence->shift()) if the number
- of rotations is positive, or $sequence->unshift($sequence->pop()) if negative.
-
-
-
-
-
- &reftitle.parameters;
-
-
- rotations
-
-
- The number of times the sequence should be rotated.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;. The sequence of the current instance will be rotated.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::rotate example
-
-rotate(1); // "a" is shifted, then pushed.
-print_r($sequence);
-
-$sequence->rotate(2); // "b" and "c" are both shifted, the pushed.
-print_r($sequence);
-?>
-]]>
-
- &example.outputs.similar;
-
- b
- [1] => c
- [2] => d
- [3] => a
-)
-Ds\Vector Object
-(
- [0] => d
- [1] => a
- [2] => b
- [3] => c
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/set.xml b/reference/ds/ds/sequence/set.xml
deleted file mode 100644
index a123c531a8b7..000000000000
--- a/reference/ds/ds/sequence/set.xml
+++ /dev/null
@@ -1,133 +0,0 @@
-
-
-
-
-
- Ds\Sequence::set
- Updates a value at a given index
-
-
-
- &reftitle.description;
-
- abstractpublicvoidDs\Sequence::set
- intindex
- mixedvalue
-
-
- Updates a value at a given index.
-
-
-
-
-
- &reftitle.parameters;
-
-
- index
-
-
- The index of the value to update.
-
-
-
-
- value
-
-
- The new value.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.errors;
-
- OutOfRangeException if the index is not valid.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::set example
-
-set(1, "_");
-print_r($sequence);
-?>
-]]>
-
- &example.outputs.similar;
-
- a
- [1] => _
- [2] => c
-)
-]]>
-
-
-
- Ds\Sequence::set example using array syntax
-
-
-]]>
-
- &example.outputs.similar;
-
- a
- [1] => _
- [2] => c
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/shift.xml b/reference/ds/ds/sequence/shift.xml
deleted file mode 100644
index 41e47c31c194..000000000000
--- a/reference/ds/ds/sequence/shift.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-
- Ds\Sequence::shift
- Removes and returns the first value
-
-
-
- &reftitle.description;
-
- abstractpublicmixedDs\Sequence::shift
-
-
-
- Removes and returns the first value.
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The first value, which was removed.
-
-
-
-
- &reftitle.errors;
-
- UnderflowException if empty.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::shift example
-
-shift());
-var_dump($sequence->shift());
-var_dump($sequence->shift());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/slice.xml b/reference/ds/ds/sequence/slice.xml
deleted file mode 100644
index 83334fcd4c33..000000000000
--- a/reference/ds/ds/sequence/slice.xml
+++ /dev/null
@@ -1,156 +0,0 @@
-
-
-
-
-
- Ds\Sequence::slice
-
- Returns a sub-sequence of a given range
-
-
-
-
- &reftitle.description;
-
- abstractpublicDs\SequenceDs\Sequence::slice
- intindex
- intlength
-
-
- Creates a sub-sequence of a given range.
-
-
-
-
-
- &reftitle.parameters;
-
-
- index
-
-
- The index at which the sub-sequence starts.
-
-
- If positive, the sequence will start at that index in the sequence.
- If negative, the sequence will start that far from the end.
-
-
-
-
- length
-
-
- If a length is given and is positive, the resulting
- sequence will have up to that many values in it.
-
- If the length results in an overflow, only
- values up to the end of the sequence will be included.
-
- If a length is given and is negative, the sequence
- will stop that many values from the end.
-
- If a length is not provided, the resulting sequence
- will contain all values between the index and the
- end of the sequence.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- A sub-sequence of the given range.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::slice example
-
-slice(2));
-
-// Slice from 1, for a length of 3
-print_r($sequence->slice(1, 3));
-
-// Slice from 1 onwards
-print_r($sequence->slice(1));
-
-// Slice from 2 from the end onwards
-print_r($sequence->slice(-2));
-
-// Slice from 1 to 1 from the end
-print_r($sequence->slice(1, -1));
-?>
-]]>
-
- &example.outputs.similar;
-
- c
- [1] => d
- [2] => e
-)
-Ds\Vector Object
-(
- [0] => b
- [1] => c
- [2] => d
-)
-Ds\Vector Object
-(
- [0] => b
- [1] => c
- [2] => d
- [3] => e
-)
-Ds\Vector Object
-(
- [0] => d
- [1] => e
-)
-Ds\Vector Object
-(
- [0] => b
- [1] => c
- [2] => d
-)
-
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/sort.xml b/reference/ds/ds/sequence/sort.xml
deleted file mode 100644
index c9cf2a588c8f..000000000000
--- a/reference/ds/ds/sequence/sort.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-
-
-
-
-
- Ds\Sequence::sort
-
- Sorts the sequence in-place
-
-
-
-
- &reftitle.description;
-
- abstractpublicvoidDs\Sequence::sort
- callablecomparator
-
-
- Sorts the sequence in-place, using an optional comparator function.
-
-
-
-
-
- &reftitle.parameters;
-
-
- comparator
-
- &sort.callback.description;
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::sort example
-
-sort();
-
-print_r($sequence);
-?>
-]]>
-
- &example.outputs.similar;
-
- 1
- [1] => 2
- [2] => 3
- [3] => 4
- [4] => 5
-)
-]]>
-
-
-
- Ds\Sequence::sort example using a comparator
-
-sort(function($a, $b) {
- return $b <=> $a;
-});
-
-print_r($sequence);
-?>
-]]>
-
- &example.outputs.similar;
-
- 5
- [1] => 4
- [2] => 3
- [3] => 2
- [4] => 1
-)
-]]>
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/sorted.xml b/reference/ds/ds/sequence/sorted.xml
deleted file mode 100644
index d8014cf3b5c4..000000000000
--- a/reference/ds/ds/sequence/sorted.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-
-
-
-
-
- Ds\Sequence::sorted
- Returns a sorted copy
-
-
-
- &reftitle.description;
-
- abstractpublicDs\SequenceDs\Sequence::sorted
- callablecomparator
-
-
- Returns a sorted copy, using an optional comparator function.
-
-
-
-
-
- &reftitle.parameters;
-
-
- comparator
-
- &sort.callback.description;
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- Returns a sorted copy of the sequence.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::sorted example
-
-sorted());
-?>
-]]>
-
- &example.outputs.similar;
-
- 1
- [1] => 2
- [2] => 3
- [3] => 4
- [4] => 5
-)
-]]>
-
-
-
- Ds\Sequence::sorted example using a comparator
-
-sorted(function($a, $b) {
- return $b <=> $a;
-});
-
-print_r($sorted);
-?>
-]]>
-
- &example.outputs.similar;
-
- 5
- [1] => 4
- [2] => 3
- [3] => 2
- [4] => 1
-)
-]]>
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/sum.xml b/reference/ds/ds/sequence/sum.xml
deleted file mode 100644
index 55a76552f22e..000000000000
--- a/reference/ds/ds/sequence/sum.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
-
-
-
- Ds\Sequence::sum
- Returns the sum of all values in the sequence
-
-
-
- &reftitle.description;
-
- abstractpublicintfloatDs\Sequence::sum
-
-
-
- Returns the sum of all values in the sequence.
-
-
-
- Arrays and objects are considered equal to zero when calculating the sum.
-
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The sum of all the values in the sequence as either a float or int
- depending on the values in the sequence.
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::sum integer example
-
-sum());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
- Ds\Sequence::sum float example
-
-sum());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/sequence/unshift.xml b/reference/ds/ds/sequence/unshift.xml
deleted file mode 100644
index 8da0e57c32d4..000000000000
--- a/reference/ds/ds/sequence/unshift.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
- Ds\Sequence::unshift
- Adds values to the front of the sequence
-
-
-
- &reftitle.description;
-
- abstractpublicvoidDs\Sequence::unshift
- mixedvalues
-
-
- Adds values to the front of the sequence, moving all the current
- values forward to make room for the new values.
-
-
-
-
-
- &reftitle.parameters;
-
-
- values
-
-
- The values to add to the front of the sequence.
-
-
- Multiple values will be added in the same order that they are
- passed.
-
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Sequence::unshift example
-
-unshift("a");
-$sequence->unshift("b", "c");
-
-print_r($sequence);
-?>
-]]>
-
- &example.outputs.similar;
-
- b
- [1] => c
- [2] => a
- [3] => 1
- [4] => 2
- [5] => 3
-)
-]]>
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/set/__serialize.xml b/reference/ds/ds/set/__serialize.xml
new file mode 100644
index 000000000000..f02d8cfe5ed6
--- /dev/null
+++ b/reference/ds/ds/set/__serialize.xml
@@ -0,0 +1,41 @@
+
+
+
+ Ds\Set::__serialize
+ Returns the serialized representation of the set
+
+
+
+ &reftitle.description;
+
+ See Serializable::serialize
+
+
+
+ You should never need to call this directly.
+
+
+
+
+
+
+
diff --git a/reference/ds/ds/set/__unserialize.xml b/reference/ds/ds/set/__unserialize.xml
new file mode 100644
index 000000000000..6747e45b329b
--- /dev/null
+++ b/reference/ds/ds/set/__unserialize.xml
@@ -0,0 +1,41 @@
+
+
+
+ Ds\Set::__unserialize
+ Restores the set from its serialized form
+
+
+
+ &reftitle.description;
+
+ See Serializable::serialize
+
+
+
+ You should never need to call this directly.
+
+
+
+
+
+
+
diff --git a/reference/ds/ds/set/add.xml b/reference/ds/ds/set/add.xml
index fb373ffd13dd..6517a877e89e 100644
--- a/reference/ds/ds/set/add.xml
+++ b/reference/ds/ds/set/add.xml
@@ -20,10 +20,10 @@
Values of type object are supported.
- If an object implements Ds\Hashable,
+ If an object implements Ds\Key,
equality will be determined by the object's equals function.
- If an object does not implement Ds\Hashable,
+ If an object does not implement Ds\Key,
objects must be references to the same instance to be considered equal.
@@ -100,7 +100,7 @@ object(Ds\Set)#1 (5) {
value = $value;
}
- public function hash()
+ public function hash(): mixed
{
return $this->value;
}
- public function equals($obj): bool
+ public function equals(mixed $other): bool
{
- return $this->value === $obj->value;
+ return $this->value === $other->value;
}
}
@@ -135,11 +135,11 @@ $set->add($obj);
$set->add(new \stdClass());
$set->add(new \stdClass());
-// Adding multiple instances of equal hashable objects will only add the first.
-$set->add(new \HashableObject(1));
-$set->add(new \HashableObject(1));
-$set->add(new \HashableObject(2));
-$set->add(new \HashableObject(2));
+// Adding multiple instances of equal Key objects will only add the first.
+$set->add(new \KeyObject(1));
+$set->add(new \KeyObject(1));
+$set->add(new \KeyObject(2));
+$set->add(new \KeyObject(2));
var_dump($set);
?>
@@ -162,13 +162,13 @@ object(Ds\Set)#1 (5) {
object(stdClass)#4 (0) {
}
[3]=>
- object(HashableObject)#5 (1) {
- ["value":"HashableObject":private]=>
+ object(KeyObject)#5 (1) {
+ ["value":"KeyObject":private]=>
int(1)
}
[4]=>
- object(HashableObject)#6 (1) {
- ["value":"HashableObject":private]=>
+ object(KeyObject)#6 (1) {
+ ["value":"KeyObject":private]=>
int(2)
}
}
diff --git a/reference/ds/ds/set/contains.xml b/reference/ds/ds/set/contains.xml
index 96d21898500f..fa29851ae3cb 100644
--- a/reference/ds/ds/set/contains.xml
+++ b/reference/ds/ds/set/contains.xml
@@ -21,10 +21,10 @@
Values of type object are supported.
- If an object implements Ds\Hashable,
+ If an object implements Ds\Key,
equality will be determined by the object's equals function.
- If an object does not implement Ds\Hashable,
+ If an object does not implement Ds\Key,
objects must be references to the same instance to be considered equal.
diff --git a/reference/ds/ds/set/getiterator.xml b/reference/ds/ds/set/getiterator.xml
new file mode 100644
index 000000000000..a69bc1e2891a
--- /dev/null
+++ b/reference/ds/ds/set/getiterator.xml
@@ -0,0 +1,52 @@
+
+
+
+ Ds\Set::getIterator
+ Returns an iterator for the set
+
+
+
+ &reftitle.description;
+
+ publicTraversableDs\Set::getIterator
+
+
+
+ Returns an iterator for the set.
+
+
+
+
+ &reftitle.parameters;
+ &no.function.parameters;
+
+
+
+ &reftitle.returnvalues;
+
+ An instance of an object implementing Traversable.
+
+
+
+
+
+
diff --git a/reference/ds/ds/set/offsetexists.xml b/reference/ds/ds/set/offsetexists.xml
new file mode 100644
index 000000000000..5fcf82677dec
--- /dev/null
+++ b/reference/ds/ds/set/offsetexists.xml
@@ -0,0 +1,61 @@
+
+
+
+ Ds\Set::offsetExists
+ Returns whether an offset exists
+
+
+
+ &reftitle.description;
+
+ publicboolDs\Set::offsetExists
+ mixedoffset
+
+
+ Returns whether an offset exists.
+
+
+
+
+ &reftitle.parameters;
+
+
+ offset
+
+
+ The offset to check.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &true; if the offset is valid, &false; otherwise.
+
+
+
+
+
+
diff --git a/reference/ds/ds/set/offsetget.xml b/reference/ds/ds/set/offsetget.xml
new file mode 100644
index 000000000000..f5ccf09eea30
--- /dev/null
+++ b/reference/ds/ds/set/offsetget.xml
@@ -0,0 +1,61 @@
+
+
+
+ Ds\Set::offsetGet
+ Returns the value at a given offset
+
+
+
+ &reftitle.description;
+
+ publicmixedDs\Set::offsetGet
+ mixedoffset
+
+
+ Returns the value at a given offset.
+
+
+
+
+ &reftitle.parameters;
+
+
+ offset
+
+
+ The offset to get.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ The value at the given offset.
+
+
+
+
+
+
diff --git a/reference/ds/ds/set/offsetset.xml b/reference/ds/ds/set/offsetset.xml
new file mode 100644
index 000000000000..45d4fcf8ef96
--- /dev/null
+++ b/reference/ds/ds/set/offsetset.xml
@@ -0,0 +1,70 @@
+
+
+
+ Ds\Set::offsetSet
+ Sets the value at a given offset
+
+
+
+ &reftitle.description;
+
+ publicvoidDs\Set::offsetSet
+ mixedoffset
+ mixedvalue
+
+
+ Sets the value at a given offset.
+
+
+
+
+ &reftitle.parameters;
+
+
+ offset
+
+
+ The offset to set.
+
+
+
+
+ value
+
+
+ The new value.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.void;
+
+
+
+
+
+
diff --git a/reference/ds/ds/set/offsetunset.xml b/reference/ds/ds/set/offsetunset.xml
new file mode 100644
index 000000000000..dfa9e07f7ee4
--- /dev/null
+++ b/reference/ds/ds/set/offsetunset.xml
@@ -0,0 +1,61 @@
+
+
+
+ Ds\Set::offsetUnset
+ Removes a value by offset
+
+
+
+ &reftitle.description;
+
+ publicvoidDs\Set::offsetUnset
+ mixedoffset
+
+
+ Removes a value by offset.
+
+
+
+
+ &reftitle.parameters;
+
+
+ offset
+
+
+ The offset to unset.
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.void;
+
+
+
+
+
+
diff --git a/reference/ds/ds/stack/allocate.xml b/reference/ds/ds/stack/allocate.xml
deleted file mode 100644
index 9fa52d8b88dc..000000000000
--- a/reference/ds/ds/stack/allocate.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
-
- Ds\Stack::allocate
- Allocates enough memory for a required capacity
-
-
-
- &reftitle.description;
-
- publicvoidDs\Stack::allocate
- intcapacity
-
-
- Ensures that enough memory is allocated for a required capacity.
- This removes the need to reallocate the internal as values are added.
-
-
-
-
- &reftitle.parameters;
-
-
- capacity
-
-
- The number of values for which capacity should be allocated.
-
-
-
- Capacity will stay the same if this value is less than or equal to the
- current capacity.
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/stack/capacity.xml b/reference/ds/ds/stack/capacity.xml
deleted file mode 100644
index a793e68167fb..000000000000
--- a/reference/ds/ds/stack/capacity.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-
-
-
-
-
- Ds\Stack::capacity
- Returns the current capacity
-
-
-
- &reftitle.description;
-
- publicintDs\Stack::capacity
-
-
-
- Returns the current capacity.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The current capacity.
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/stack/construct.xml b/reference/ds/ds/stack/construct.xml
deleted file mode 100644
index 7554d18b4f44..000000000000
--- a/reference/ds/ds/stack/construct.xml
+++ /dev/null
@@ -1,102 +0,0 @@
-
-
-
-
-
- Ds\Stack::__construct
- Creates a new instance
-
-
-
- &reftitle.description;
-
- publicDs\Stack::__construct
- mixedvalues
-
-
- Creates a new instance, using either a traversable
- object or an &array; for the initial values.
-
-
-
-
- &reftitle.parameters;
-
-
- values
-
-
- A traversable object or an &array; to use for the initial values.
-
-
-
-
-
-
-
-
-
-
- &reftitle.examples;
-
- Ds\Stack::__construct example
-
-
-]]>
-
- &example.outputs.similar;
-
- 3
- [1] => 2
- [2] => 1
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/stack/copy.xml b/reference/ds/ds/stack/copy.xml
deleted file mode 100644
index 10ac257b0f01..000000000000
--- a/reference/ds/ds/stack/copy.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
-
-
- Ds\Stack::copy
- Returns a shallow copy of the stack
-
-
-
- &reftitle.description;
-
- publicDs\StackDs\Stack::copy
-
-
-
- Returns a shallow copy of the stack.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- Returns a shallow copy of the stack.
-
-
-
-
- &reftitle.examples;
-
- Ds\Stack::copy example
-
-copy();
-
-// Updating the copy doesn't affect the original
-$b->push(4);
-
-print_r($a);
-print_r($b);
-?>
-]]>
-
- &example.outputs.similar;
-
- 3
- [1] => 2
- [2] => 1
-)
-Ds\Stack Object
-(
- [0] => 4
- [1] => 3
- [2] => 2
- [3] => 1
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/stack/count.xml b/reference/ds/ds/stack/count.xml
deleted file mode 100644
index 4ff7fd78de16..000000000000
--- a/reference/ds/ds/stack/count.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
- Ds\Stack::count
- Returns the number of values in the stack
-
-
-
- &reftitle.description;
-
- See Countable::count
-
-
-
-
-
-
diff --git a/reference/ds/ds/stack/peek.xml b/reference/ds/ds/stack/peek.xml
deleted file mode 100644
index 183e5dccf3a3..000000000000
--- a/reference/ds/ds/stack/peek.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-
-
- Ds\Stack::peek
- Returns the value at the top of the stack
-
-
-
- &reftitle.description;
-
- publicmixedDs\Stack::peek
-
-
-
- Returns the value at the top of the stack, but does not remove it.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The value at the top of the stack.
-
-
-
-
- &reftitle.errors;
-
- UnderflowException if empty.
-
-
-
-
- &reftitle.examples;
-
- Ds\Stack::peek example
-
-push("a");
-$stack->push("b");
-$stack->push("c");
-
-var_dump($stack->peek());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/stack/pop.xml b/reference/ds/ds/stack/pop.xml
deleted file mode 100644
index df040a7881cd..000000000000
--- a/reference/ds/ds/stack/pop.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
- Ds\Stack::pop
- Removes and returns the value at the top of the stack
-
-
-
- &reftitle.description;
-
- publicmixedDs\Stack::pop
-
-
-
- Removes and returns the value at the top of the stack.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The removed value which was at the top of the stack.
-
-
-
-
- &reftitle.errors;
-
- UnderflowException if empty.
-
-
-
-
- &reftitle.examples;
-
- Ds\Stack::pop example
-
-push("a");
-$stack->push("b");
-$stack->push("c");
-
-var_dump($stack->pop());
-var_dump($stack->pop());
-var_dump($stack->pop());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/allocate.xml b/reference/ds/ds/vector/allocate.xml
deleted file mode 100644
index bed605da7796..000000000000
--- a/reference/ds/ds/vector/allocate.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
-
- Ds\Vector::allocate
- Allocates enough memory for a required capacity
-
-
-
- &reftitle.description;
-
- publicvoidDs\Vector::allocate
- intcapacity
-
-
- Ensures that enough memory is allocated for a required capacity.
- This removes the need to reallocate the internal as values are added.
-
-
-
-
- &reftitle.parameters;
-
-
- capacity
-
-
- The number of values for which capacity should be allocated.
-
-
-
- Capacity will stay the same if this value is less than or equal to the
- current capacity.
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::allocate example
-
-capacity());
-
-$vector->allocate(100);
-var_dump($vector->capacity());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/apply.xml b/reference/ds/ds/vector/apply.xml
deleted file mode 100644
index 64c8b61fd73e..000000000000
--- a/reference/ds/ds/vector/apply.xml
+++ /dev/null
@@ -1,106 +0,0 @@
-
-
-
-
-
- Ds\Vector::apply
- Updates all values by applying a callback function to each value
-
-
-
- &reftitle.description;
-
- publicvoidDs\Vector::apply
- callablecallback
-
-
- Updates all values by applying a callback function to
- each value in the vector.
-
-
-
-
- &reftitle.parameters;
-
-
- callback
-
-
-
-
- mixed
- callback
- mixedvalue
-
-
-
- A callable to apply to each value in the vector.
-
-
-
- The callback should return what the value should be replaced by.
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::apply example
-
-apply(function($value) { return $value * 2; });
-
-print_r($vector);
-?>
-]]>
-
- &example.outputs.similar;
-
- 2
- [1] => 4
- [2] => 6
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/clear.xml b/reference/ds/ds/vector/clear.xml
deleted file mode 100644
index 0960f80a2c24..000000000000
--- a/reference/ds/ds/vector/clear.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
-
- Ds\Vector::clear
- Removes all values
-
-
-
- &reftitle.description;
-
- publicvoidDs\Vector::clear
-
-
-
- Removes all values from the vector.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::clear example
-
-clear();
-print_r($vector);
-?>
-]]>
-
- &example.outputs.similar;
-
- 1
- [1] => 2
- [2] => 3
-)
-Ds\Vector Object
-(
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/construct.xml b/reference/ds/ds/vector/construct.xml
deleted file mode 100644
index fb9e4d703baf..000000000000
--- a/reference/ds/ds/vector/construct.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
- Ds\Vector::__construct
- Creates a new instance
-
-
-
- &reftitle.description;
-
- publicDs\Vector::__construct
- mixedvalues
-
-
- Creates a new instance, using either a traversable
- object or an &array; for the initial values.
-
-
-
-
- &reftitle.parameters;
-
-
- values
-
-
- A traversable object or an &array; to use for the initial values.
-
-
-
-
-
-
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::__construct example
-
-
-]]>
-
- &example.outputs.similar;
-
-
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
-}
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/contains.xml b/reference/ds/ds/vector/contains.xml
deleted file mode 100644
index 8ee226def21e..000000000000
--- a/reference/ds/ds/vector/contains.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-
-
-
-
-
- Ds\Vector::contains
- Determines if the vector contains given values
-
-
-
- &reftitle.description;
-
- publicboolDs\Vector::contains
- mixedvalues
-
-
- Determines if the vector contains all values.
-
-
-
-
- &reftitle.parameters;
-
-
- values
-
-
- Values to check.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &false; if any of the provided values are not in the
- vector, &true; otherwise.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::contains example
-
-contains('a')); // true
-var_dump($vector->contains('a', 'b')); // true
-var_dump($vector->contains('c', 'd')); // false
-
-var_dump($vector->contains(...['c', 'b', 'a'])); // true
-
-// Always strict
-var_dump($vector->contains(1)); // true
-var_dump($vector->contains('1')); // false
-
-var_dump($sequece->contains(...[])); // true
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/count.xml b/reference/ds/ds/vector/count.xml
deleted file mode 100644
index e2eced61ad30..000000000000
--- a/reference/ds/ds/vector/count.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
- Ds\Vector::count
- Returns the number of values in the collection
-
-
-
- &reftitle.description;
-
- See Countable::count
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/filter.xml b/reference/ds/ds/vector/filter.xml
deleted file mode 100644
index 4e26f00bd1fc..000000000000
--- a/reference/ds/ds/vector/filter.xml
+++ /dev/null
@@ -1,139 +0,0 @@
-
-
-
-
-
- Ds\Vector::filter
-
- Creates a new vector using a callable to
- determine which values to include
-
-
-
-
- &reftitle.description;
-
- publicDs\VectorDs\Vector::filter
- callablecallback
-
-
- Creates a new vector using a callable to
- determine which values to include.
-
-
-
-
- &reftitle.parameters;
-
-
-
- callback
-
-
-
-
- bool
- callback
- mixedvalue
-
-
-
- Optional callable which returns &true; if the value should be included, &false; otherwise.
-
-
- If a callback is not provided, only values which are &true;
- (see converting to boolean)
- will be included.
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- A new vector containing all the values for which
- either the callback returned &true;, or all values that
- convert to &true; if a callback was not provided.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::filter example using callback function
-
-filter(function($value) {
- return $value % 2 == 0;
-}));
-?>
-]]>
-
- &example.outputs.similar;
-
-
- int(2)
- [1]=>
- int(4)
-}
-]]>
-
-
-
- Ds\Vector::filter example without a callback function
-
-filter());
-?>
-]]>
-
- &example.outputs.similar;
-
-
- int(1)
- [1]=>
- string(1) "a"
- [2]=>
- bool(true)
-}
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/get.xml b/reference/ds/ds/vector/get.xml
deleted file mode 100644
index 178423cf4d3d..000000000000
--- a/reference/ds/ds/vector/get.xml
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
- Ds\Vector::get
- Returns the value at a given index
-
-
-
- &reftitle.description;
-
- publicmixedDs\Vector::get
- intindex
-
-
- Returns the value at a given index.
-
-
-
-
-
- &reftitle.parameters;
-
-
- index
-
-
- The index to access, starting at 0.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- The value at the requested index.
-
-
-
-
- &reftitle.errors;
-
- OutOfRangeException if the index is not valid.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::get example
-
-get(0));
-var_dump($vector->get(1));
-var_dump($vector->get(2));
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
- Ds\Vector::get example using array syntax
-
-
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/insert.xml b/reference/ds/ds/vector/insert.xml
deleted file mode 100644
index 2f1c67a7fd26..000000000000
--- a/reference/ds/ds/vector/insert.xml
+++ /dev/null
@@ -1,129 +0,0 @@
-
-
-
-
-
- Ds\Vector::insert
- Inserts values at a given index
-
-
-
- &reftitle.description;
-
- publicvoidDs\Vector::insert
- intindex
- mixedvalues
-
-
- Inserts values into the vector at a given index.
-
-
-
-
-
- &reftitle.parameters;
-
-
- index
-
-
- The index at which to insert. 0 <= index <= count
-
-
-
- You can insert at the index equal to the number of values.
-
-
-
-
-
- values
-
-
- The value or values to insert.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.errors;
-
- OutOfRangeException if the index is not valid.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::insert example
-
-insert(0, "e"); // [e]
-$vector->insert(1, "f"); // [e, f]
-$vector->insert(2, "g"); // [e, f, g]
-$vector->insert(0, "a", "b"); // [a, b, e, f, g]
-$vector->insert(2, ...["c", "d"]); // [a, b, c, d, e, f, g]
-
-var_dump($vector);
-?>
-]]>
-
- &example.outputs.similar;
-
-
- string(1) "a"
- [1]=>
- string(1) "b"
- [2]=>
- string(1) "c"
- [3]=>
- string(1) "d"
- [4]=>
- string(1) "e"
- [5]=>
- string(1) "f"
- [6]=>
- string(1) "g"
-}
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/isempty.xml b/reference/ds/ds/vector/isempty.xml
deleted file mode 100644
index 22e301628b52..000000000000
--- a/reference/ds/ds/vector/isempty.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
- Ds\Vector::isEmpty
- Returns whether the vector is empty
-
-
-
- &reftitle.description;
-
- publicboolDs\Vector::isEmpty
-
-
-
- Returns whether the vector is empty.
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- Returns &true; if the vector is empty, &false; otherwise.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::isEmpty example
-
-isEmpty());
-var_dump($b->isEmpty());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/join.xml b/reference/ds/ds/vector/join.xml
deleted file mode 100644
index 6b8c4dcaf05b..000000000000
--- a/reference/ds/ds/vector/join.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
- Ds\Vector::join
- Joins all values together as a string
-
-
-
- &reftitle.description;
-
- publicstringDs\Vector::join
- stringglue
-
-
- Joins all values together as a string using an optional separator between each value.
-
-
-
-
- &reftitle.parameters;
-
-
- glue
-
-
- An optional string to separate each value.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- All values of the vector joined together as a string.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::join example using a separator string
-
-join("|"));
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
- Ds\Vector::join example without a separator string
-
-join());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/map.xml b/reference/ds/ds/vector/map.xml
deleted file mode 100644
index 9664ccd64a38..000000000000
--- a/reference/ds/ds/vector/map.xml
+++ /dev/null
@@ -1,118 +0,0 @@
-
-
-
-
-
- Ds\Vector::map
- Returns the result of applying a callback to each value
-
-
-
- &reftitle.description;
-
- publicDs\VectorDs\Vector::map
- callablecallback
-
-
- Returns the result of applying a callback function to
- each value in the vector.
-
-
-
-
- &reftitle.parameters;
-
-
- callback
-
-
-
-
- mixed
- callback
- mixedvalue
-
-
-
- A callable to apply to each value in the vector.
-
-
-
- The callable should return what the new value will be in the new vector.
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- The result of applying a callback to each value in
- the vector.
-
-
-
- The values of the current instance won't be affected.
-
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::map example
-
-map(function($value) { return $value * 2; }));
-print_r($vector);
-?>
-]]>
-
- &example.outputs.similar;
-
- 2
- [1] => 4
- [2] => 6
-)
-Ds\Vector Object
-(
- [0] => 1
- [1] => 2
- [2] => 3
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/merge.xml b/reference/ds/ds/vector/merge.xml
deleted file mode 100644
index 955ad6bdde0e..000000000000
--- a/reference/ds/ds/vector/merge.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-
-
-
-
-
- Ds\Vector::merge
- Returns the result of adding all given values to the vector
-
-
-
- &reftitle.description;
-
- publicDs\VectorDs\Vector::merge
- mixedvalues
-
-
- Returns the result of adding all given values to the vector.
-
-
-
-
-
- &reftitle.parameters;
-
-
- values
-
-
- A traversable object or an &array;.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- The result of adding all given values to the vector,
- effectively the same as adding the values to a copy, then returning that copy.
-
-
-
- The current instance won't be affected.
-
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::merge example
-
-merge([4, 5, 6]));
-var_dump($vector);
-?>
-]]>
-
- &example.outputs.similar;
-
-
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
-}
-object(Ds\Vector)#1 (3) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
-}
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/reduce.xml b/reference/ds/ds/vector/reduce.xml
deleted file mode 100644
index a5a400ed826c..000000000000
--- a/reference/ds/ds/vector/reduce.xml
+++ /dev/null
@@ -1,159 +0,0 @@
-
-
-
-
-
- Ds\Vector::reduce
- Reduces the vector to a single value using a callback function
-
-
-
- &reftitle.description;
-
- publicmixedDs\Vector::reduce
- callablecallback
- mixedinitial
-
-
- Reduces the vector to a single value using a callback function.
-
-
-
-
-
- &reftitle.parameters;
-
-
- callback
-
-
-
- mixedcallback
- mixedcarry
- mixedvalue
-
-
-
- carry
-
-
- The return value of the previous callback, or initial if
- it's the first iteration.
-
-
-
-
- value
-
-
- The value of the current iteration.
-
-
-
-
-
-
-
-
- initial
-
-
- The initial value of the carry value. Can be &null;.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- The return value of the final callback.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::reduce with initial value example
-
-reduce($callback, 5));
-
-// Iterations:
-//
-// $carry = $initial = 5
-//
-// $carry = $carry * 1 = 5
-// $carry = $carry * 2 = 10
-// $carry = $carry * 3 = 30
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
- Ds\Vector::reduce without an initial value example
-
-reduce(function($carry, $value) {
- return $carry + $value + 5;
-}));
-
-// Iterations:
-//
-// $carry = $initial = null
-//
-// $carry = $carry + 1 + 5 = 6
-// $carry = $carry + 2 + 5 = 13
-// $carry = $carry + 3 + 5 = 21
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/remove.xml b/reference/ds/ds/vector/remove.xml
deleted file mode 100644
index b15f809cfe1d..000000000000
--- a/reference/ds/ds/vector/remove.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-
-
-
-
-
- Ds\Vector::remove
- Removes and returns a value by index
-
-
-
- &reftitle.description;
-
- publicmixedDs\Vector::remove
- intindex
-
-
- Removes and returns a value by index.
-
-
-
-
-
- &reftitle.parameters;
-
-
- index
-
-
- The index of the value to remove.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- The value that was removed.
-
-
-
-
- &reftitle.errors;
-
- OutOfRangeException if the index is not valid.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::remove example
-
-remove(1));
-var_dump($vector->remove(0));
-var_dump($vector->remove(0));
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/reverse.xml b/reference/ds/ds/vector/reverse.xml
deleted file mode 100644
index 2162bfc99355..000000000000
--- a/reference/ds/ds/vector/reverse.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-
-
-
- Ds\Vector::reverse
-
- Reverses the vector in-place
-
-
-
-
- &reftitle.description;
-
- publicvoidDs\Vector::reverse
-
-
-
- Reverses the vector in-place.
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::reverse example
-
-reverse();
-
-print_r($vector);
-?>
-]]>
-
- &example.outputs.similar;
-
- c
- [1] => b
- [2] => a
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/reversed.xml b/reference/ds/ds/vector/reversed.xml
deleted file mode 100644
index cca3679a82fc..000000000000
--- a/reference/ds/ds/vector/reversed.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
-
- Ds\Vector::reversed
- Returns a reversed copy
-
-
-
- &reftitle.description;
-
- publicDs\VectorDs\Vector::reversed
-
-
-
- Returns a reversed copy of the vector.
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- A reversed copy of the vector.
-
-
-
- The current instance is not affected.
-
-
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::reversed example
-
-reversed());
-print_r($vector);
-?>
-]]>
-
- &example.outputs.similar;
-
- c
- [1] => b
- [2] => a
-)
-Ds\Vector Object
-(
- [0] => a
- [1] => b
- [2] => c
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/rotate.xml b/reference/ds/ds/vector/rotate.xml
deleted file mode 100644
index e82315f82e34..000000000000
--- a/reference/ds/ds/vector/rotate.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
-
-
-
- Ds\Vector::rotate
- Rotates the vector by a given number of rotations
-
-
-
- &reftitle.description;
-
- publicvoidDs\Vector::rotate
- introtations
-
-
- Rotates the vector by a given number of rotations, which is equivalent
- to successively calling $vector->push($vector->shift()) if the number
- of rotations is positive, or $vector->unshift($vector->pop()) if negative.
-
-
-
-
-
- &reftitle.parameters;
-
-
- rotations
-
-
- The number of times the vector should be rotated.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;. The vector of the current instance will be rotated.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::rotate example
-
-rotate(1); // "a" is shifted, then pushed.
-print_r($vector);
-
-$vector->rotate(2); // "b" and "c" are both shifted, the pushed.
-print_r($vector);
-?>
-]]>
-
- &example.outputs.similar;
-
- b
- [1] => c
- [2] => d
- [3] => a
-)
-Ds\Vector Object
-(
- [0] => d
- [1] => a
- [2] => b
- [3] => c
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/set.xml b/reference/ds/ds/vector/set.xml
deleted file mode 100644
index 848b73a87d7b..000000000000
--- a/reference/ds/ds/vector/set.xml
+++ /dev/null
@@ -1,133 +0,0 @@
-
-
-
-
-
- Ds\Vector::set
- Updates a value at a given index
-
-
-
- &reftitle.description;
-
- publicvoidDs\Vector::set
- intindex
- mixedvalue
-
-
- Updates a value at a given index.
-
-
-
-
-
- &reftitle.parameters;
-
-
- index
-
-
- The index of the value to update.
-
-
-
-
- value
-
-
- The new value.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.errors;
-
- OutOfRangeException if the index is not valid.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::set example
-
-set(1, "_");
-print_r($vector);
-?>
-]]>
-
- &example.outputs.similar;
-
- a
- [1] => _
- [2] => c
-)
-]]>
-
-
-
- Ds\Vector::set example using array syntax
-
-
-]]>
-
- &example.outputs.similar;
-
- a
- [1] => _
- [2] => c
-)
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/shift.xml b/reference/ds/ds/vector/shift.xml
deleted file mode 100644
index f4facb9657c0..000000000000
--- a/reference/ds/ds/vector/shift.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-
- Ds\Vector::shift
- Removes and returns the first value
-
-
-
- &reftitle.description;
-
- publicmixedDs\Vector::shift
-
-
-
- Removes and returns the first value.
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The first value, which was removed.
-
-
-
-
- &reftitle.errors;
-
- UnderflowException if empty.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::shift example
-
-shift());
-var_dump($vector->shift());
-var_dump($vector->shift());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/slice.xml b/reference/ds/ds/vector/slice.xml
deleted file mode 100644
index 15c94e0d6b39..000000000000
--- a/reference/ds/ds/vector/slice.xml
+++ /dev/null
@@ -1,156 +0,0 @@
-
-
-
-
-
- Ds\Vector::slice
-
- Returns a sub-vector of a given range
-
-
-
-
- &reftitle.description;
-
- publicDs\VectorDs\Vector::slice
- intindex
- intlength
-
-
- Creates a sub-vector of a given range.
-
-
-
-
-
- &reftitle.parameters;
-
-
- index
-
-
- The index at which the sub-vector starts.
-
-
- If positive, the vector will start at that index in the vector.
- If negative, the vector will start that far from the end.
-
-
-
-
- length
-
-
- If a length is given and is positive, the resulting
- vector will have up to that many values in it.
-
- If the length results in an overflow, only
- values up to the end of the vector will be included.
-
- If a length is given and is negative, the vector
- will stop that many values from the end.
-
- If a length is not provided, the resulting vector
- will contain all values between the index and the
- end of the vector.
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- A sub-vector of the given range.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::slice example
-
-slice(2));
-
-// Slice from 1, for a length of 3
-print_r($vector->slice(1, 3));
-
-// Slice from 1 onwards
-print_r($vector->slice(1));
-
-// Slice from 2 from the end onwards
-print_r($vector->slice(-2));
-
-// Slice from 1 to 1 from the end
-print_r($vector->slice(1, -1));
-?>
-]]>
-
- &example.outputs.similar;
-
- c
- [1] => d
- [2] => e
-)
-Ds\Vector Object
-(
- [0] => b
- [1] => c
- [2] => d
-)
-Ds\Vector Object
-(
- [0] => b
- [1] => c
- [2] => d
- [3] => e
-)
-Ds\Vector Object
-(
- [0] => d
- [1] => e
-)
-Ds\Vector Object
-(
- [0] => b
- [1] => c
- [2] => d
-)
-
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/sort.xml b/reference/ds/ds/vector/sort.xml
deleted file mode 100644
index cb0c0949b100..000000000000
--- a/reference/ds/ds/vector/sort.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-
-
-
-
-
- Ds\Vector::sort
-
- Sorts the vector in-place
-
-
-
-
- &reftitle.description;
-
- publicvoidDs\Vector::sort
- callablecomparator
-
-
- Sorts the vector in-place, using an optional comparator function.
-
-
-
-
-
- &reftitle.parameters;
-
-
- comparator
-
- &sort.callback.description;
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::sort example
-
-sort();
-
-print_r($vector);
-?>
-]]>
-
- &example.outputs.similar;
-
- 1
- [1] => 2
- [2] => 3
- [3] => 4
- [4] => 5
-)
-]]>
-
-
-
- Ds\Vector::sort example using a comparator
-
-sort(function($a, $b) {
- return $b <=> $a;
-});
-
-print_r($vector);
-?>
-]]>
-
- &example.outputs.similar;
-
- 5
- [1] => 4
- [2] => 3
- [3] => 2
- [4] => 1
-)
-]]>
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/sorted.xml b/reference/ds/ds/vector/sorted.xml
deleted file mode 100644
index 8f99f36d022d..000000000000
--- a/reference/ds/ds/vector/sorted.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-
-
-
-
-
- Ds\Vector::sorted
- Returns a sorted copy
-
-
-
- &reftitle.description;
-
- publicDs\VectorDs\Vector::sorted
- callablecomparator
-
-
- Returns a sorted copy, using an optional comparator function.
-
-
-
-
-
- &reftitle.parameters;
-
-
- comparator
-
- &sort.callback.description;
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- Returns a sorted copy of the vector.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::sorted example
-
-sorted());
-?>
-]]>
-
- &example.outputs.similar;
-
- 1
- [1] => 2
- [2] => 3
- [3] => 4
- [4] => 5
-)
-]]>
-
-
-
- Ds\Vector::sorted example using a comparator
-
-sorted(function($a, $b) {
- return $b <=> $a;
-});
-
-print_r($sorted);
-?>
-]]>
-
- &example.outputs.similar;
-
- 5
- [1] => 4
- [2] => 3
- [3] => 2
- [4] => 1
-)
-]]>
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/sum.xml b/reference/ds/ds/vector/sum.xml
deleted file mode 100644
index 8480fa1469d9..000000000000
--- a/reference/ds/ds/vector/sum.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
-
-
-
- Ds\Vector::sum
- Returns the sum of all values in the vector
-
-
-
- &reftitle.description;
-
- publicintfloatDs\Vector::sum
-
-
-
- Returns the sum of all values in the vector.
-
-
-
- Arrays and objects are considered equal to zero when calculating the sum.
-
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- The sum of all the values in the vector as either a float or int
- depending on the values in the vector.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::sum integer example
-
-sum());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
- Ds\Vector::sum float example
-
-sum());
-?>
-]]>
-
- &example.outputs.similar;
-
-
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/toarray.xml b/reference/ds/ds/vector/toarray.xml
deleted file mode 100644
index e2126f8dc30c..000000000000
--- a/reference/ds/ds/vector/toarray.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
- Ds\Vector::toArray
-
- Converts the vector to an &array;
-
-
-
-
- &reftitle.description;
-
- publicarrayDs\Vector::toArray
-
-
-
- Converts the vector to an &array;.
-
-
-
- Casting to an &array; is not supported yet.
-
-
-
-
-
-
- &reftitle.parameters;
- &no.function.parameters;
-
-
-
- &reftitle.returnvalues;
-
- An &array; containing all the values in the same order as the vector.
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::toArray example
-
-toArray());
-?>
-]]>
-
- &example.outputs.similar;
-
-
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
-}
-]]>
-
-
-
-
-
-
-
-
diff --git a/reference/ds/ds/vector/unshift.xml b/reference/ds/ds/vector/unshift.xml
deleted file mode 100644
index 20a3e8ab2afa..000000000000
--- a/reference/ds/ds/vector/unshift.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
- Ds\Vector::unshift
- Adds values to the front of the vector
-
-
-
- &reftitle.description;
-
- publicvoidDs\Vector::unshift
- mixedvalues
-
-
- Adds values to the front of the vector, moving all the current
- values forward to make room for the new values.
-
-
-
-
-
- &reftitle.parameters;
-
-
- values
-
-
- The values to add to the front of the vector.
-
-
- Multiple values will be added in the same order that they are
- passed.
-
-
-
-
-
-
-
-
-
- &reftitle.returnvalues;
-
- &return.void;
-
-
-
-
- &reftitle.examples;
-
- Ds\Vector::unshift example
-
-unshift("a");
-$vector->unshift("b", "c");
-
-print_r($vector);
-?>
-]]>
-
- &example.outputs.similar;
-
- b
- [1] => c
- [2] => a
- [3] => 1
- [4] => 2
- [5] => 3
-)
-]]>
-
-
-
-
-
-
-
diff --git a/reference/ds/examples.xml b/reference/ds/examples.xml
index 6b593e38f6fd..e894a3c51614 100644
--- a/reference/ds/examples.xml
+++ b/reference/ds/examples.xml
@@ -4,19 +4,19 @@
&reftitle.examples;
- Vector
+ Seq
push('a');
-$vector->push('b', 'c');
+$seq->push('a');
+$seq->push('b', 'c');
-$vector[] = 'd';
+$seq[] = 'd';
-print_r($vector);
+print_r($seq);
?>
]]>
@@ -24,7 +24,7 @@ print_r($vector);
&example.outputs.similar;
a
[1] => b
diff --git a/reference/ds/setup.xml b/reference/ds/setup.xml
index 66f0fb9923bf..91fea347ce8e 100644
--- a/reference/ds/setup.xml
+++ b/reference/ds/setup.xml
@@ -7,7 +7,7 @@
&reftitle.required;
- PHP 7 is required by both the extension and the compatibility polyfill.
+ PHP >= 8.2 is required by both the extension and the compatibility polyfill.
@@ -28,9 +28,9 @@ pecl install ds
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -174,6 +73,7 @@
+
@@ -192,6 +92,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -224,25 +138,30 @@
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+