Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Possible Duplicates:
Using arrays or std::vectors in C++, what's the performance gap?Using arrays or std::vectors in C++, what's the performance gap?
std::vector is so much slower than plain arrays?std::vector is so much slower than plain arrays?

memory is vector of 1000 elements array[] is an integer array of 1000 elements

for (iteration = 0; iteration < numiterations; iteration++) { for (j = 1; j < numints; j++) { memory[j] += memory[j - 1]; //array[j] += array[j - 1]; } } 

If I compare the time of the for loop after running 100 iterations, time required for accessing is very much small compared to that of vector

why is the case ? because I thought both takes constant and nearly same time ..

Possible Duplicates:
Using arrays or std::vectors in C++, what's the performance gap?
std::vector is so much slower than plain arrays?

memory is vector of 1000 elements array[] is an integer array of 1000 elements

for (iteration = 0; iteration < numiterations; iteration++) { for (j = 1; j < numints; j++) { memory[j] += memory[j - 1]; //array[j] += array[j - 1]; } } 

If I compare the time of the for loop after running 100 iterations, time required for accessing is very much small compared to that of vector

why is the case ? because I thought both takes constant and nearly same time ..

Possible Duplicates:
Using arrays or std::vectors in C++, what's the performance gap?
std::vector is so much slower than plain arrays?

memory is vector of 1000 elements array[] is an integer array of 1000 elements

for (iteration = 0; iteration < numiterations; iteration++) { for (j = 1; j < numints; j++) { memory[j] += memory[j - 1]; //array[j] += array[j - 1]; } } 

If I compare the time of the for loop after running 100 iterations, time required for accessing is very much small compared to that of vector

why is the case ? because I thought both takes constant and nearly same time ..

insert duplicate link
Source Link

Possible Duplicates:
Using arrays or std::vectors in C++, what's the performance gap?
std::vector is so much slower than plain arrays?

memory is vector of 1000 elements array[] is an integer array of 1000 elements

for (iteration = 0; iteration < numiterations; iteration++) { for (j = 1; j < numints; j++) { memory[j] += memory[j - 1]; //array[j] += array[j - 1]; } } 

If I compare the time of the for loop after running 100 iterations, time required for accessing is very much small compared to that of vector

why is the case ? because I thought both takes constant and nearly same time ..

memory is vector of 1000 elements array[] is an integer array of 1000 elements

for (iteration = 0; iteration < numiterations; iteration++) { for (j = 1; j < numints; j++) { memory[j] += memory[j - 1]; //array[j] += array[j - 1]; } } 

If I compare the time of the for loop after running 100 iterations, time required for accessing is very much small compared to that of vector

why is the case ? because I thought both takes constant and nearly same time ..

Possible Duplicates:
Using arrays or std::vectors in C++, what's the performance gap?
std::vector is so much slower than plain arrays?

memory is vector of 1000 elements array[] is an integer array of 1000 elements

for (iteration = 0; iteration < numiterations; iteration++) { for (j = 1; j < numints; j++) { memory[j] += memory[j - 1]; //array[j] += array[j - 1]; } } 

If I compare the time of the for loop after running 100 iterations, time required for accessing is very much small compared to that of vector

why is the case ? because I thought both takes constant and nearly same time ..

edited tags
Link
Matthew Flaschen
  • 286.4k
  • 53
  • 523
  • 554
added 13 characters in body
Source Link
mauris
  • 43.6k
  • 16
  • 102
  • 132
Loading
Source Link
ajayreddy
  • 83
  • 1
  • 1
  • 8
Loading