title: Which structure is best for implementation when the number of elements in a list/array is variable?
body: <p>I have a slightly specific question. I am using C/C++ with OpenCV. My aim to store detected rectangles in a list/array style structure. However, the length is variable for every frame (iteration). </p>
  
  <p>What should I use to store this info? I thought of Linked Lists, however, they are slow to traverse and also if the number of nodes decrease, I will have to manually delete the extra nodes which would take up even more processor time. I discarded Arrays as they are not very flexible in terms of their length. I can do dynamic arrays with malloc but even with that I think I will need to specify the maximum number of elements. </p>
  
  <p>feel free to correct me if i'm wrong somewhere. Also please do share your views and let me know what you think is the best way to go about this?</p>
  
  <p>Thanks</p>
  
  <p>EDIT: I'm not restricted to C (i know i mentioned malloc). I can use C++ features as well as the rest of my program does not use any C specific functions. So do feel free to suggest me any better ways. </p>