kariricode/data-structure
Composer 安装命令:
composer require 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.
关键字:
README 文档
README
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
- 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
To install the KaririCode DataStructure component, use the following command:
composer require kariricode/data-structure
Basic Usage
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
use KaririCode\DataStructure\Collection\LinkedList; $linkedList = new LinkedList(); $linkedList->add("First"); $linkedList->add("Second"); $linkedList->remove("First");
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
use KaririCode\DataStructure\Map\HashMap; $map = new HashMap(); $map->put("key1", "value1"); echo $map->get("key1"); // Outputs: value1
TreeSet Example
use KaririCode\DataStructure\Set\TreeSet; $set = new TreeSet(); $set->add("value1"); $set->add("value2"); echo $set->contains("value1"); // Outputs: true
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
use KaririCode\DataStructure\Queue\ArrayDeque; $deque = new ArrayDeque(); $deque->addFirst("First"); $deque->addLast("Last"); echo $deque->peekLast(); // Outputs: Last $deque->removeLast(); // Removes "Last"
Testing
To run tests for the KaririCode DataStructure component, execute the following command:
make test
License
This project is licensed under the MIT License. See the LICENSE file for details.
Support and Community
- Documentation: https://kariricode.org
- Issue Tracker: GitHub Issues
- Community: KaririCode Club Community
- Professional Support: For enterprise-level support, contact us at support@kariricode.org
Built with ❤️ by the KaririCode team. Maintained by Walmir Silva - walmir.silva@kariricode.org
kariricode/data-structure 适用场景与选型建议
kariricode/data-structure 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.09k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 09 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「collections」 「queue」 「php」 「OOP」 「set」 「data structures」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kariricode/data-structure 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kariricode/data-structure 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kariricode/data-structure 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP AMQP Binding Library
A Laravel package to monitor queue jobs.
This package provides type-safe extension of the laravel collection, forcing a single type of object.
Doctrine Collections adapter for Rekapager pagination library
Library to mimics generic collections
The helpers allows you to easy use DATE. Change format, add/sub day, diff date, get quarter - all this is available in this library.
统计信息
- 总下载量: 1.09k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 33
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-26