matejicekvojtech / sorted-linked-list
Sorted linked list library. Test task for ShipMonk
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/matejicekvojtech/sorted-linked-list
Requires
- php: ^8.4
- webmozart/assert: ^1.11
Requires (Dev)
- phpunit/phpunit: ^12.3
This package is not auto-updated.
Last update: 2026-01-03 13:38:38 UTC
README
This library was created as task for ShipMonk recruiting process.
Installation
composer require matejicekvojtech/sorted-linked-list
Usage
This list can hold integer or string values sorted in ascending order. Value types of items in single list cannot mix (all values are either integer or string).
Create list
use VM\LinkedList\Model\SortedList /* ... */ $list = new SortedList(); // empty list
Insert value
$list->add(123); // list: 123 $list->add(111); // list: 111 -> 123
Find value
$item = $list->find(5); // item: null (not found) $item = $list->find(123); // item: SortedListItem {value: 123, next: null} $item = $list->find(111); // item: SortedListItem { // value: 111, // next: SortedListItem { // value: 123, // next: null // } // }
Remove value
$list->remove(5); // list: 111 -> 123 (not found) $list->remove(111); // list: 123