Sorted Collections for PHP >= 5.4

1.0.0 2015-03-17 23:07 UTC


Flattr this git repo Build Status Code coverage Scrutinizer Code Quality Dependency Status Latest Stable Version Total Downloads Latest Unstable Version License

Sorted Collection for PHP. Insertion, search, and removal compute in log(n) time where n is the number of items present in the collection. It uses AVL threaded tree [see @Knuth97, 1:320, Sect. 2.3.1] as internal structure.

@Knuth97: Donald E. Knuth, The Art of Computer Programming, Addison-Wesley, volumes 1 and 2, 2nd edition, 1997.

This project uses:


Using composer: either

$ composer create-project chdemko/sorted-collections:1.0.*@dev; cd sorted-collections

or create a composer.json file containing

    "require": {
        "chdemko/sorted-collections": "1.0.*@dev"

and run

$ composer install

Create a test.php file containg

require __DIR__ . '/vendor/autoload.php';

use chdemko\SortedCollection\TreeMap;

$tree = TreeMap::create()->put(
    [1=>1, 9=>9, 5=>5, 2=>2, 6=>6, 3=>3, 0=>0, 8=>8, 7=>7, 4=>4]
echo $tree . PHP_EOL;

This should print


See the examples folder for more information.



If you are using this project including publication in research activities, you have to cite it using (BibTeX format). You are also pleased to send me an email to

All releases can be found here