以下成员源于类 QLinkedList are part of the Qt compatibility layer. We advise against using them in new code.
| iterator | find (iterator from , const T & t ) |
| iterator | find (const T & t ) |
| const_iterator | find (const_iterator from , const T & t ) const |
| const_iterator | find (const T & t ) const |
| int | findIndex (const T & t ) const |
| iterator | remove (iterator pos ) |
If you need random access to a data structure then QList , QVector , QMap ,或 QHash , are all better choices than QLinkedList .
例如,若有代码像
QLinkedList::iterator i = list->find(from, value);
可以把它重写成
QLinkedList::iterator i = from; while (i != list->end() && *i != value) ++i;
If you need random access to a data structure then QList , QVector , QMap ,或 QHash , are all better choices than QLinkedList .
例如,若有代码像
QLinkedList::iterator i = list->find(value);
可以把它重写成
QLinkedList::iterator i = list->begin(); while (i != list->end() && *i != value) ++i;
If you need random access to a data structure then QList , QVector , QMap ,或 QHash , are all better choices than QLinkedList .
例如,若有代码像
QLinkedList::const_iterator i = list->find(from, value);
可以把它重写成
QLinkedList::const_iterator i = from; while (i != list->end() && *i != value) ++i;
If you need random access to a data structure then QList , QVector , QMap ,或 QHash , are all better choices than QLinkedList .
例如,若有代码像
QLinkedList::const_iterator i = list->find(value);
可以把它重写成
QLinkedList::const_iterator i = list->begin(); while (i != list->end() && *i != value) ++i;
If you need indexes then QList or QVector are better choices than QLinkedList .
例如,若有代码像
int index = list->findIndex(value);
可以把它重写成
int index = 0; bool found = false; for (const_iterator i = list->begin(); i != list->end(); ++i; ++index) if (*i == value) { found = true; break; } if (!found) index = -1;
使用 erase () 代替。