PDA

View Full Version : QVector, QLinkedList



aash_89
21st July 2010, 22:01
Hello,

Could anyone please tell me the difference between QVector and QLinkedList.

And when are they used?

Because they look quite similar.

Thank you
Aashish

Zlatomir
21st July 2010, 22:34
QVector<T> (http://doc.qt.nokia.com/4.6/qvector.html) is a generic container classes. It stores its items in adjacent memory locations and provides fast index-based access.

QLinkedList<T> (http://doc.trolltech.com/4.6/qlinkedlist.html) is another generic container classes. It stores a list of values and provides iterator-based access as well as constant time insertions and removals.

wysota
22nd July 2010, 03:20
Those two classes are completely different. QVector is index based and assures items occupy a contignous area of memory. QLinkedList is a sequential container. In most cases you should use neither one nor the other but rather QList. QLinkedList is only interesting for very large lists which you only access sequantially (i.e. when you are interested only in neighbourhood of the current item).