PHP Classes

Binary search: Search for data in files using binary search

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 59%Total: 2,887 All time: 1,301 This week: 62Up
Version License PHP version Categories
binary_search 1.0Artistic License5.0Algorithms, PHP 5, Files and Folders, S...
Description 

Author

This class can be used to quickly search for sorted data in large files using the binary search algorithm.

It can search for a given identifier in a file that has lines that contain only the identifier and a value separated by a tab character.

The class uses the binary search algorithm to quickly narrow the search for a given identifier even when the files are very large.

Innovation Award
PHP Programming Innovation award winner
September 2008
Winner


Prize: One book of choice by Apress
Sometimes it is necessary to search a large amount of data for given information.

One way to reduce the time that is necessary to search the data is to store it in a file sorted by the key search values. Then we can used the binary search algorithm to quickly find the data in the file without having to load it all at once in memory.

This class implements the binary search algorithm in pure PHP code.

Manuel Lemos
Picture of Alex Fourth
Name: Alex Fourth is available for providing paid consulting. Contact Alex Fourth .
Classes: 1 package by
Country: Ukraine Ukraine
Age: 42
All time rank: 111319 in Ukraine Ukraine
Week rank: 170 Up3 in Ukraine Ukraine Up
Innovation award
Innovation award
Nominee: 1x

Winner: 1x

  Files folder image Files (3)  
File Role Description
Plain text file binary_search.class.php Class Does all work
Accessible without login Plain text file test.php Example Example how to use the class
Accessible without login Plain text file data.csv Data Example data to search in

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,887
This week:0
All time:1,301
This week:62Up
User Ratings User Comments (1)
 All time
Utility:85%StarStarStarStarStar
Consistency:82%StarStarStarStarStar
Documentation:-
Examples:89%StarStarStarStarStar
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:1245
 
Nice work and very well coded.
16 years ago (David Ferreira)
70%StarStarStarStar