好吧,我有一個在不同的線程中不斷更新的結構。將數組(float)複製到本地數組(float)的最佳方法
現在我需要某些地方的這些變量在本地某個地方沒有他們之間的變化。
我第一次做到了讓他們在當地,這顯然不是最好的方法,但它的工作。
float MyFloatArray[3];
MyFloatArray[0] = otherThread()->floatArray[0];
MyFloatArray[1] = otherThread()->floatArray[1];
MyFloatArray[2] = otherThread()->floatArray[2];
現在我想知道是否有更好的方法來做到這一點。
我已經試過如下:
float MyFloatArray = otherThread()->floatArray;
float* MyFloatArray = otherThread()->floatArray; //Works but updates the otherThread array(Obviously) but that shouldn't happen
因爲我有一個體面的大項目這將是大量的工作,以更新所有這些以std::array<float,3>
有什麼選擇?否則,我會更新我所有的float數組到std::array<float,3>
,因爲如果沒有其他選擇,它會更清晰。
*由於我有一個體面的大項目,將更新所有這些''std :: array'*這並不真正顯示努力解決您的問題... –
Walter
2015-03-13 16:16:51
@Walter:And這並沒有顯示任何幫助它的努力 – 2015-03-13 16:18:19
@LightnessRacesinOrbit正確,但我在他們的位置會做到這一點:更改'std :: array',即使這需要一點努力,它最終會付出代價。 – Walter 2015-03-13 16:36:18