teds 0.5.1

Provides extra data structures and iterable/array functionality.


teds (Tentative Extra Data Structures) is a collection of data structures and iterable functionality

License: BSD-3-Clause

Changes

* Add Teds\array_value_first(), Teds\array_value_last()
* Add `Teds\stable_compare($v1, $v2): int` for a stable comparison function of arbitrary values. (see tests/misc/stable_compare.phpt).
Like strcmp, this returns a negative value for less than, and positive for greater than, and 0 for equality.
Note that php's `<` operator is not stable. `'10' < '0a' < '1b' < '9' < '10'`.
stable_compare fixes that by strictly ordering:
`null < false < true < int,float < string < array < object < resource`.
(objects and resources are compared by id, and arrays are compared recursively. Numbers are compared numerically. If an int is equal to a float, then the int is first)
(strings use strcmp)
* Make Deque iteration account for calls to shift/unshift tracking the position of the front of the Deque.
Calls to shift/unshift will do the following:
- Increase/Decrease the value returned by the iterator's key() by the number of elements added/removed to/from the front of the Deque. (`$deque[$iteratorKey] === $iteratorValue` at the time the key and value are returned).
- Repeated calls to shift will cause valid() to return false if the iterator's position ends up before the start of the Deque at the time iteration resumes.
- They will not cause the remaining values to be iterated over more than once or skipped.