C++: Fastest method to check if all array elements are equal

后端 未结 10 2024
庸人自扰
庸人自扰 2020-12-01 12:50

What is the fastest method to check if all elements of an array(preferable integer array) are equal. Till now I have been using the following code:

bool chec         


        
10条回答
  •  广开言路
    2020-12-01 13:10

    Find a library that's available on your platform that supports threading or parallel-for loops, and split the computation out such that different cores test different ranges of the array.

    Some available libraries are listed here:

    http://parallel-for.sourceforge.net/parallelfor.html

    Or possibly, you can make use of the parallism that many GPU's offer.

提交回复
热议问题