search algorithm

Discussion in 'C++' started by fenwayfool, Jan 6, 2009.

  1. fenwayfool

    fenwayfool Guest

    Anyone ever do something similar to the following in C++?

    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 zero.

    Basically I want to simulate the operation of a ternary CAM in
    software in a semi efficient manner. I have a few other databases I
    use a hash_map<> for which works just fine... but the introduction of
    a "don't care" mask eliminates this as a possibility.

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

    key: 0xA0A000001
    mask: 0xFFFF000F

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

    A search solution that returns more than 1 match is possible....
    similar to a partial match for a string.

    Anyway... anyone ever do anthing similar and if so what was your
    solution?
     
    fenwayfool, Jan 6, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Johann Blake
    Replies:
    0
    Views:
    343
    Johann Blake
    Jan 21, 2004
  2. Ben Fidge
    Replies:
    8
    Views:
    456
    Ben Fidge
    May 2, 2005
  3. Ahmed Moustafa
    Replies:
    0
    Views:
    814
    Ahmed Moustafa
    Nov 15, 2003
  4. Bapaiah Katepalli
    Replies:
    1
    Views:
    1,531
    Mike Treseler
    Jun 23, 2006
  5. Abby Lee
    Replies:
    5
    Views:
    476
    Abby Lee
    Aug 2, 2004
Loading...

Share This Page