PHP code example of mf-miko / sorted-linked-list

1. Go to this page and download the library: Download mf-miko/sorted-linked-list library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mf-miko / sorted-linked-list example snippets


use Miko\SortedLinkedList\SortedLinkedList;

$list = new SortedLinkedList();
$list->insert(10);
$list->insert(5);
$list->insert(20);

print_r($list->toArray()); // [5, 10, 20]

$list->delete(10);
print_r($list->toArray()); // [5, 20]

echo $list->exists(5); // true

$list->clear();

$list = new SortedLinkedList();
$list->insert("apple");     // OK
$list->insert("banana");    // OK
$list->insert(42);          // ❌ InvalidArgumentException