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

On this page you can find all versions of the php package studio83/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

studio83/sorted-linked-list

CI Latest Stable Version PHP Version Require License

A small, type-safe sorted singly-linked list for PHP. A single instance holds either int values or string values — never both. The constraint is enforced at the language level by exposing two distinct concrete classes.

Installation

Requires PHP 8.2 or newer.

Usage

Integers

Strings

Empty-list safety

The idiomatic guard is isEmpty():

If pre-checking is awkward (e.g. inside a generic helper), catch the exception:

Catching every library error

API Reference

Method Returns Complexity Notes
__construct(T ...$values) — O(n²) for n inserts Variadic; supports empty initialisation
static fromArray(array $values): self new instance O(n²) Validates element types; throws InvalidValueException
add(T $value): void — O(n) Inserts at sorted position; stable for duplicates
remove(T $value): bool bool O(n) Removes first occurrence; returns whether anything was removed
contains(T $value): bool bool O(n) worst Early exit when sort order overshoots
count(): int int O(1) Maintained as a counter
isEmpty(): bool bool O(1)
clear(): void — O(1)
first(): T T O(1) Throws EmptyListException on empty
last(): T T O(1) Tail pointer maintained
toArray(): array list<T> O(n) Zero-indexed, ascending
getIterator(): Generator Generator O(1) memory Implements IteratorAggregate
jsonSerialize(): array list<T> O(n) Implements JsonSerializable
clone $list new instance O(n) Deep-copies the node chain

T = int for IntSortedLinkedList, string for StringSortedLinkedList.

Design Decisions

Why two concrete classes instead of one generic class

PHP has no language-level generics. Three approaches were considered:

Approach Verdict
Single class with PHPStan @template + runtime check Type errors only at runtime; PHP itself doesn't enforce.
Single class with type-lock on first add Latent bug — error surfaces only on the second wrong-typed add.
Two final concrete classes + abstract parent Chosen. PHP enforces correctness at the language level; idiomatic Symfony pattern.

Stable insertion of duplicates

When inserting a value equal to one already in the list, the new element is placed after existing equals — insertion order is preserved among equals. This matches the standard expectation for a "sorted by key" collection.

Explicit non-goals

Limitations

Development

License

MIT — see LICENSE.


All versions of sorted-linked-list with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
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 studio83/sorted-linked-list contains the following files

Loading the files please wait ...