mercredi 4 mai 2016

Can iterating over unsorted data structure (like array, tree), with multiple thread make iteration faster?

Can iterating over unsorted data structure like array, tree with multiple thread make it faster?

For example I have big array with unsorted data.

int array[1000];

I'm searching array[i] == 8 Can running:

Thread 1:

for(auto i = 0; i < 500; i++)
{
  if(array[i] == 8)
      std::cout << "found" << std::endl;
}

Thread 2:

for(auto i = 500; i < 1000; i++)
{
  if(array[i] == 8)
      std::cout << "found" << std::endl;
}

be faster than normal iteration?

Aucun commentaire:

Enregistrer un commentaire