Algorithm-MedianSelect-XS
view release on metacpan or search on metacpan
lib/Algorithm/MedianSelect/XS.pm view on Meta::CPAN
$algorithm ||= 'quick';
}
no strict 'refs';
${__PACKAGE__.'::ALGORITHM'} = $valid_alg{$algorithm};
if (ref $nums[0] eq 'ARRAY') { return xs_median($nums[0]) }
else { return xs_median(@nums) }
}
1;
__END__
=head1 NAME
Algorithm::MedianSelect::XS - Median finding algorithm
=head1 SYNOPSIS
use Algorithm::MedianSelect::XS qw(median);
@numbers = (21, 6, 2, 9, 5, 1, 14, 7, 12, 3, 19);
print median(@numbers);
print median(\@numbers);
print median(\@numbers, { algorithm => 'bubble' }); # slow algorithm
print median(\@numbers, { algorithm => 'quick' }); # default algorithm
=head1 DESCRIPTION
C<Algorithm::MedianSelect::XS> finds the item which is smaller
than half of the integers and bigger than half of the integers.
=head1 FUNCTIONS
=head2 median
Takes a list or reference to an array of integers and returns the median number.
Optionally, the algorithm being used for computation may be specified within
a hash reference. See SYNOPSIS for algorithms currently available.
=head1 EXPORT
C<median()> is exportable.
=head1 SEE ALSO
L<http://www.cs.sunysb.edu/~algorith/files/median.shtml>
=head1 AUTHOR
Steven Schubiger <schubiger@cpan.org>
=head1 LICENSE
This program is free software; you may redistribute it and/or
modify it under the same terms as Perl itself.
See L<http://dev.perl.org/licenses/>
=cut
( run in 1.210 second using v1.01-cache-2.11-cpan-df04353d9ac )