What type of data structure will be effective for finding a process table

I need to search the process table, which is populated with the names of the processes running in the given set of ip addresses. I am currently using multimaps in C ++ with the process name as the key and IP address as the value. Is there any other efficient data structure that can perform the same task. can i also get any kind of parallelism using pthreads? if so, can someone point me in the right direction

+4
source share
3 answers

You do not need parallelism to access the data structure in RAM of several thousand records. You can simply lock it (make sure that only one process / thread is accessing it at a time), and make sure that access is enough. Multimap is fine. However, a hash file would be better.

+1
source

What is a typical query for your table?

Try using hashmap, it can be faster for large tables.

How to save names and IP address? Utf string char *? Ip like uint32 or string?

For readonly structures with a large number of read requests, you can use several threads.

upd: use std::unordered_multimap from #include <tr1/unordered_map>

+1
source

Depending on the size of the table, you may find the 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 may be useful to you.

0
source

Source: https://habr.com/ru/post/1300537/


All Articles