The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

GenOO::Module::Search::Binary - Module that offers methods for searching in an array using binary search

SYNOPSIS

    use GenOO::Module::Search::Binary
    my $pos = GenOO::Module::Search::Binary->binary_search_for_value_greater_or_equal(3.2, [0,1,2,3,4,4,4,5,6], sub {return $_[0]});

DESCRIPTION

    Implements binary search algorithms for scanning an array.
    

binary_search_for_value_greater_or_equal Arg [1] : number. The target value Arg [2] : array reference. Array in which the target value is searched. No assumption is made about the entries in the array and how to extract the actual values from them. The array must be sorted by value though. Arg [3] : code reference. Code that extracts the actual value given an entry of the array Example : binary_search_for_value_greater_or_equal(3.2, [0,1,2,3,4,4,4,5,6], sub {return $_[0]}) Description: Implements a binary search algorithm returning the position of the first entry whose value is greater than or equal to target value. The search routine does not make any assumption about the entries in the array, but leaves the implementation to the user supplied code function. During the search the user supplied code function will be called with a single arguments: an entry of the array and should return the value that corresponds to this entry. Return : Integer index of the first entry whose value is greater or equal to the target value