Download the PHP package rulinski/sorted-linked-list without Composer
On this page you can find all versions of the php package rulinski/sorted-linked-list. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download rulinski/sorted-linked-list
More information about rulinski/sorted-linked-list
Files in rulinski/sorted-linked-list
Download rulinski/sorted-linked-list
More information about rulinski/sorted-linked-list
Files in rulinski/sorted-linked-list
Vendor rulinski
Package sorted-linked-list
Short Description A type-safe sorted linked list supporting int or string values (not both).
License MIT
Package sorted-linked-list
Short Description A type-safe sorted linked list supporting int or string values (not both).
License MIT
Please rate this library. Is it a good library?
Informations about the package sorted-linked-list
Sorted Linked List
A small, type-safe PHP library implementing a linked list that keeps its elements sorted at all times. A single list instance holds either int or string values — never both — with the type declared explicitly when the list is created.
Requirements
- PHP >= 8.4
Installation
Usage
Design notes
- Type is fixed at construction, not inferred from the first inserted value. This makes the contract explicit at the call site and fails fast on misuse, rather than silently locking in a type based on insertion order.
- Duplicates are allowed. This is a sorted list, not a sorted set.
remove()removes only the first matching occurrence and returns whether anything was removed; call it repeatedly (or in a loop) to remove all matches. first()/last()throwEmptyListExceptionon an empty list rather than returningnull, so callers can't silently mistake "empty" for a valid0/''value.- Ordering is ascending: numeric comparison for
int,strcmpforstring. Custom comparators are intentionally out of scope. - Complexity:
add(),remove(),contains()are O(n) (list traversal to find the sorted position / matching node).first()/isEmpty()/count()are O(1).last()is O(n) (singly linked, no tail pointer). - Implements
Countable,IteratorAggregate, andStringableso it behaves like a native PHP collection (count(),foreach, string casting all work as expected).
Testing
Author
Vitali Rulinski
All versions of sorted-linked-list with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.4
The package rulinski/sorted-linked-list contains the following files
Loading the files please wait ...