sorted-list/sorted-list

The package provides sorted list class.

1.1.0 2024-10-02 16:20 UTC

This package is auto-updated.

Last update: 2025-03-30 17:26:06 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

  1. Add new value to sorted list
$sortedList->put($value);
  1. Get sorted list
$sortedList->get();
  1. Check if value exists in sorted list
$sortedList->exists($value);
  1. Get leftmost position of new value
$sortedList->leftPosition($value);
  1. Get rightmost position of new value
$sortedList->rightPosition($value);
  1. Get minimum and maximum value respectively
$sortedList->getMin();
$sortedList->getMax();
  1. Extract minimum and maximum value respectively
$sortedList->popMin();
$sortedList->popMax();

Unit tests

  1. Install unit test package
composer install --dev
  1. Run unit tests
./vendor/bin/phpunit