forked from greensync/interval-tree
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
= IntervalTree | ||
|
||
Title:: the IntervalTree module using "argumanted tree" | ||
Author:: MISHIMA, Hiroyuki ( https://github.com/misshie ) | ||
Copyright:: The MIT/X11 license | ||
|
||
== see also | ||
*description in Wikipedia http://en.wikipedia.org/wiki/Interval_tree | ||
*an implementstion in Python by Tyler Kahn http://forrst.com/posts/Interval_Tree_implementation_in_python-e0K | ||
|
||
== usage | ||
require "interval_tree" | ||
|
||
itv = [(0...3), (1...4), (3...5),] | ||
t = IntervalTree::Tree.new(itv) | ||
p t.search(2) => [0...3, 1...4] | ||
p t.search(1...3) => [0...3, 1...4, 3...5] | ||
|
||
== note | ||
result intervals are always returned | ||
in the "left-closed and right-open" style that can be expressed | ||
by three-dotted Range object literals (first...last) | ||
|
||
Full-closed intervals "(first..last)" for tree are internally | ||
converted to half-closed intervals. |