PHPackages                             kariricode/data-structure - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. kariricode/data-structure

ActiveLibrary[Queues &amp; Workers](/categories/queues)

kariricode/data-structure
=========================

The KaririCode DataStructure component offers advanced PHP data structures, including lists, stacks, queues, maps, and sets. It features efficient, strongly-typed, object-oriented implementations like ArrayList, LinkedList, BinaryHeap, and TreeMap.

v1.1.3(9mo ago)11.1k1MITPHPPHP ^8.3CI passing

Since Sep 26Pushed 9mo agoCompare

[ Source](https://github.com/KaririCode-Framework/kariricode-data-structure)[ Packagist](https://packagist.org/packages/kariricode/data-structure)[ Docs](https://kariricode.org/)[ RSS](/packages/kariricode-data-structure/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (8)Versions (8)Used By (1)

KaririCode Framework: Data Structure Component
==============================================

[](#kariricode-framework-data-structure-component)

[![en](https://camo.githubusercontent.com/9687410941adb91c2f673c9d50ef38544f3e9a38a6b9f9367cac918a8d3e2a41/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c616e672d656e2d7265642e737667)](README.md)[![pt-br](https://camo.githubusercontent.com/03443f2a7a42ea03f0747d7bb784c5e42ee3f2c09e27bab66436a5021cc05c0c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c616e672d70742d2d62722d677265656e2e737667)](README.pt-br.md)

[![PHP](https://camo.githubusercontent.com/d282cc3193faee11ee32307d0c4c9d809e8fafa4b3a8c12c6afbf35d4f7ec617/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d3737374242343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/d282cc3193faee11ee32307d0c4c9d809e8fafa4b3a8c12c6afbf35d4f7ec617/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d3737374242343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![Composer](https://camo.githubusercontent.com/167fde758f22b49b6cc9441209ab62a654ea9b422f34b21f6130a1e29aaeeaab/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6d706f7365722d3838353633303f7374796c653d666f722d7468652d6261646765266c6f676f3d636f6d706f736572266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/167fde758f22b49b6cc9441209ab62a654ea9b422f34b21f6130a1e29aaeeaab/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6d706f7365722d3838353633303f7374796c653d666f722d7468652d6261646765266c6f676f3d636f6d706f736572266c6f676f436f6c6f723d7768697465)[![Data Structures](https://camo.githubusercontent.com/836f0785fea3452928520b6cb37c76610b813999919ff9f14db6f03bfef528cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446174615f537472756374757265732d4537344333433f7374796c653d666f722d7468652d6261646765266c6f676f3d646174612d73747275637475726573266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/836f0785fea3452928520b6cb37c76610b813999919ff9f14db6f03bfef528cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446174615f537472756374757265732d4537344333433f7374796c653d666f722d7468652d6261646765266c6f676f3d646174612d73747275637475726573266c6f676f436f6c6f723d7768697465)

The **KaririCode Data Structure** component provides a collection of advanced data structures implemented in PHP, designed with strong typing and object-oriented principles. It includes implementations for various common structures like dynamic arrays, linked lists, heaps, queues, maps, sets, and stacks.

Features
--------

[](#features)

- **ArrayList**: A dynamic array providing fast access and amortized O(1) complexity for adding elements.
- **LinkedList**: A doubly linked list with O(1) insertion and removal at both ends, and O(n) for arbitrary index access.
- **BinaryHeap**: A binary heap (min-heap or max-heap) with O(log n) for insertions, removals, and polling.
- **HashMap**: A hash-based map providing average O(1) complexity for put, get, and remove operations.
- **TreeMap**: A self-balancing red-black tree map with O(log n) time complexity for put, get, and remove operations.
- **TreeSet**: A set implementation backed by `TreeMap`, ensuring elements are stored in a sorted order.
- **ArrayDeque**: A double-ended queue using a circular array with amortized O(1) operations at both ends.
- **ArrayStack**: A stack implemented using a dynamic array, providing O(1) complexity for push, pop, and peek operations.

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

[](#installation)

To install the **KaririCode DataStructure** component, use the following command:

```
composer require kariricode/data-structure
```

Basic Usage
-----------

[](#basic-usage)

### ArrayList Example

[](#arraylist-example)

```
use KaririCode\DataStructure\Collection\ArrayList;

$list = new ArrayList();
$list->add("Item 1");
$list->add("Item 2");
echo $list->get(0); // Outputs: Item 1
```

### LinkedList Example

[](#linkedlist-example)

```
use KaririCode\DataStructure\Collection\LinkedList;

$linkedList = new LinkedList();
$linkedList->add("First");
$linkedList->add("Second");
$linkedList->remove("First");
```

### BinaryHeap Example

[](#binaryheap-example)

```
use KaririCode\DataStructure\Heap\BinaryHeap;

$heap = new BinaryHeap();
$heap->add(10);
$heap->add(5);
$heap->add(20);
echo $heap->poll(); // Outputs: 5 (min-heap by default)
```

### HashMap Example

[](#hashmap-example)

```
use KaririCode\DataStructure\Map\HashMap;

$map = new HashMap();
$map->put("key1", "value1");
echo $map->get("key1"); // Outputs: value1
```

### TreeSet Example

[](#treeset-example)

```
use KaririCode\DataStructure\Set\TreeSet;

$set = new TreeSet();
$set->add("value1");
$set->add("value2");
echo $set->contains("value1"); // Outputs: true
```

### ArrayStack Example

[](#arraystack-example)

```
use KaririCode\DataStructure\Stack\ArrayStack;

$stack = new ArrayStack();
$stack->push("First");
$stack->push("Second");
echo $stack->peek(); // Outputs: Second
$stack->pop();       // Removes "Second"
```

### ArrayDeque Example

[](#arraydeque-example)

```
use KaririCode\DataStructure\Queue\ArrayDeque;

$deque = new ArrayDeque();
$deque->addFirst("First");
$deque->addLast("Last");
echo $deque->peekLast(); // Outputs: Last
$deque->removeLast();    // Removes "Last"
```

Testing
-------

[](#testing)

To run tests for the **KaririCode DataStructure** component, execute the following command:

```
make test
```

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

Support and Community
---------------------

[](#support-and-community)

- **Documentation**:
- **Issue Tracker**: [GitHub Issues](https://github.com/KaririCode-Framework/kariricode-datastructure/issues)
- **Community**: [KaririCode Club Community](https://kariricode.club)
- **Professional Support**: For enterprise-level support, contact us at

---

Built with ❤️ by the KaririCode team. Maintained by Walmir Silva -

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance56

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

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

Every ~61 days

Recently: every ~76 days

Total

6

Last Release

291d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e42da33070ae9e744b18f4be67303b8935f6e14488a88328e7c121d909b4f2db?d=identicon)[growthcodeoficial](/maintainers/growthcodeoficial)

---

Top Contributors

[![walmir-silva](https://avatars.githubusercontent.com/u/142913591?v=4)](https://github.com/walmir-silva "walmir-silva (39 commits)")

---

Tags

algorithmsarraylistbinaryheapcollectionsframeworkframework-phphashmapkariricodelinkedlistphpphp-data-structuresqueuestacktreemapphpqueuestacksetcollectionsdata structuresheapbinary heapdynamic arrayOOPtreemaparraylistalgorithmsstrong typingLinkedListKaririCodered-black tree

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kariricode-data-structure/health.svg)

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

###  Alternatives

[ramsey/collection

A PHP library for representing and manipulating collections.

1.2k486.0M69](/packages/ramsey-collection)[phootwork/collection

The phootwork library fills gaps in the php language and provides better solutions than the existing ones php offers.

3924.8M15](/packages/phootwork-collection)[microsoft/azure-storage-queue

This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Queue APIs.

142.6M17](/packages/microsoft-azure-storage-queue)

PHPackages © 2026

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