Array vs List

Should I use an array or list?(I don't have specific code)

When should I use array, when should I use list?

What are the advantages and disadvantages for using an array and a list?
You have to be more specific. What type of list?
http://en.wikipedia.org/wiki/List_(abstract_data_type)

And when you say array, do you mean a fixed size array (std::array<T>) or a dynamic array (std::vector<T>)?
Double linked list(std::list), and std::array.
Last edited on
Well that is easy enough.

Double linked list
Advantage:
- Dynamic growth
Disadvantage:
- Access to any element apart from the first and last takes O(N) time
Example: std::list<T> - http://www.cplusplus.com/reference/list/list/

std::array
Advantage:
- O(1) access to any element
Disadvantage:
- Fixed size, enforced by compiler so can't grow at runtime
Example: http://www.cplusplus.com/reference/array/array/

There might be more, but this is just the basic advantage/disadvantage one has to consider when deciding which to pick
Thank you very much!
Topic archived. No new replies allowed.