⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qlistiterator.3qt

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 3QT
字号:
.TH QListIterator 3qt "3 September 2000" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2000 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQListIterator \- Iterator for QList collections.SH SYNOPSIS.br.PP\fC#include <qlist.h>\fR.PPInherits QGListIterator..PPInherited by QStrListIterator..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQListIterator\fR ( const QList<type> & list ) ".br.ti -1c.BI "\fB~QListIterator\fR () ".br.ti -1c.BI "uint \fBcount\fR () const".br.ti -1c.BI "bool \fBisEmpty\fR () const".br.ti -1c.BI "bool \fBatFirst\fR () const".br.ti -1c.BI "bool \fBatLast\fR () const".br.ti -1c.BI "type* \fBtoFirst\fR () ".br.ti -1c.BI "type* \fBtoLast\fR () ".br.ti -1c.BI "operator \fBtype*\fR ()const".br.ti -1c.BI "type* \fBoperator*\fR () ".br.ti -1c.BI "type* \fBcurrent\fR () const".br.ti -1c.BI "type* \fBoperator\fR () ".br.ti -1c.BI "type* \fBoperator++\fR () ".br.ti -1c.BI "type* \fBoperator+=\fR ( uint jump ) ".br.ti -1c.BI "type* \fBoperator--\fR () ".br.ti -1c.BI "type* \fBoperator-=\fR ( uint jump ) ".br.ti -1c.BI "QListIterator<type>& \fBoperator=\fR ( const QListIterator<type> & it ) ".br.in -1c.SH DESCRIPTIONThe QListIterator class provides an iterator for QList collections..PPDefine a template instance QListIterator<X> to create a list iterator that operates on QList<X> (list of X*)..PPExample:.PP.nf.br    #include <qlist.h>.br    #include <qstring.h>.br    #include <stdio.h>.br.br    class Employee.br    {.br    public:.br        Employee( const char *name, int salary ) { n=name; s=salary; }.br        const char *name()   const               { return n; }.br        int         salary() const               { return s; }.br    private:.br        QString     n;.br        int         s;.br    };.br.br    void main().br    {.br        QList<Employee> list;             // list of pointers to Employee.br        list.setAutoDelete( TRUE );       // delete items when they are removed.br.br        list.append( new Employee("Bill", 50000) );.br        list.append( new Employee("Steve",80000) );.br        list.append( new Employee("Ron",  60000) );.br.br        QListIterator<Employee> it(list); // iterator for employee list.br        for ( ; it.current(); ++it ) {.br            Employee *emp = it.current();.br            printf( "%s earns %d\\n", emp->name().latin1(), emp->salary() );.br        }.br    }.fi.PPProgram output:.PP.nf.br        Bill earns 50000.br        Steve earns 80000.br        Ron earns 60000.fi.PPAlthough QList has member functions to traverse the doubly linked list structure, using a list iterator is a much more robust way of traversing the list, because multiple list iterators can operate on the same list, independent of each other and independent of the QList's current item. An iterator has its own current list item and can get the next and previous list items. It can only traverse the list, never modify it..PPA QList knows about all list iterators that are operating on the list. When an item is removed from the list, the list update all iterators that are pointing the removed item to point to the new current list item..PPExample:.PP.nf.br    #include <qlist.h>.br    #include <qstring.h>.br    #include <stdio.h>.br.br    class Employee.br    {.br        ...     // same as above.br    };.br.br    void main().br    {.br        QList<Employee> list;             // list of pointers to Employee.br        list.setAutoDelete( TRUE );       // delete items when they are removed.br.br        list.append( new Employee("Bill", 50000) );.br        list.append( new Employee("Steve",80000) );.br        list.append( new Employee("Ron",  60000) );.br.br        QListIterator<Employee> it(list);.br.br        list.at( 1 );                     // current list item: "Steve".br        it.toLast();                      // it: "Ron".br        --it;                             // it: "Steve".br.br          // Now, both the list and the iterator are referring the same item.br.br        list.remove();.br        printf( "%s\\n", it.current()->name().latin1() );.br    }.fi.PPProgram output:.PP.nf.br        Ron.fi.PPSee also QList and collection classes.PPExamples:.(ldirview/main.cpp.)l.SH MEMBER FUNCTION DOCUMENTATION.SH "QListIterator::QListIterator ( const QList<type> & list )"Constructs an iterator for \fIlist.\fR The current iterator item is set to point on the first item in the \fIlist.\fR.SH "QListIterator::~QListIterator ()"Destroys the iterator..SH "QListIterator::operator type * () const"Cast operator. Returns a pointer to the current iterator item. Same as current()..SH "bool QListIterator::atFirst () const"Returns TRUE if the current iterator item is the first list item, otherwise FALSE..PPSee also toFirst() and atLast()..SH "bool QListIterator::atLast () const"Returns TRUE if the current iterator item is the last list item, otherwise FALSE..PPSee also toLast() and atFirst()..SH "uint QListIterator::count () const"Returns the number of items in the list this iterator operates on..PPSee also isEmpty()..SH "type * QListIterator::current () const"Returns a pointer to the current iterator item..SH "bool QListIterator::isEmpty () const"Returns TRUE if the list is empty, i.e. count() == 0, otherwise FALSE..PPSee also count()..SH "type * QListIterator::operator() ()"Makes the succeeding item current and returns the original current item..PPIf the current iterator item was the last item in the list or if it was null, null is returned..SH "type * QListIterator::operator* ()"Asterix operator. Returns a pointer to the current iterator item. Same as current()..SH "type * QListIterator::operator++ ()"Prefix ++ makes the succeeding item current and returns the new current item..PPIf the current iterator item was the last item in the list or if it was null, null is returned..SH "type * QListIterator::operator+= ( uint jump )"Sets the current item to the item \fIjump\fR positions after the current item, and returns a pointer to that item..PPIf that item is beyond the last item or if the dictionary is empty, it sets the current item to null and returns null..SH "type * QListIterator::operator-- ()"Prefix -- makes the preceding item current and returns the new current item..PPIf the current iterator item was the first item in the list or if it was null, null is returned..SH "type * QListIterator::operator-= ( uint jump )"Returns the item \fIjump\fR positions before the current item, or null if it is beyond the first item. Makes this the current item..SH "QListIterator<type>& QListIterator::operator= ( const QListIterator<type> & it )"Assignment. Makes a copy of the iterator \fIit\fR and returns a reference to this iterator..SH "type * QListIterator::toFirst ()"Sets the current iterator item to point to the first list item and returns a pointer to the item. Sets the current item to null and returns null if the list is empty..PPSee also toLast() and atFirst()..SH "type * QListIterator::toLast ()"Sets the current iterator item to point to the last list item and returns a pointer to the item. Sets the current item to null and returns null if the list is empty..PPSee also  toFirst() and atLast()..SH "SEE ALSO".BR http://doc.trolltech.com/qlistiterator.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -