i have to search a process table which is populated by the names of processes running on a given set of ip adresses. currently i am using multimaps in C++ with process name as key and ip address as the value. is there any other efficient data structure which can do the same task. also can i gain any sort of parallelism by using pthreads ? if so can anyone point me into a right direction
views:
82answers:
3You do not need parallelism to access a data structure in RAM of several thousand entries. You can just lock over it (making sure only one process/thread accesses it at the time), and ensure the access is sufficient enough. Multimap is okay. A hashmap would be better though.
What is typical query to your table?
Try to use hashmap, it can be faster for big tables.
How do you store names and IP? UTF, string, char*? Ip as uint32 or string?
For readonly structure with a lot of read queries you can benefit from several threads.
upd: use std::unordered_multimap
from #include <tr1/unordered_map>
Depending on the size of the table, you may find a hash table more efficient than the multimap
container (which is implemented with a balanced binary tree).
The hash_multimap data structure implements a hash table STL container, and could be of use to you.