Valid HTML 4.0! Valid CSS!

rangefind.pl - Output

Beispiel-Suchbaum für die Suche in 10 Intervallen

Zurück zum Artikel | Back to the article

 sub unrolled_binsearch {                                           
   my $num = shift;                                                 
                                                                    
   if( 40 <= $num && $num <= 44 ){                                  
     return( 4 );                                                   
   } else {                                                         
     if( 40 > $num ){                                               
       if( 10 <= $num && $num <= 14 ){                              
         return( 1 );                                               
       } else {                                                     
         if( 10 > $num ){                                           
           if( 0 <= $num && $num <= 4 ){                            
             return( 0 );                                           
           } else {                                                 
             return( -1 );                                          
           }                                                        
         } else {                                                   
           if( 20 <= $num && $num <= 24 ){                          
             return( 2 );                                           
           } else {                                                 
             if( 20 > $num ){                                       
                 return -1;                                         
             } else {                                               
               if( 30 <= $num && $num <= 34 ){                      
                 return( 3 );                                       
               } else {                                             
                 return( -1 );                                      
               }                                                    
             }                                                      
           }                                                        
         }                                                          
       }                                                            
     } else {                                                       
       if( 70 <= $num && $num <= 74 ){                              
         return( 7 );                                               
       } else {                                                     
         if( 70 > $num ){                                           
           if( 50 <= $num && $num <= 54 ){                          
             return( 5 );                                           
           } else {                                                 
             if( 50 > $num ){                                       
                 return -1;                                         
             } else {                                               
               if( 60 <= $num && $num <= 64 ){                      
                 return( 6 );                                       
               } else {                                             
                 return( -1 );                                      
               }                                                    
             }                                                      
           }                                                        
         } else {                                                   
           if( 80 <= $num && $num <= 84 ){                          
             return( 8 );                                           
           } else {                                                 
             if( 80 > $num ){                                       
                 return -1;                                         
             } else {                                               
               if( 90 <= $num && $num <= 94 ){                      
                 return( 9 );                                       
               } else {                                             
                 return( -1 );                                      
               }                                                    
             }                                                      
           }                                                        
         }                                                          
       }                                                            
     }                                                              
   }                                                                
 }                                                                  

Zurück zum Artikel | Back to the article

 


Auswege: Impressum, Haftungsausschluß, Datenschutz, thb's Perl-Ecke, meine Homepage.
Links: Imprint, thb's Perl Corner, my homepage.


Thomas Bätzler, Thomas@Baetzler.de
$Id$