Esri Interview Question: How to make vectors push_back... | Glassdoor

Interview Question

Software Development Engineer Interview Redlands, CA

How to make vectors push_back function as efficient as c

  arrays ? Why it is slow?
Answer

Interview Answer

1 Answer

0

It’s slow because the vector potentially has to reallocate more memory. You could use std::vector::reserve to allocate memory in advance. Source: http://stackoverflow.com/questions/4006634/stdvector-push-back-is-bottleneck

Ben on Aug 15, 2016

Add Answers or Comments

To comment on this, Sign In or Sign Up.