PHP code example of matejicekvojtech / sorted-linked-list

1. Go to this page and download the library: Download matejicekvojtech/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/ */

    

matejicekvojtech / sorted-linked-list example snippets


use VM\LinkedList\Model\SortedList
/* ... */
$list = new SortedList();
// empty list

$list->add(123);
// list: 123

$list->add(111);
// list: 111 -> 123

$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
//      }
//  }

$list->remove(5);
// list: 111 -> 123 (not found)

$list->remove(111);
// list: 123