Download the PHP package vondrasoft/sorted-linked-list without Composer

On this page you can find all versions of the php package vondrasoft/sorted-linked-list. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sorted-linked-list

SortedLinkedList

Type-safe, homogeneous sorted singly linked list for PHP 8.4+.

Installation

Note: The repository includes a Docker setup for development purposes only (running tests, static analysis, benchmarks). It is not needed when using the library as a dependency in your project.

Quick start (Docker)

The project uses a pre-built Docker image (ghcr.io/vondrasoft/php-xdebug:8.4) with PHP 8.4 + Xdebug + Composer, so you don't need to build anything locally. The Dockerfile is kept in the repository for reference.

API

Type safety

The list locks its type on first insertion. Mixing types throws InvalidTypeException:

The type lock resets when all elements are removed, allowing the list to be reused with a different type.

String sorting

Strings are sorted using PHP's native < operator, which performs byte-by-byte (lexicographic) comparison. This works correctly for ASCII/English strings. For locale-aware sorting (e.g. Czech, German), a Collator from the intl extension would be needed — this is intentionally out of scope for a generic data structure.

Project structure

Code coverage

Class Methods Lines
InvalidTypeException 100.00% (1/1) 100.00% (7/7)
Node 100.00% (2/2) 100.00% (4/4)
SortedLinkedList 100.00% (12/12) 100.00% (104/104)
ValueType 100.00% (1/1) 100.00% (3/3)
Total 100.00% (16/16) 100.00% (118/118)

Quality tools

Tool Level Command
PHPUnit 69 tests, 107 assertions composer test / composer test-coverage
PHPStan Level 9 + strict rules (phpstan-strict-rules, shipmonk/phpstan-rules) composer analyze
PHPCS ShipMonk Coding Standard composer cs

Benchmarks

Note: The pre-built Docker image is built for arm64 (Apple Silicon / Mac). The benchmark results below reflect this architecture. Running the image on amd64 (e.g. Linux servers) may result in significantly slower performance due to QEMU userspace emulation — Docker transparently translates arm64 instructions to amd64 at runtime, which adds substantial overhead. For accurate benchmarks on amd64, rebuild the image natively (docker build --platform linux/amd64).

Run docker compose exec php composer benchmark to measure performance across different scenarios:

Size Time
100 elements 2.64 ms
500 elements 2.12 ms
1,000 elements 7.10 ms
5,000 elements 162.02 ms
10,000 elements 640.19 ms
Size Time
100 elements 0.26 ms
500 elements 3.34 ms
1,000 elements 11.44 ms
5,000 elements 261.77 ms
10,000 elements 1,098.61 ms
Size Already sorted Reverse sorted
100 elements 0.10 ms 0.11 ms
500 elements 0.47 ms 0.45 ms
1,000 elements 0.86 ms 0.82 ms
5,000 elements 4.07 ms 4.03 ms
10,000 elements 8.23 ms 7.90 ms
Size Time
100 elements 0.07 ms
500 elements 0.22 ms
1,000 elements 0.46 ms
5,000 elements 2.18 ms
10,000 elements 4.45 ms
Size toArray() foreach
100 elements 0.01 ms 0.03 ms
500 elements 0.03 ms 0.10 ms
1,000 elements 0.05 ms 0.20 ms
5,000 elements 0.24 ms 0.81 ms
10,000 elements 0.48 ms 1.63 ms

Middle element (contains):

Size while foreach in_array
100 elements 2.35 ms 7.75 ms 0.31 ms
500 elements 9.67 ms 38.10 ms 0.48 ms
1,000 elements 18.99 ms 76.67 ms 0.71 ms
5,000 elements 92.94 ms 372.95 ms 2.29 ms
10,000 elements 186.13 ms 756.94 ms 4.38 ms

Last element:

Size tail O(1) while foreach end()
100 elements 0.25 ms 2.29 ms 16.09 ms 0.23 ms
500 elements 0.26 ms 9.44 ms 78.43 ms 0.23 ms
1,000 elements 0.25 ms 18.38 ms 156.64 ms 0.24 ms
5,000 elements 0.25 ms 86.98 ms 766.63 ms 0.25 ms
10,000 elements 0.26 ms 174.49 ms 1,523.88 ms 0.23 ms

1,000 calls per scenario.

Size LinkedList array ratio
100 elements 7.9 KB 2.6 KB 3.1x
500 elements 39.2 KB 12.1 KB 3.2x
1,000 elements 78.2 KB 20.1 KB 3.9x
5,000 elements 390.7 KB 132.1 KB 3.0x
10,000 elements 909.4 KB 260.1 KB 3.5x

SortedLinkedList (CZ)

Typově bezpečný, homogenní seřazený jednosměrný lineární seznam pro PHP 8.4+.

Instalace

Poznámka: Repozitář obsahuje Docker setup pouze pro vývojové účely (spouštění testů, statické analýzy, benchmarků). Pro použití knihovny jako závislosti ve vašem projektu není potřeba.

