|
NAMEMath::IntervalSearch - Search where an element lies in a list of sorted elements SYNOPSIS use Math::IntervalSearch qw(interval_search);
my @array = (1..5);
my $location = interval_search(2.4, \@array);
# Use your own comparison operators.
sub ReverseLessThan {
$_[0] < $_[1];
}
sub ReverseLessThanEqualTo {
$_[0] <= $_[1];
}
$location = interval_search(2.4,
\@array,
\&ReverseLessThan,
\&ReverseLessThanEqualTo);
DESCRIPTIONThis subroutine is used to locate a position in an array of values where a given value would fit. It has been designed to be efficient in the common situation that it is called repeatedly. The user can supply a different set of comparison operators to replace the standard < and <=. SUBROUTINES
AUTHORBlair Zajac <blair@orcaware.com>. COPYRIGHTCopyright (C) 1998-2005 Blair Zajac. All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself. POD ERRORSHey! The above document had some coding errors, which are explained below:
|