sorted-list / sorted-list
The package provides sorted list class.
Installs: 155
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/sorted-list/sorted-list
Requires
- php: ^7.4|^8.0
Requires (Dev)
- phpunit/phpunit: ^9.6
This package is auto-updated.
Last update: 2025-09-30 18:34:37 UTC
README
The package provides sorted list class with methods to work with sorted list.
How to install
Add the package
composer require sorted-list/sorted-list
How to use
Create a class SortedList
use SortedList\SortedList;
$sortedList = new SortedList();
Methods
- Add new value to sorted list
$sortedList->put($value);
- Get sorted list
$sortedList->get();
- Check if value exists in sorted list
$sortedList->exists($value);
- Get leftmost position of new value
$sortedList->leftPosition($value);
- Get rightmost position of new value
$sortedList->rightPosition($value);
- Get minimum and maximum value respectively
$sortedList->getMin();
$sortedList->getMax();
- Extract minimum and maximum value respectively
$sortedList->popMin();
$sortedList->popMax();
Unit tests
- Install unit test package
composer install --dev
- Run unit tests
./vendor/bin/phpunit