Fast set membership check ?

R

Richard

I need to determine if a given number or string is in a set of
numbers or strings. The standard hack I'd do is make a search tree,
but in this particular application I'm going to be doing a boatload
of these comparisons over and over and over, and I just checking to
see if there's not some smarter way to go about it.

Discussion, links, etc. appreciated.
 
L

Les Cargill

Richard said:
I need to determine if a given number or string is in a set of
numbers or strings. The standard hack I'd do is make a search tree,
but in this particular application I'm going to be doing a boatload
of these comparisons over and over and over, and I just checking to
see if there's not some smarter way to go about it.

Discussion, links, etc. appreciated.

I'd use the file "hash.c" that comes with the Tcl source code. Email me
if you wannit attached to an email.
 
S

Sidney Cadot

Richard said:
I need to determine if a given number or string is in a set of
numbers or strings. The standard hack I'd do is make a search tree,
but in this particular application I'm going to be doing a boatload
of these comparisons over and over and over, and I just checking to
see if there's not some smarter way to go about it.

Discussion, links, etc. appreciated.

You might want to take a look at libjudy: http://judy.sourceforge.net

Best regards,

Sidney
 
R

Richard

(e-mail address removed) wrote...
And a whole lot less intensive than the Tcl hash functions...

I pulled down hash.c, then judy, and thought the same thing. The
reduction in cache line fills is just the kind of performance
improvement I was hoping to find.

(Thanks for hash.c, Les.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,077
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top