Spuštění (Docker)

Projekt používá předpřipravený Docker image (ghcr.io/vondrasoft/php-xdebug:8.4) s PHP 8.4 + Xdebug + Composer, takže není potřeba nic buildovat lokálně. Dockerfile je ponechán v repozitáři pro nahlédnutí.

API

Typová bezpečnost

Seznam zamkne svůj typ při prvním vložení prvku. Pokus o vložení jiného typu vyhodí InvalidTypeException:

Po odebrání všech prvků se zámek uvolní a seznam je možné použít s jiným typem.

Řazení řetězců

Řetězce jsou řazeny pomocí nativního PHP operátoru <, který provádí lexikografické (byte-by-byte) porovnání. To funguje správně pro ASCII/anglické řetězce. Pro locale-aware řazení (např. čeština, němčina) by bylo potřeba použít Collator z rozšíření intl — to je záměrně mimo rozsah této generické datové struktury.

Struktura projektu

Pokrytí kódu testy

Třída Metody Řádky
InvalidTypeException 100.00% (1/1) 100.00% (7/7)
Node 100.00% (2/2) 100.00% (4/4)
SortedLinkedList 100.00% (12/12) 100.00% (104/104)
ValueType 100.00% (1/1) 100.00% (3/3)
Celkem 100.00% (16/16) 100.00% (118/118)

Nástroje pro kvalitu

Nástroj Úroveň Příkaz
PHPUnit 69 testů, 107 assertions composer test / composer test-coverage
PHPStan Level 9 + strict rules (phpstan-strict-rules, shipmonk/phpstan-rules) composer analyze
PHPCS ShipMonk Coding Standard composer cs

Benchmarky

Poznámka: Předbuilděný Docker image je postaven pro arm64 (Apple Silicon / Mac). Níže uvedené výsledky benchmarků odpovídají této architektuře. Při spuštění na amd64 (např. Linux servery) může být výkon výrazně nižší kvůli QEMU emulaci — Docker za běhu transparentně překládá arm64 instrukce na amd64, což přidává značný overhead. Pro přesné benchmarky na amd64 je potřeba image přebuildit nativně (docker build --platform linux/amd64).

Spuštění: docker compose exec php composer benchmark. Měří výkon v různých scénářích:

Velikost Čas
100 prvků 2,64 ms
500 prvků 2,12 ms
1 000 prvků 7,10 ms
5 000 prvků 162,02 ms
10 000 prvků 640,19 ms
Velikost Čas
100 prvků 0,26 ms
500 prvků 3,34 ms
1 000 prvků 11,44 ms
5 000 prvků 261,77 ms
10 000 prvků 1 098,61 ms
Velikost Seřazený Obrácený
100 prvků 0,10 ms 0,11 ms
500 prvků 0,47 ms 0,45 ms
1 000 prvků 0,86 ms 0,82 ms
5 000 prvků 4,07 ms 4,03 ms
10 000 prvků 8,23 ms 7,90 ms
Velikost Čas
100 prvků 0,07 ms
500 prvků 0,22 ms
1 000 prvků 0,46 ms
5 000 prvků 2,18 ms
10 000 prvků 4,45 ms
Velikost toArray() foreach
100 prvků 0,01 ms 0,03 ms
500 prvků 0,03 ms 0,10 ms
1 000 prvků 0,05 ms 0,20 ms
5 000 prvků 0,24 ms 0,81 ms
10 000 prvků 0,48 ms 1,63 ms

Prostřední prvek (contains):

Velikost while foreach in_array
100 prvků 2,35 ms 7,75 ms 0,31 ms
500 prvků 9,67 ms 38,10 ms 0,48 ms
1 000 prvků 18,99 ms 76,67 ms 0,71 ms
5 000 prvků 92,94 ms 372,95 ms 2,29 ms
10 000 prvků 186,13 ms 756,94 ms 4,38 ms

Poslední prvek:

Velikost tail O(1) while foreach end()
100 prvků 0,25 ms 2,29 ms 16,09 ms 0,23 ms
500 prvků 0,26 ms 9,44 ms 78,43 ms 0,23 ms
1 000 prvků 0,25 ms 18,38 ms 156,64 ms 0,24 ms
5 000 prvků 0,25 ms 86,98 ms 766,63 ms 0,25 ms
10 000 prvků 0,26 ms 174,49 ms 1 523,88 ms 0,23 ms

1 000 volání na scénář.

Velikost LinkedList array poměr
100 prvků 7,9 KB 2,6 KB 3,1x
500 prvků 39,2 KB 12,1 KB 3,2x
1 000 prvků 78,2 KB 20,1 KB 3,9x
5 000 prvků 390,7 KB 132,1 KB 3,0x
10 000 prvků 909,4 KB 260,1 KB 3,5x

All versions of sorted-linked-list with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vondrasoft/sorted-linked-list contains the following files

Loading the files please wait ...