Download the PHP package adambenovic/shipmonk-sorted-linked-list without Composer

On this page you can find all versions of the php package adambenovic/shipmonk-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 shipmonk-sorted-linked-list

SortedLinkedList

A type-safe sorted linked list library for PHP 8.4+. Holds either int or string values (never both in the same instance) and maintains ascending order on every insertion.

Requirements

Installation

Quick Start

Once the first value is inserted, the type is locked:

Creating Lists

Typed Convenience Classes

For stricter static analysis, use the type-specific classes directly:

API

Method Description Complexity
insert($value): void Add a value, maintaining sorted order O(n)
remove($value): bool Remove the first occurrence O(n)
contains($value): bool Check if a value exists O(n)
first(): int\|string Get the smallest (first) element O(1)
last(): int\|string Get the largest (last) element O(1)
toArray(): array Get all values as a sorted array O(n)
isEmpty(): bool Check if the list is empty O(1)
clear(): void Remove all elements O(1)
count(): int Get the number of elements O(1)
filter(callable): static Create a new filtered list O(n)
merge(self): static Merge two lists into a new one O(n+m)
getValueType(): ?ValueType Get the detected/declared value type O(1)

Counting and Iteration

All list classes implement Countable, IteratorAggregate, JsonSerializable, and Stringable:

Filtering

Merging

Merges two sorted lists of the same type in O(n+m) time:

Duplicates

Duplicate values are allowed. remove() removes only the first occurrence:

String Sorting

StringSortedLinkedList and SortedLinkedList (when holding strings) use byte-level comparison (strcmp), which follows UTF-8 byte order rather than locale-aware collation. This means:

If you need locale-sensitive ordering, consider using PHP's intl extension (Collator class).

Exceptions

Exception Parent When
TypeMismatchException \InvalidArgumentException Inserting a value of the wrong type
EmptyListException \UnderflowException Calling first() or last() on an empty list
\InvalidArgumentException -- Merging two lists of different types

Architecture

The library uses the Template Method pattern:

Development

License

MIT


All versions of shipmonk-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 adambenovic/shipmonk-sorted-linked-list contains the following files

Loading the files please wait ...