angle/tree

Basic binary tree implementation in PHP.

v1.0.0 2019-03-10 15:01 UTC

This package is auto-updated.

Last update: 2024-04-11 13:45:51 UTC


README

Simple binary tree implementation in PHP.

Installation

composer require angle/tree

Usage

Creating a tree:

use Angle\Tree\Leaf;

$tree = new Leaf(10);
$tree->insert(5);
$tree->insert(15);
$tree->insert(8);

Check for values within the tree:

$tree->contains(5); // true
$tree->contains(42); // false

Climb the tree:

$tree->left->right->data == 8; // true

Contributing

Improvements are welcome! Feel free to submit pull requests.

Licence

MIT

Copyright © 2019 Angle Software