develooper Front page | perl.perl5.porters | Postings from March 2010

Re: Another optimization question: bsearch()

Thread Previous | Thread Next
From:
David Nicol
Date:
March 2, 2010 07:51
Subject:
Re: Another optimization question: bsearch()
Message ID:
934f64a21003020750l427b0f78te85b278b85674fe1@mail.gmail.com
On Mon, Mar 1, 2010 at 12:43 PM, karl williamson
<public@khwilliamson.com> wrote:

> Inversion lists can be searched binarily.  bsearch() is a standard C library
> routine, but the only mention of it in Perl is in the POSIX module where it
> says it is not furnished.  This makes me think there must be a problem with
> using the library routine.  Is there?

the problem is that you need to keep your data sorted, which is not
perly. The perly thing to do is to keep data in a hash table instead
of a sorted array. So not furnishing a perl interface to bsearch a
perl array makes sense, because You Should Be Using A Hash Table Silly
Rabbit.



-- 
Is it the time when there isn't time to discuss but there is time to act yet?

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About