Vector versus dynamic array, does it make a big difference in speed?
<p>Now I am writing some code for solving vehicle routing problems. To do so, one important decision is to choose how to encode the solutions. A solution contains several routes, one for each vehicle. Each route has a customer visiting sequence, the load of route, the length of route.
To perform modifications on a solution the information, I also need to quickly find some information.</p>

<p>For example,<br>
Which route is a customer in?<br>
What customers does a route have?<br>
How many nodes are there in a route?<br>
What nodes are in front of or behind a node?</p>

<p>Now, I am thinking to use the following structure to keep a solution.</p>

<pre><code>struct Sol
{
    vector&lt;short&gt; nextNode;   // show what is the next node of each node;
    vector&lt;short&gt; preNode;    //show what is the preceding node
    vector&lt;short&gt; startNode; 
    vector&lt;short&gt; rutNum;
    vector&lt;short&gt; rutLoad;
    vector&lt;float&gt; rutLength;
    vector&lt;short&gt; rutSize;
};
</code></pre>

<p>The common size of each vector is instance dependent, between 200-2000.</p>

<p>I heard it is possible to use dynamic array to do this job. But it seems to me dynamic array is more complicated. One has to locate the memory and release the memory. Here my question is twofold.</p>

<p>How to use dynamic array to realize the same purpose? how to define the struct or class so that memory location and release can be easily taken care of?</p>

<p>Will using dynamic array be faster than using vector? Assuming the solution structure need to be accessed million times.</p>
