I have a list of integers that I need to iterate over but an array is inadequate.
What are the differences between vectors and lists and is there anything I need to know before I pick a type?
Just to be clear, I've read the QT docs but this is the extent of what I know:
QList<T>,QLinkedList<T>, andQVector<T>provide similar functionality. Here's an overview:
- For most purposes,
QListis the right class to use. Its index-based API is more convenient thanQLinkedList'siterator-based API, and it is usually faster thanQVectorbecause of the way it stores its items in memory. It also expands to less code in your executable.- If you need a real linked list, with guarantees of constant time insertions in the middle of the list and iterators to items rather than indexes, use
QLinkedList.- If you want the items to occupy adjacent memory positions, use
QVector.