crimson-nynja / php-trees
PHP 实现的各种树的实现
0.6.0
2021-12-28 08:03 UTC
Requires
- php: >=8.1.0
Requires (Dev)
- phpunit/phpunit: ^9
README
该仓库旨在以易于使用的方式提供所有常用的树
当前包括二叉搜索树、Rope、二叉堆和泛型树的实现,更多功能即将推出!
所有测试均用 PHP 单元测试编写,所有代码均遵循 PSR-4 标准。Php Trees 还需要 PHP 8.1.0 或更高版本,并利用 PHP 的所有现代特性。
可以通过 composer 安装 Php Trees
composer require crimson-nynja/php-trees
https://packagist.org.cn/packages/crimson-nynja/php-trees
使用方法
要使用二叉搜索树,包含正确的文件并创建如下
use PhpTrees\BinarySearchTree; $b = new BinarySearchTree(rootValue: 5); // This will create a binary search tree with a root of the value 5
要使用 Rope
use PhpTrees\Rope; $r = new Rope(string: "This is a Rope!"); // This will create a Rope with the initial string, "This is a Rope!"
要使用二叉堆
use PhpTrees\BinaryHeap; $h = new BinaryHeap(); // This will create an empty binary heap
要使用泛型树
use PhpTrees\GenericTree; $g = new GenericTree(rootValue: 4.1); // This will create a generic tree with root 4.1
有关 Php Trees 功能的更详细描述,请查看 wiki
https://github.com/CrimsonNynja/PHP-Trees/wiki
即将推出
树平衡选项
2-3 树
B 树
搜索/遍历类型(深度优先搜索、广度优先搜索等)