S
Sudarshan Narasimhan
All,
I am developing a module on a telecom box. In my application, i have a
requirement for building a fault management framework, i used std::map
to create a generic fault table which accesses fault objects by using
a key(string).
Now, i am being asked to come up with a much faster lookup better than
O(log n). The thing with the key for the search is that most of them
have a numeric background to them. For eg. 1-A-1-T1-1 (which
corresponds to a specific port on a card, on a slot, on a chassis
etc). So i thought i could define an array of pointers(statically) and
manage this.
But the problem is that, i would have to write a search function for
every table(because the above object is just one type, there are many
such objects of different formats, hence the array would have to
defined and interpreted differently). Also, for some tables, there may
be strings in them which do not have a numeric pattern as above.
Do i need to use a hash function for the above? OR do you have any
other alternatives in mind? Can you refer me to a standard hash
function(havent done a has earlier) or give idea for one? The good
thing is that if i implement a hash function, i can use it generically
on any string, so i would have to implement it only in the base class
and let any table which inherits from the generic table use this
method.
Thanks in advance,
Sud
I am developing a module on a telecom box. In my application, i have a
requirement for building a fault management framework, i used std::map
to create a generic fault table which accesses fault objects by using
a key(string).
Now, i am being asked to come up with a much faster lookup better than
O(log n). The thing with the key for the search is that most of them
have a numeric background to them. For eg. 1-A-1-T1-1 (which
corresponds to a specific port on a card, on a slot, on a chassis
etc). So i thought i could define an array of pointers(statically) and
manage this.
But the problem is that, i would have to write a search function for
every table(because the above object is just one type, there are many
such objects of different formats, hence the array would have to
defined and interpreted differently). Also, for some tables, there may
be strings in them which do not have a numeric pattern as above.
Do i need to use a hash function for the above? OR do you have any
other alternatives in mind? Can you refer me to a standard hash
function(havent done a has earlier) or give idea for one? The good
thing is that if i implement a hash function, i can use it generically
on any string, so i would have to implement it only in the base class
and let any table which inherits from the generic table use this
method.
Thanks in advance,
Sud