PHPackages                             sergiobelya/data-structures - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sergiobelya/data-structures

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sergiobelya/data-structures
===========================

PHP library for data structures like Sorted Linked List

1.0.0(4mo ago)01MITPHPPHP ^8.3

Since Jan 7Pushed 4mo agoCompare

[ Source](https://github.com/sergiobelya/php-data-structures)[ Packagist](https://packagist.org/packages/sergiobelya/data-structures)[ RSS](/packages/sergiobelya-data-structures/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

sergiobelya/data-structures
===========================

[](#sergiobelyadata-structures)

PHP library for data structures like Sorted Linked List

Installation
------------

[](#installation)

```
composer require sergiobelya/data-structures
```

Sorted Linked List
------------------

[](#sorted-linked-list)

The data structure that consists of elements, each containing a link to the next element, and all elements are always kept sorted. One instance of SortedLinkedList contains `int` or `string` values but not both.

### Available actions

[](#available-actions)

- add
- delete
- shift
- pop
- isValueExists
- count
- reverse
- toArray
- iterate

### Usages

[](#usages)

Notice: each `$value` used for one instance of `SortedLinkedList` should be `int` or `string` but not both, otherwise `\InvalidArgumentException` will be thrown.

#### Add

[](#add)

```
use Sergiobelya\DataStructures\SortedLinkedList;

// 1 example
$list = new SortedLinkedList();
while ($value = /* some function, e.g. fetch record from DB, read row from file, pop value from array, etc. */) {
    $list->add($value);
}

// 2 example
$sortedListInt = new SortedLinkedList();
$sortedListInt->add(5);
$sortedListInt->add(15);
$sortedListInt->add(10);

// 3 example
$sortedListString = new SortedLinkedList();
$sortedListString->add('USA');
$sortedListString->add('Canada');
$sortedListString->add('Mexico');
```

#### Delete

[](#delete)

```
// Delete value from SortedLinkedList
$sortedListInt->delete(10);

// Delete value from SortedLinkedList
$sortedListString->delete('Mexico');
```

#### Shift &amp; Pop

[](#shift--pop)

```
$firstValue = $list->shift();
$lastValue = $list->pop();
```

#### Is Value Exists

[](#is-value-exists)

```
if ($list->isValueExists('USA')) {
    // do something
}
```

#### Count

[](#count)

```
$countItems = $list->count();
// or
$countItems = count($list);
```

#### Reverse

[](#reverse)

```
// 1st option - call reverse() before add()
$sortedList = new SortedLinkedList();
$sortedList->reverse();
foreach ($originalData as $value) {
    // add values in descending order
    $sortedList->add($value);
}

// 2nd option - call reverse() after add()
$sortedList = new SortedLinkedList();
foreach ($originalData as $value) {
    // add values in ascending order
    $sortedList->add($value);
}
// reverse all values in descending order
$sortedList->reverse();
```

#### To Array

[](#to-array)

```
$data = $list->toArray();
```

#### Iterations

[](#iterations)

```
foreach ($list as $value) {
    // do something
}
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance76

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

131d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2e0714a25088eac1e505cf58ad854ea4166312fe68f9006f4d1cf5c1e53e4c30?d=identicon)[sergiobelya](/maintainers/sergiobelya)

---

Top Contributors

[![sergiobelya](https://avatars.githubusercontent.com/u/6141086?v=4)](https://github.com/sergiobelya "sergiobelya (18 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sergiobelya-data-structures/health.svg)

```
[![Health](https://phpackages.com/badges/sergiobelya-data-structures/health.svg)](https://phpackages.com/packages/sergiobelya-data-structures)
```

###  Alternatives

[zakirullin/mess

Convenient array-related routine &amp; better type casting

21228.9k2](/packages/zakirullin-mess)[clarkwinkelmann/flarum-ext-emojionearea

Add EmojioneArea emoji picker to Flarum

2848.5k2](/packages/clarkwinkelmann-flarum-ext-emojionearea)[dcat-admin-extension/ueditor

百度在线编辑器

205.5k](/packages/dcat-admin-extension-ueditor)[shibuyakosuke/laravel-postalcode-japan

郵便番号データを取り込んで住所マスタを作成します。

105.2k](/packages/shibuyakosuke-laravel-postalcode-japan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
