[Bio] / FigKernelPackages / BinarySearch.pm Repository:
ViewVC logotype

Annotation of /FigKernelPackages/BinarySearch.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : overbeek 1.1 # -*- perl -*-
2 :     ########################################################################
3 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
4 :     # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     ########################################################################
18 :    
19 :     package BinarySearch;
20 :    
21 :     sub binary_search {
22 :     my($xL,$x) = @_;
23 :    
24 :     my $l = 0;
25 :     my $h = @$xL - 1;
26 :    
27 :     while ($l < $h)
28 :     {
29 :     $m = int(($l+$h)/2);
30 :     if ($xL->[$m] >= $x)
31 :     {
32 :     $h = $m;
33 :     }
34 :     else
35 :     {
36 :     $l = $m+1;
37 :     }
38 :     }
39 :     return $l;
40 :     }
41 :    
42 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3