Note that there are some explanatory texts on larger screens.

plurals
  1. POcheck array elements if changed and update values for large arrays in a very fast way in c++
    primarykey
    data
    text
    <p>I have the following code:</p> <pre><code>const int size=9; mtype array[size]; array[0]... array[0].Value=me-&gt;getRootInstance()-&gt;A(); array[0]... ... array[3000]... array[3000].Value=me-&gt;getRootInstance()-&gt;A3000(); array[3000]... while(Logging::getLogging()){ if(!areEqual(array[0].Value,me-&gt;getRootInstance()-&gt;A())){array[0].Value=me-&gt;getRootInstance()-&gt;A(); saveValue(array[0]);} ... if(!areEqual(array[3000].Value,me-&gt;getRootInstance()-&gt;A3000())){array[3000].Value=me-&gt;getRootInstance()-&gt;A3000(); saveValue(array[3000]);} } return 0; </code></pre> <p>An array of structs is initialized at the beginning and checked for changes. If changes occur the values in the array should be updated. The problem is that the current code is very slow, I know that changes occur every 100 miliseconds. for small arrays it works fine. Nevertheless, if the array is large( 3000 elements) the update time delay is over 3s. Is there a better way to compare and update the elements of the array?</p> <p>the areEqual function looks like this: <code>return fabs(a - b) &lt; 0.000000000001;</code></p> <p>and the saveValues() looks like this:</p> <pre><code>OMGuard _omGuard(r_omGuard); int tc = clock()-Logging::getStarttime(); //clicks double seconds = ((double)tc)/CLOCKS_PER_SEC; mtype *newstruct = new mtype(); newstruct-&gt;Calltime = seconds; newstruct-&gt;Name = melem.Name; newstruct-&gt;Value = melem.Value; newstruct-&gt;GUID = melem.GUID; newstruct-&gt;ReqName = melem.ReqName; newstruct-&gt;ReqGUID = melem.ReqGUID; monitoredlist.add(newstruct); </code></pre> <p>Thank you for any help! Greetings Ed</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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