Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>(I had to use an own answer to write code-blocks - sorry!) </p> <p>The <code>composite_key</code> with <code>used_time</code> and <code>parts</code> (as Kirill V. Lyadvinsky suggested) is basically what I've already implemented. I want to get rid of the lexicographical compare of the <code>parts</code>-vector.</p> <p>Suppose I've stored the needed_demand somehow then I could write a simple function, which returns the correct index within a random-access data-structure like that: </p> <pre><code>int get_index(intermediate_result &amp;input_result) const { int ret_value = 0; int index_part = 1; for(int i=0;i&lt;needed_demand.size();++i) { ret_value += input_result.get_part(i) * index_part; index_part *= (needed_demand.get_part(i) + 1); } } </code></pre> <p>Obviously this can be implemented more efficiently and this is not the only possible index ordering for the needed demand. But let's suppose this function exists as a member-function of <code>intermediate_result</code>! Is it possible to write something like this to prevent <code>lexicographical_compare</code> ?</p> <pre><code>indexed_by&lt; random_access&lt; &gt;, ordered_unique&lt; composite_key&lt; intermediate_result, member&lt;intermediate_result, int, &amp;intermediate_result::used_time&gt;, const_mem_fun&lt;intermediate_result,int,&amp;intermediate_result::get_index&gt; &gt; &gt; &gt; </code></pre> <p>If this is possible and I initialized the multi-index with all possible <code>parts</code>-vectors (i.e. in my comment above I would've pushed 24 empty maps in my data-structure), does this find the right entry for a given <code>intermediate_result</code> in constant time (after computing the correct index with <code>get_index</code>) ?<br> I have to ask this, because I don't quite see, how the <code>random_access&lt;&gt;</code> index is linked with the <code>ordered_unique&lt;&gt;</code> index..</p> <p>But thank you for your answers so far!!</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