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

📄 qvector.3qt

📁 Trolltech公司发布的基于C++图形开发环境
💻 3QT
字号:
'\" t.TH QVector 3qt "24 January 2005" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQVector \- Template collection class that provides a vector (array).br.PP\fC#include <qvector.h>\fR.PPInherits QGVector..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQVector\fR () ".br.ti -1c.BI "\fBQVector\fR ( uint size ) ".br.ti -1c.BI "\fBQVector\fR ( const QVector<type> & v ) ".br.ti -1c.BI "\fB~QVector\fR () ".br.ti -1c.BI "QVector<type>& \fBoperator=\fR ( const QVector<type> & v ) ".br.ti -1c.BI "type** \fBdata\fR () const".br.ti -1c.BI "uint \fBsize\fR () const".br.ti -1c.BI "virtual uint \fBcount\fR () const".br.ti -1c.BI "bool \fBisEmpty\fR () const".br.ti -1c.BI "bool \fBisNull\fR () const".br.ti -1c.BI "bool \fBresize\fR ( uint size ) ".br.ti -1c.BI "bool \fBinsert\fR ( uint " "i" ", const type * d ) ".br.ti -1c.BI "bool \fBremove\fR ( uint i ) ".br.ti -1c.BI "type* \fBtake\fR ( uint i ) ".br.ti -1c.BI "virtual void \fBclear\fR () ".br.ti -1c.BI "bool \fBfill\fR ( const type * " "d" ", int " "size" "=-1 ) ".br.ti -1c.BI "void \fBsort\fR () ".br.ti -1c.BI "int \fBbsearch\fR ( const type * d ) const".br.ti -1c.BI "int \fBfindRef\fR ( const type * " "d" ", uint " "i" "=0 ) const".br.ti -1c.BI "int \fBfind\fR ( const type * " "d" ", uint " "i" "= 0 ) const".br.ti -1c.BI "uint \fBcontainsRef\fR ( const type * d ) const".br.ti -1c.BI "uint \fBcontains\fR ( const type * d ) const".br.ti -1c.BI "type* \fBoperator[]\fR ( int i ) const".br.ti -1c.BI "type* \fBat\fR ( uint i ) const".br.ti -1c.BI "void \fBtoList\fR ( QGList * list ) const".br.in -1c.SH DESCRIPTIONThe QVector class is a template collection class that provides a vector (array)..PPQVector is implemented as a template class. Define a template instance QVector<X> to create a vector that contains pointers to X, or X*..PPA vector is the same as an array. The main difference between QVector and QArray is that QVector stores pointers to the elements, while QArray stores the elements themselves (i.e. QArray is value-based)..PPUnless where otherwise stated, all functions that remove items from the vector will also delete the element pointed to if auto-deletion is enabled - see setAutoDelete(). By default, auto-deletion is disabled. This behaviour can be changed in a subclass by reimplementing the virtual method deleteItem()..PPFunctions that compares items, e.g. find() and sort(), will do so using the virtual function compareItems(). The default implementation of this function will only compare the absolute pointer values. Reimplement compareItems() in a subclass to get searching and sorting based on the item contents..PPSee also Collection Classes and QArray..SH MEMBER FUNCTION DOCUMENTATION.SH "QVector::QVector ()"Constructs a null vector..PPSee also isNull()..SH "QVector::QVector ( const QVector<type> & v )"Constructs a copy of \fIv.\fR Only the pointers are copied (i.e. shallow copy)..SH "QVector::QVector ( uint size )"Constructs an vector with room for \fIsize\fR items. Makes a null vector if \fIsize\fR == 0..PPAll \fIsize\fR positions in the vector are initialized to 0..PPSee also size(), resize() and isNull()..SH "QVector::~QVector ()"Removes all items from the vector, and destroys the vector itself..PPSee also clear()..SH "type * QVector::at ( uint i ) const"Returns the item at position \fIi,\fR or 0 if there is no item at that position. \fIi\fR must be less than size()..SH "int QVector::bsearch ( const type * d ) const"In a sorted array, finds the first occurrence of \fId\fR using binary search. For a sorted array, this is generally much faster than find(), which does a linear search..PPReturns the position of \fId,\fR or -1 if \fId\fR could not be found. \fId\fR may not be 0..PPCompares items using the virtual function compareItems()..PPSee also sort() and find()..SH "void QVector::clear () \fC[virtual]\fR"Removes all items from the vector, and destroys the vector itself..PPThe vector becomes a null vector..PPSee also isNull()..PPReimplemented from QCollection..SH "uint QVector::contains ( const type * d ) const"Returns the number of occurrences of item \fId\fR in the vector..PPCompares items using the virtual function compareItems()..PPSee also containsRef()..SH "uint QVector::containsRef ( const type * d ) const"Returns the number of occurrences of the item pointer \fId\fR in the vector..PPThis function does \fInot\fR use compareItems() to compare items..PPSee also findRef()..SH "uint QVector::count () const \fC[virtual]\fR"Returns the number of items in the vector. The vector is empty if count() == 0..PPSee also isEmpty() and size()..PPReimplemented from QCollection..SH "type ** QVector::data () const"Returns a pointer to the actual vector data, which is an array of type*..PPThe vector is a null vector if data() == 0 (null pointer)..PPSee also isNull()..SH "bool QVector::fill ( const type * d, int size=-1 )"Inserts item \fId\fR in all positions in the vector. Any existing items are removed. If \fId\fR is 0, the vector becomes empty..PPIf \fIsize\fR >= 0, the vector is first resized to \fIsize.\fR By default, \fIsize\fR is -1..PPReturns TRUE if successful, or FALSE if the memory cannot be allocated (only if a resize has been requested)..PPSee also resize(), insert() and isEmpty()..SH "int QVector::find ( const type * d, uint i= 0 ) const"Finds the first occurrence of item \fId\fR in the vector, using linear search. The search starts at position \fIi,\fR which must be less than size(). \fIi\fR is by default 0; i.e. the search starts at the start of the vector..PPReturns the position of \fIv,\fR or -1 if \fIv\fR could not be found..PPCompares items using the virtual function compareItems()..PPSee also findRef() and bsearch()..SH "int QVector::findRef ( const type * d, uint i=0 ) const"Finds the first occurrence of the item pointer \fId\fR in the vector, using linear search. The search starts at position \fIi,\fR which must be less than size(). \fIi\fR is by default 0; i.e. the search starts at the start of the vector..PPReturns the position of \fId,\fR or -1 if \fId\fR could not be found..PPThis function does \fInot\fR use compareItems() to compare items..PPSee also find() and bsearch()..SH "bool QVector::insert ( uint i, const type * d )"Sets position \fIi\fR in the vector to contain the item \fId. i\fR must be less than size(). Any previous element in position \fIi\fR is removed..PPSee also at()..SH "bool QVector::isEmpty () const"Returns TRUE if the vector is empty, i.e. count() == 0, otherwise FALSE..PPSee also count()..SH "bool QVector::isNull () const"Returns TRUE if the vector is null, otherwise FALSE..PPA null vector has size() == 0 and data() == 0..PPSee also size()..SH "QVector<type> & QVector::operator= ( const QVector<type> & v )"Assigns \fIv\fR to this vector and returns a reference to this vector..PPThis vector is first cleared, then all the items from \fIv\fR is copied into this vector. Only the pointers are copied (i.e. shallow copy)..PPSee also clear()..SH "type * QVector::operator[] ( int i ) const"Returns the item at position \fIi,\fR or 0 if there is no item at that position. \fIi\fR must be less than size()..PPEquivalent to at( \fIi\fR )..PPSee also at()..SH "bool QVector::remove ( uint i )"Removes the item at position \fIi\fR in the vector, if there is one. \fIi\fR must be less than size()..PPReturns TRUE unless \fIi\fR is out of range..PPSee also take() and at()..SH "bool QVector::resize ( uint size )"Resizes (expands or shrinks) the vector to \fIsize\fR elements. The array becomes a null array if \fIsize\fR == 0..PPAny items in position \fIsize\fR or beyond in the vector are removed. New positions are initialized 0..PPReturns TRUE if successful, or FALSE if the memory cannot be allocated..PPSee also size() and isNull()..SH "uint QVector::size () const"Returns the size of the vector, i.e. the number of vector positions. This is also the maximum number of items the vector can hold..PPThe vector is a null vector if size() == 0..PPSee also isNull(), resize() and count()..SH "void QVector::sort ()"Sorts the items in ascending order. Any empty positions will be put last..PPCompares items using the virtual function compareItems()..PPSee also bsearch()..SH "type* QVector::take ( uint i )"Returns the item at position \fIi\fR in the vector, and removes that item from the vector. \fIi\fR must be less than size(). If there is no item at position \fIi,\fR 0 is returned..PPIn contrast to remove(), this function does \fInot\fR call deleteItem() for the removed item..PPSee also remove() and at()..SH "void QVector::toList ( QGList * list ) const"Copies all items in this vector to the list \fIlist.\fR First, \fIlist\fR is cleared, then all items are appended to \fIlist.\fR.PPSee also  QList, QStack and QQueue..SH "SEE ALSO".BR http://doc.trolltech.com/qvector.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports make our job much simpler. Thank you..PIn case of content or formattting problems with this manual page, pleasereport them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qvector.3qt) and the Qtversion (2.3.10).

⌨️ 快捷键说明

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