Java 8 times faster with arrays than std::vector in C++. What did I do wrong?
问题 I have the following Java code with several big arrays which never change their size. It runs in 1100 ms on my computer. I implemented the same code in C++ and used std::vector . The time of the C++ implementation which runs the exact same code is 8800 ms on my computer. What did I do wrong, so that it runs this slowly? Basically the code does the following: for (int i = 0; i < numberOfCells; ++i) { h[i] = h[i] + 1; floodedCells[i] = !floodedCells[i]; floodedCellsTimeInterval[i] =