Re: search algorithm

fenwayfool said:

I need to create a database that has a fairly long key. Consider
the key a bitstring. My problem is that this key also has an
associated mask. All bits that we "care" about in the key have a
mask value of '1' while the don't care bits are marked with a


For example let's assume the key/mask is 32 bits. If I have the
following in my database:

key: 0xA0A000001

(I'm guessing this was supposed to be 0xA0A00001)

mask: 0xFFFF000F

Should match a key such as 0xA0A00007 (the lookup does not specify
a key).

Here's your example in binary:

key: 1010 1010 0000 0000 0000 0000 0000 0001
mask: 1111 1111 1111 1111 0000 0000 0000 1111

I'm guessing that you mean by this that any match for the search key
must look like this:

1010 1010 0000 0000 xxxx xxxx xxxx 0001

where x indicates "any bit value will do for this position".

But your indicated match has the pattern

1010 1010 0000 0000 0000 0000 0000 0111

which does NOT match the required bit pattern (two mandatory bits
are different).

So I'm puzzled as to whether I have understood your requirements

Anyway, this whole question smacks very much of secondary analysis.
"I have a problem X. Ah! I have thought of a solution Y. Oh! I have
a problem Z with solution Y. Hm! How can I solve Z?" whereas
perhaps you ought really to be asking "How can I best solve X?"

Richard Heathfield <>
Email: -http://www. +rjh@
Google users: <>
"Usenet is a strange place" - dmr 29 July 1999

Relevant Pages

  • Re: Killfile
    ... This filter filters by keywords in the subject line in any newsgroup. ... I don't care about any of the other matching options I could choose. ... These particular keywords are from newsgroup subject lines that were bugging me in the past. ... News pattern = ...
  • Re: Public School was a waste of my time (Re: When even a Republican can see it....)
    ... If such evidence appeared, what are the consequences? ... The argument pattern is not one that I ... particularly care to play with. ... Opting out by announcing that the other person is ...
  • Re: Hospital or night gowns
    ... pattern so I can make a good one. ... sleeping in absolute darkness can help prevent breast cancer. ... under the mask in that area. ...
  • ML-style pattern matching in C-like languages
    ... I am working on a C compiler written in a malleable ... syntax to the language to make writing the compiler ... If I want to pattern match on this, sometimes I might care ...
  • Re: My first Spacecraft
    ... instead of electroplating a gold pattern. ... The lead mask is for the Burst Alert Telescope instrument on the ... find out where the gamma-rays are coming from. ... distance up to over 13 billion light years, from when the Universe was ...