Created
January 23, 2013 12:10
-
-
Save lamprosg/4604903 to your computer and use it in GitHub Desktop.
Qt - qFind algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //How to use qFind() | |
| #include "mytimer.h" | |
| int main(int argc, char *argv[]) | |
| { | |
| QCoreApplication a(argc, argv); | |
| QList<int> List; | |
| List << 1 << 5 << 15 << 23; | |
| //qFind(starting point,ending point, value we're looking for) | |
| QList<int>::const_iterator Iter = qFind(List.begin(),List.end(),15); | |
| if (Iter != List.end()) //if it's not equal to the end of the list (23), then we found a value | |
| { | |
| int value = *Iter; //The value we found (15) | |
| } | |
| else | |
| { | |
| //Value not found, iter=List.end() | |
| } | |
| return a.exec(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment