Skip to content

CrimsonNynja/PHP-Trees

Folders and files

NameName
Last commit message
Last commit date

Latest commit

afa424b · Apr 17, 2022
Dec 28, 2021
Dec 28, 2021
Nov 30, 2020
Dec 28, 2019
Nov 8, 2019
Apr 17, 2022
Dec 20, 2021
Dec 20, 2021
Jan 1, 2021

Repository files navigation

PHP-Trees

GitHub Workflow build status badge Latest Stable Version

This repo is designed to have all common trees used in an easy to use php way

Current included are implementations of a Binary Search Tree, Rope, Binary Heap, and a Generic Tree, with more to come!

All tests are written in PHP Unit, and all code is written in the PSR-4 standards. Php Trees also requires PHP 8.1.0 or above, and utilizes all modern features of PHP.

PHP Trees can be installed through composer with

composer require crimson-nynja/php-trees

https://packagist.org/packages/crimson-nynja/php-trees

Usage

To use the binary search tree, include the correct file and create it as such

use PhpTrees\BinarySearchTree;

$b = new BinarySearchTree(rootValue: 5);
// This will create a binary search tree with a root of the value 5

To use the 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!"

To use the Binary Heap

use PhpTrees\BinaryHeap;

$h = new BinaryHeap();
// This will create an empty binary heap

To use the Generic Tree

use PhpTrees\GenericTree;

$g = new GenericTree(rootValue: 4.1);
// This will create a generic tree with root 4.1

For a more detailed description of the features of PHP Trees, check out the wiki
https://github.com/CrimsonNynja/PHP-Trees/wiki

Coming up

tree balancing options
2-3 tree
B-Tree
search/traversal types (depth first search breadth first search, etc)