NAME

List::Range::Search::Binary - binary search for the ranges

SYNOPSIS

use List::Range;
use List::Range::Set;
use List::Range::Search::Binary;

my $seeker = List::Range::Search::Binary->new(
    List::Range::Set->new('MySet' => [
        List::Range->new(name => "A",              upper =>  0),
        List::Range->new(name => "B", lower =>  1, upper => 10),
        List::Range->new(name => "C", lower => 11, upper => 20),
        List::Range->new(name => "D", lower => 21, upper => 30),
        List::Range->new(name => "E", lower => 31, upper => 40),
        List::Range->new(name => "F", lower => 41, upper => 50),
    ])
);

$seeker->find(0);  # => List::Range<name="A">
$seeker->find(1);  # => List::Range<name="B">
$seeker->find(11); # => List::Range<name="C">
$seeker->find(31); # => List::Range<name="E">
$seeker->find(50); # => List::Range<name="F">
$seeker->find(51); # => undef

DESCRIPTION

List::Range::Search::Binary search value from a set by binary search algorithm.

METHODS

List::Range::Search::Binary->new($set)

Create a new List::Range::Set object.

$seeker->find($value)

Find the range included the $value from the set.

SEE ALSO

List::Range List::Range::Set List::Range::Search::Liner

LICENSE

Copyright (C) karupanerura.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

karupanerura <karupa@cpan.org>