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

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

Sorted Linked List

A PHP library providing a sorted linked list for typed values. It provides sorted linked lists for integers and strings, with a strategy-based extension point for custom value types.

Requirements

Installation

Install the library with Composer:

Then import the factory class where you need it:

Architecture

Create lists with SortedLinkedListFactory. SortedLinkedList has a public constructor only for factory and extension internals, and that constructor is marked @internal.

Built-in factories configure the strategy for common value types:

Strategies validate values through normalize() and compare normalized values through compare(). Invalid values should be rejected by throwing InvalidValueTypeException.

Usage

Integer Lists

Use descending: true for descending integer order:

String Lists

Use descending: true for descending string order:

Use a locale to sort strings in locale-aware order:

If locale cannot be resolved, LocaleNotInstalledException is thrown.

Custom Strategy Lists

Value Typing

Built-in lists can contain integers or strings, but never both.

Direct construction is marked internal and is not supported for consumers. Use SortedLinkedListFactory::forIntegers() for integer lists, SortedLinkedListFactory::forStrings() for string lists, or SortedLinkedListFactory::usingStrategy() for custom value types.

Lists created with SortedLinkedListFactory::forIntegers() or SortedLinkedListFactory::forStrings() are explicitly typed from the start. They keep that type even when empty or after clear().

valueType() returns the value type string defined by the configured strategy.

Invalid values are rejected with Agrzelec\SortedLinkedList\Exception\InvalidValueTypeException. This applies to factory initialization, insertion, contains(), and remove().

Sorting

Integer lists use numeric ascending order by default.

String lists use lexicographic ascending order by default, using PHP's strcmp() semantics. The default order is case-sensitive, and numeric strings remain strings.

Pass a locale to forStrings() to use locale-aware collation through PHP intl's collator_sort():

Descending locale-aware sorting is also supported:

Locale-aware sorting depends on ICU locales provided by PHP's intl extension. If the configured locale cannot be resolved, LocaleNotInstalledException is thrown.

Custom strategy lists use the ordering returned by the strategy's compare() method.

Duplicates

Duplicate values are allowed. New duplicates are placed after existing equal values, so the insertion order is stable among equal values.

remove() removes one matching value at a time:

API Reference

Operation Complexity

Operation Complexity Notes
insert() O(n) Finds the sorted insertion point.
contains() O(n) Stops early when the current value is greater than the searched value.
remove() O(n) Removes the first matching value and stops early when possible.
first() O(1) Reads the head node.
last() O(1) Reads the tracked tail node.
count() / isEmpty() O(1) Uses tracked list size.
clear() O(1) Drops head and tail references.
toArray() / iteration / JSON serialization O(n) Walks the list in sorted order.

Benchmark

These figures are illustrative, not guarantees. They were measured on a local run with PHP 8.4.6 using integer lists built from deterministic shuffled input. Each value is the median of 3 runs.

Length Build shuffled list contains() last value contains() missing high value toArray()
100 1.432 ms 0.176 ms 0.003 ms 0.043 ms
1,000 23.423 ms 1.744 ms 0.006 ms 0.378 ms
2,500 74.699 ms 5.078 ms 0.008 ms 1.035 ms
5,000 150.381 ms 8.376 ms 0.008 ms 1.970 ms

Shuffled construction was intentionally the expensive case because every inserted value could scan part of the list. Factory construction now sorts the initial values first, so building shuffled input scales much better. Existing insert() calls still use linked-list insertion and remain O(n).

Development

Install dependencies:

Common local commands:

Command Description
composer test Run the PHPUnit test suite.
composer analyse Run PHPStan static analysis.
composer cs Check coding standards with PHP-CS-Fixer.
composer cs:fix Automatically fix coding-standard issues.
composer check Run coding standards, static analysis, and tests.

Versioning

This project follows Semantic Versioning. Release notes are maintained in CHANGELOG.md.


All versions of sorted-linked-list with dependencies

PHP Build Version
Package Version
Requires ext-intl Version *
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 r34117y/sorted-linked-list contains the following files

Loading the files please wait ...