Skip to content

sykora-ji/sorted-linked-list

Repository files navigation

PHP Composer

PHP library providing SortedLinkedList (linked list that keeps values sorted). SortedLinkedList can hold string or int values, but not both together.

Installation

composer require novak-ji/sorted-linked-list

Usage

<?php

use Novakji\SortedLinkedList\Node\NodeFactory;
use Novakji\SortedLinkedList\SortedLinkedList;

$nodeFactory = new NodeFactory();
$sortedLinkedList = new SortedLinkedList($nodeFactory);

$sortedLinkedList->insertValue('beta'); //beta
$sortedLinkedList->insertValue('alfa'); //alfa -> beta
$sortedLinkedList->insertValue('aaa'); //aaa -> alfa -> beta

$sortedLinkedList->removeValue('alfa'); //aaa -> beta

$sortedLinkedList->hasValue('aaa'); //true
$sortedLinkedList->hasValue('alfa'); //false

SortedLinkedList implementing Iterator and Countable interfaces

<?php
$sortedLinkedList->count(); //int

/** @var string|int $value */
foreach ($sortedLinkedList as $value) {

}

Code Quality

PHP Linter

composer phplint

PHP_CodeSniffer

composer phpcs
composer phpcbf

PHPStan

composer phpstan

PHPUnit - unit tests

composer test-unit

Run all checks

composer check

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages