Download the PHP package dan-on/php-interval-tree without Composer
On this page you can find all versions of the php package dan-on/php-interval-tree. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dan-on/php-interval-tree
More information about dan-on/php-interval-tree
Files in dan-on/php-interval-tree
Package php-interval-tree
Short Description Is an implementation of interval binary search tree according to Thomas Cormen book "Introduction to Algorithms".
License MIT
Informations about the package php-interval-tree
PHP Interval tree
Overview
Package dan-on/php-interval-tree is an implementation of self balancing binary search tree data structure called Red-Black Tree.
Based on interval tree described in "Introduction to Algorithms 3rd Edition", published by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein.
Complexity
Operation | Best, Average, Worst |
---|---|
Insertion | O(log(n)) |
Search | O(log(n)) |
Remove | O(log(n)) |
Space | O(n) |
Installing via Composer
Usage
Interval Tree
insert(IntervalInterface $interval, mixed $value): void
Insert new pair (interval + value) into interval tree
findIntersections(IntervalInterface $interval): Iterator\
Find pairs which intervals intersect with given interval
hasIntersection(IntervalInterface $interval): bool
Returns true if interval has at least one intersection in tree
countIntersections(IntervalInterface $interval): int
Count intersections given interval in tree
remove(IntervalInterface $interval, $value): bool
Remove node from tree by interval and value
exist(IntervalInterface $interval, $value): bool
Returns true if interval and value exist in the tree
isEmpty(): bool
Returns true if tree is empty
getSize(): int
Get number of items stored in the interval tree
Intervals
There are numeric and DateTimeInterface-based interval types included.