Coder Profile - Show off your skills, get a coder profile.
 
 
 
The Author
gunni
Send A Message
Rating
Not
Rated
Please login to rate source codes.

Click here to register a free account with us.
General Details
C++
Posted 109 Days Ago
176 Views
Received 0 Ratings
More Codes By This Author
Beatiful Code Contest con...

Beatiful Code Contest contribution: binary search


Description
Searches an ordered (either ASCending or DESCending) list for the occurence of a value and returns the index at which the value was found (-1 otherwise). My implementation works with all types of values and lists I could think of. See Requirements in "Technical".
Technical
g++ does not take default arguments for templates like I'm using them; I haven't checked other compilers.

Requirements:
-the type of the values inside the list must have the following operators (either by nature, like all numeric datatypes, or by operator overloading): greater than (>), less than (<), equals (==)
-the type of the list itself must have the index ([]) operator (either by nature, like generic arrays or by operator overloading, like std::vector and std::map)
-the type of the list indexes must have the following operators (either by nature, like all numeric datatypes or by operator overloading): plus (+), minus (-), division (/) and less than or equal (<=)
Source Code
Comments
Please login to post comments.
Page 1 of 1
More "C++" Source Codes By This Author
Recently Posted "C++" Source Codes
Recently Rated "C++" Source Codes
 
 
Latest News About Coder Profile
Coder Profile Poll
What is the next application you would like to be added to your profiles?

Books
Coding Challenges
Project Management
Blog
Tutorials


please login to cast your vote
and see the results of this poll
Latest Coder Profile Changes
Coder Profile was last updated
5 Days Ago
Official Blog :: Make A Donation :: Credits :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents :: Wallpapers
Version 1.46.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved