rafayrty / linkedlist-php
This Package allows you to have a Linked List inside Your PHP Project
Fund package maintenance!
rafayrty
Requires
- php: >=7.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- pestphp/pest: ^1.20
This package is auto-updated.
Last update: 2024-05-09 01:38:14 UTC
README
A PHP Package Implementing Linked List, for the cases when it is actually costly to insert an element at the beginning of an array.
Installation
You can install the package via composer:
composer require rafayrty/linkedlist-php
Usage
$list = new Rafayrty\LinkedListPhp\SinglyList(); //Insert a New Node to the LinkedList $list->push(5); // -> returns the linkedlist //Remove the Last Node from the LinkedList $list->pop(); // -> returns value of deleted element //Remove the Initial Node from the LinkedList $list->shift(); // -> returns value of deleted node //Add a Node To Beginning of the LinkedList $list->unshift(5); // -> returns the linkedlist //Get a Node from a specific index $list->get(0); // -> returns the value of the node //Remove a Node from a specific index $list->remove(0); // -> returns the value of the deleted node //Convert Your LinkedList to an array $list->toArray(); // -> returns an array of linkedlist //Delete an Element from a specified index to deleteCount similar to JS array splice $list->splice($starting,$deletecount); // -> returns the linkedlist
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.