Sub -container (linear storage in the container) includes: QLIST (array list), QLINKEDList (linked list), QVector
qvector (vector):
1, QVector <t> is a container similar to an array, which stores data in continuous memory space
2, qvector <t> Know your length, and can change its size
3, QVector <T> Support random access
4. The efficiency of adding elements at the tail at Qvector <T> is very high, but inserting elements or deleting elements at the head or middle position may be time -consuming
If we predict how many elements should be stored in QVector <t> objects, you can directly initialize the QVector <t> size. If you don’t know After initialization to 0), then use the member function
void |
append ( const T & value ) |
to QVector <T> Add elements at the end
The
qvector class also re -loads the array access operating symbols and output operators:
T & |
operator[] ( int i ) |
const T & |
operator[] ( int i ) const |
QVector<T> & |
operator<< ( const T & value ) |
QVector<T> & |
operator<< ( const QVector<T> & other ) |
This makes it easier and fast to access the elements in a certain position in QVector <t> and add elements to the container
qlinkedList (linked list):
1. QLINKEDList <t> is a two -way linked list in QT, which is efficient in inserting and deleting elements (insertion and deletion of constant time)
2, QLINKEDList <T> does not support random access, it must be used to access it with iterators
3, qlinkedlist <t>operator<<
qlist (array list):
1, Qlist <t> is the most commonly used container in QT. It combines the advantages of QVECTOR <t> and QLINKEDList <t>. It supports random access to accessible access
2, Qlist <t> Insert or remove elements at any end of Qlist <T> is very fast.
3. When there are 1,000 (including) elements in QLINKEDList <t>, the element is inserted in the middle
4. Unless we need to add and delete operations in the middle position in a large collection, or need all elements to be stored continuously in memory, we should always use QLIST <t>
5, qlist <t> heavy loadoperator[]andoperator<<
qstack (stack):
qstack <t> is a vector that provides the semantic semantic semantic semantics
queue (queue):
queue <t> is a list that provides advanced (FIFO) semantics