Skip to content
Permalink
48f388f94a
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
40 lines (26 sloc) 641 Bytes
package BedTree;
use warnings;
use strict;
use Tree::Interval;
sub new
{
my $class = shift;
my $self = {};
bless ($self, $class);
$self->{tree} = Tree::Interval->new();
return $self;
}
sub run
{
my $self = shift;
my $query = shift;
# insert data to tree
$self->{tree}->insert(1,6, ["cat", 1, 10]);
$self->{tree}->insert(7,10, ["dog", 11, 20]);
# look for position
my $value = $self->{tree}->find($query);
# print result
my $result = defined($value) ? $value : ["<empty>", -1, -1];
print join("\t",@{$result}),"\n";
}
1; # returns true