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?
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?