mantisbt/binary-tree
Composer 安装命令:
composer require mantisbt/binary-tree
包简介
binary tree class
README 文档
README
This repository contains a simple and efficient implementation of a binary tree in PHP.
A binary tree is a hierarchical data structure in which each node has at most two children, often referred to as the left and right child. Binary trees are useful for various applications, such as searching, sorting, and organizing data.
Features
- Easy-to-use interface for creating and manipulating binary trees
- Basic tree traversal algorithms
- Insertion and search operations
- Node removal
- Counting the number of nodes in the tree
Installation
To install the Mantis Binary Tree Library, simply grab it from packagist.org using composer:
composer required mantisbt/mantisbt
Usage
Creating a binary tree
To create a new binary tree, instantiate the 'Tree' class:
use MantisBT\Tree;
$tree = new Tree();
Adding values to the tree
To insert values into the truee, use the add method:
$tree->insert(42);
$tree->insert(10);
$tree->insert(60);
Searching for a node in the tree
To search for a value in the tree, use the find method:
$node = $tree->find(61);
if ($node !== null ) {
echo "Value Found: " . $node->value . PHP_EOL;
} else {
echo "Value Not Found " . PHP_EOL;
}
Traversal
The tree can be manually traversed by using:
- getLeft()
- getRight()
- getParent()
Contributing
If you would like to contribute to this project, please feel free to submit a pull request or create an issue to discuss your ideas, or contact us via our website at https://mantisbt.dev
License
This PHP Binary Tree library is released under the MIT License.
Changelog
0.1 - Initial Release 0.2 - Add SetValue command to Node to allow modifications to tree node values 0.3 - Fix bug in Find function
mantisbt/binary-tree 适用场景与选型建议
mantisbt/binary-tree 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 08 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mantisbt/binary-tree 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mantisbt/binary-tree 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2023-08-29