Heterogeneous linked structures; for a Tire search.

Discussion in 'C++' started by Jason, Aug 21, 2003.

  1. Jason

    Jason Guest

    Could someone offer some insight on this:

    I have started implementing a Trie, somewhere along the lines of the Aho
    Corasick algorithm (but somewhat different).

    The structures I would like to have are these:

    class TrieNode {};

    class TrieVector : public TrieNode
    {
    TrieNode *vector[256]; // A 256 way table, for input transitions on a
    byte.
    };

    class TrieSequence ; public TrieNode
    {
    unsigned short *pattern;
    size_t patern_len;
    TireNode *match;
    };


    Now what I want to be able to do is have the vector array 'elements' either
    to point to another TrieVector, or a TrieSequence.Depending on the data I
    put in it. Likewise, match will point to a TrieVector or a TrieSequence.

    Now I don't see a good way of doing this. There seems to be two main ways
    (without changing the structures)

    using typeid() and comparing each node in the structure, or using
    dynamic_cast. What is a good approach for this sort of thing?

    --
    GPGKID: 0x7520A898
    Jason, Aug 21, 2003
    #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. kj
    Replies:
    1
    Views:
    358
    Ashmodai
    Apr 15, 2004
  2. Mike
    Replies:
    3
    Views:
    452
  3. Markus Dehmann
    Replies:
    8
    Views:
    2,094
    bartek
    Jun 2, 2004
  4. Alfonso Morra
    Replies:
    11
    Views:
    713
    Emmanuel Delahaye
    Sep 24, 2005
  5. Fregas
    Replies:
    2
    Views:
    111
    Phrogz
    May 11, 2010
Loading...

Share This Page