Note that there are some explanatory texts on larger screens.

plurals
  1. POAdvice about what kind of data structure to use for quick search times C++
    text
    copied!<p>I am currently in the thinking process of the data structure I might use for a current project. I don't need to delete items as i am loading a database,using it, and then exiting the program. The only constraint concerns search time.(memory in a second time but mainly time).</p> <p>Overview on what I intend to do. I am parsing files and extracting informations that I use to create various object. After reading the files and creating the objects,i have a set of multiple objects that have references to other one as string. </p> <p><strong>The goal here is to find which net goes from one domain to another</strong> </p> <p>E.g : text input file : </p> <pre><code>module Blabla netTomodule Foo domain 1 ..../*Other parameters of the module*/ end module module Foo netTomodule Blabla netTomodule Foo2 domain 2 ..../*Other parameters of the module*/ end module module Foo2 netTomodule Foo domain 2 ..../*Other parameters of the module*/ end module </code></pre> <p>After reading this I get 3 module objects Foo Foo2 and Blabla and their attributes are as follow : </p> <pre><code>class Module{ private : string name; int domain; netlist * mynetlist; ... } </code></pre> <p><strong>My opinion and the thing i want to get advice on :</strong> </p> <p>After thinking about this, i think that my best shot is to :</p> <ol> <li>When reading the file and extracting info, i should create a linked list of Module.</li> <li>Then with the number of Module i have read, i create an array that is double the size of that.</li> <li>For each module, I use a hash function to hash the module name and put a pointer to this module at the given index in the array</li> <li>Now when i will want to find a module, i just have to compute the hash value and get the pointer at the given index(or increment if its not the good module because of a collision previously in the making of the array)</li> </ol> <p>This is basically an implematation of a hashtable or atleast what i know of a hashtable from my clasess.</p> <p>My question is <strong>Is this a good thought ? Is there a hashtable library i can use that does that ?</strong> (i have heard and look for unordered_map and map but i don't know if it fits my needs very well)</p> <p>This is a huge text so i hope it is detailed enough, so thank you if you have the courage to read everything !</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload