Heterogeneous linked structures; for a Tire search.

J

Jason

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?
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top