#include <qvector.h>
Inheritance diagram for QVector< T >:


QVector<T> is one of Qt's generic {container classes}. It stores its items in adjacent memory locations and provides fast index-based access.
QList<T>, QLinkedList<T>, and QVarLengthArray<T> provide similar functionality. Here's an overview:
For most purposes, QList is the right class to use. Operations like prepend() and insert() are usually faster than with QVector because of the way QList stores its items in memory (see {Algorithmic Complexity} for details), and its index-based API is more convenient than QLinkedList's iterator-based API. It also expands to less code in your executable. If you need a real linked list, with guarantees of {constant time} insertions in the middle of the list and iterators to items rather than indexes, use QLinkedList. If you want the items to occupy adjacent memory positions, use QVector. If you want a low-level variable-size array, QVarLengthArray may be sufficient.
Here's an example of a QVector that stores integers and a QVector that stores QString values:
QVector<int> integerVector; QVector<QString> stringVector;
QVector stores a vector (or array) of items. Typically, vectors are created with an initial size. For example, the following code constructs a QVector with 200 elements:
QVector<QString> vector(200);
The elements are automatically initialized with a {default-constructed value}. If you want to initialize the vector with a different value, pass that value as the second argument to the constructor:
QVector<QString> vector(200, "Pass");
You can also call fill() at any time to fill the vector with a value.
QVector uses 0-based indexes, just like C++ arrays. To access the item at a particular index position, you can use operator[](). On non-const vectors, operator[]() returns a reference to the item that can be used on the left side of an assignment:
if (vector[0] == "Liz") vector[0] = "Elizabeth";
For read-only access, an alternative syntax is to use at():
for (int i = 0; i < vector.size(); ++i) { if (vector.at(i) == "Alfonso") cout << "Found Alfonso at position " << i << endl; }
at() can be faster than operator[](), because it never causes a {deep copy} to occur.
Another way to access the data stored in a QVector is to call data(). The function returns a pointer to the first item in the vector. You can use the pointer to directly access and modify the elements stored in the vector. The pointer is also useful if you need to pass a QVector to a function that accepts a plain C++ array.
If you want to find all occurrences of a particular value in a vector, use indexOf() or lastIndexOf(). The former searches forward starting from a given index position, the latter searches backward. Both return the index of the matching item if they found one; otherwise, they return -1. For example:
int i = vector.indexOf("Harumi"); if (i != -1) cout << "First occurrence of Harumi is at position " << i << endl;
If you simply want to check whether a vector contains a particular value, use contains(). If you want to find out how many times a particular value occurs in the vector, use count().
QVector provides these basic functions to add, move, and remove items: insert(), replace(), remove(), prepend(), append(). With the exception of append(), these functions can be slow ({linear time}) for large vectors, because they require moving many items in the vector by one position in memory. If you want a container class that provides fast insertion/removal in the middle, use QList or QLinkedList instead.
Unlike plain C++ arrays, QVectors can be resized at any time by calling resize(). If the new size is larger than the old size, QVector might need to reallocate the whole vector. QVector tries to reduce the number of reallocations by preallocating up to twice as much memory as the actual data needs.
If you know in advance approximately how many items the QVector will contain, you can call reserve(), asking QVector to preallocate a certain amount of memory. You can also call capacity() to find out how much memory QVector actually allocated.
QVector's value type must be an {assignable data type}. This covers most data types that are commonly used, but the compiler won't let you, for example, store a QWidget as a value; instead, store a QWidget *. A few functions have additional requirements; for example, indexOf() and lastIndexOf() expect the value type to support operator==(). These requirements are documented on a per-function basis.
Like the other container classes, QVector provides {Java-style iterators} (QVectorIterator and QMutableVectorIterator) and {STL-style iterators} (QVector::const_iterator and QVector::iterator). In practice, these are rarely used, because you can use indexes into the QVector.
In addition to QVector, Qt also provides QVarLengthArray, a very low-level class with little functionality that is optimized for speed.
QVector does not support inserting, prepending, appending or replacing with references to its own values. Doing so will cause your application to abort with an error message.
Definition at line 66 of file qvector.h.
Public Types | |
| typedef T * | iterator |
| typedef const T * | const_iterator |
| typedef T | value_type |
| typedef value_type * | pointer |
| typedef const value_type * | const_pointer |
| typedef value_type & | reference |
| typedef const value_type & | const_reference |
| typedef ptrdiff_t | difference_type |
| typedef iterator | Iterator |
| typedef const_iterator | ConstIterator |
| typedef int | size_type |
Public Member Functions | |
| QVector () | |
| QVector (int size) | |
| QVector (int size, const T &t) | |
| QVector (const QVector< T > &v) | |
| ~QVector () | |
| QVector< T > & | operator= (const QVector< T > &v) |
| bool | operator== (const QVector< T > &v) const |
| bool | operator!= (const QVector< T > &v) const |
| int | size () const |
| bool | isEmpty () const |
| void | resize (int size) |
| int | capacity () const |
| void | reserve (int size) |
| void | squeeze () |
| void | detach () |
| bool | isDetached () const |
| void | setSharable (bool sharable) |
| T * | data () |
| const T * | data () const |
| const T * | constData () const |
| void | clear () |
| const T & | at (int i) const |
| T & | operator[] (int i) |
| const T & | operator[] (int i) const |
| void | append (const T &t) |
| void | prepend (const T &t) |
| void | insert (int i, const T &t) |
| void | insert (int i, int n, const T &t) |
| void | replace (int i, const T &t) |
| void | remove (int i) |
| void | remove (int i, int n) |
| QVector< T > & | fill (const T &t, int size=-1) |
| int | indexOf (const T &t, int from=0) const |
| int | lastIndexOf (const T &t, int from=-1) const |
| bool | contains (const T &t) const |
| int | count (const T &t) const |
| iterator | begin () |
| const_iterator | begin () const |
| const_iterator | constBegin () const |
| iterator | end () |
| const_iterator | end () const |
| const_iterator | constEnd () const |
| iterator | insert (iterator before, int n, const T &x) |
| iterator | insert (iterator before, const T &x) |
| iterator | erase (iterator begin, iterator end) |
| iterator | erase (iterator pos) |
| int | count () const |
| T & | first () |
| const T & | first () const |
| T & | last () |
| const T & | last () const |
| QVector< T > | mid (int pos, int length=-1) const |
| T | value (int i) const |
| T | value (int i, const T &defaultValue) const |
| void | push_back (const T &t) |
| void | push_front (const T &t) |
| void | pop_back () |
| void | pop_front () |
| bool | empty () const |
| T & | front () |
| const_reference | front () const |
| reference | back () |
| const_reference | back () const |
| QVector< T > & | operator+= (const QVector< T > &l) |
| QVector< T > | operator+ (const QVector< T > &l) const |
| QVector< T > & | operator+= (const T &t) |
| QVector< T > & | operator<< (const T &t) |
| QVector< T > & | operator<< (const QVector< T > &l) |
| QList< T > | toList () const |
| std::vector< T > | toStdVector () const |
Static Public Member Functions | |
| static QVector< T > | fromList (const QList< T > &list) |
| static QVector< T > | fromStdVector (const std::vector< T > &vector) |
Private Types | |
| typedef QVectorTypedData< T > | Data |
Private Member Functions | |
| void | detach_helper () |
| QVectorData * | malloc (int alloc) |
| void | realloc (int size, int alloc) |
| void | free (Data *d) |
Private Attributes | |
| union { | |
| QVectorData * p | |
| QVectorTypedData< T > * d | |
| }; | |
Related Functions | |
| (Note that these are not member functions.) | |
| QDataStream & | operator<< (QDataStream &out, const QVector< T > &vector) |
| QDataStream & | operator>> (QDataStream &in, QVector< T > &vector) |
typedef QVectorTypedData<T> QVector< T >::Data [private] |
The QVector::iterator typedef provides an STL-style non-const iterator for QVector and QStack.
QVector provides both {STL-style iterators} and {Java-style iterators}. The STL-style non-const iterator is simply a typedef for "T *" (pointer to T).
| QVector< T >::const_iterator |
The QVector::const_iterator typedef provides an STL-style const iterator for QVector and QStack.
QVector provides both {STL-style iterators} and {Java-style iterators}. The STL-style const iterator is simply a typedef for "const T *" (pointer to const T).
| QVector< T >::value_type |
| QVector< T >::const_pointer |
| QVector< T >::const_reference |
| QVector< T >::difference_type |
Qt-style synonym for QVector::iterator.
| QVector< T >::ConstIterator |
Qt-style synonym for QVector::const_iterator.
Constructs a vector with an initial size of size elements.
The elements are initialized with a {default-constructed value}.
Definition at line 340 of file qvector.h.
References b, QVector< T >::d, i, QVector< T >::malloc(), QVector< T >::p, qMemSet(), and T.
00341 { 00342 p = malloc(asize); 00343 d->ref.init(1); 00344 d->alloc = d->size = asize; 00345 d->sharable = true; 00346 if (QTypeInfo<T>::isComplex) { 00347 T* b = d->array; 00348 T* i = d->array + d->size; 00349 while (i != b) 00350 new (--i) T; 00351 } else { 00352 qMemSet(d->array, 0, asize * sizeof(T)); 00353 } 00354 }
Here is the call graph for this function:

Constructs a vector with an initial size of size elements. Each element is initialized with value.
Definition at line 357 of file qvector.h.
References QVector< T >::d, i, QVector< T >::malloc(), QVector< T >::p, and T.
00358 { 00359 p = malloc(asize); 00360 d->ref.init(1); 00361 d->alloc = d->size = asize; 00362 d->sharable = true; 00363 T* i = d->array + d->size; 00364 while (i != d->array) 00365 new (--i) T(t); 00366 }
Here is the call graph for this function:

Constructs a copy of other.
This operation takes {constant time}, because QVector is {implicitly shared}. This makes returning a QVector from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes {linear time}.
Definition at line 75 of file qvector.h.
00075 : d(v.d) { d->ref.ref(); if (!d->sharable) detach_helper(); }
Assigns other to this vector and returns a reference to this vector.
Definition at line 321 of file qvector.h.
References QVector< T >::d, QVector< T >::detach_helper(), QVector< T >::free(), qAtomicSetPtr(), and x.
Referenced by Q3ValueVector< T >::operator=().
00322 { 00323 typename QVector::Data *x = v.d; 00324 x->ref.ref(); 00325 x = qAtomicSetPtr(&d, x); 00326 if (!x->ref.deref()) 00327 free(x); 00328 if (!d->sharable) 00329 detach_helper(); 00330 return *this; 00331 }
Here is the call graph for this function:

Returns true if other is equal to this vector; otherwise returns false.
Two vectors are considered equal if they contain the same values in the same order.
This function requires the value type to have an implementation of operator==().
Definition at line 543 of file qvector.h.
References b, QVector< T >::d, i, j, and T.
00544 { 00545 if (d->size != v.d->size) 00546 return false; 00547 if (d == v.d) 00548 return true; 00549 T* b = d->array; 00550 T* i = b + d->size; 00551 T* j = v.d->array + d->size; 00552 while (i != b) 00553 if (!(*--i == *--j)) 00554 return false; 00555 return true; 00556 }
Returns true if other is not equal to this vector; otherwise returns false.
Two vectors are considered equal if they contain the same values in the same order.
This function requires the value type to have an implementation of operator==().
Definition at line 79 of file qvector.h.
| int QVector< T >::size | ( | ) | const [inline] |
Returns the number of items in the vector.
Definition at line 81 of file qvector.h.
Referenced by CPP::WriteInitialization::acceptWidget(), QPolygonalProcessor::add(), QRegExpEngine::Box::addAnchorsToEngine(), QRegExpEngine::addCatTransitions(), Q3Header::addLabel(), QRegExpEngine::addLookahead(), QRegExpEngine::addPlusTransitions(), QPainterPath::addPolygon(), QRegExpCharClass::addRange(), QPainterPath::addRegion(), QPdfEnginePrivate::addXrefEntry(), QRegExpEngine::anchorAlternation(), Q3TextString::appendParagraphs(), QTextDocumentPrivate::appendUndoItem(), Q3CanvasEllipse::areaPoints(), QVector< T >::at(), QTextEngine::attributes(), QFontEngineMulti::boundingBox(), QTextEngine::boundingBox(), QTextLayout::boundingRect(), QRegExp::capturedTexts(), QRegExpEngine::Box::cat(), QRegExpEngine::Box::catAnchor(), Q3TextString::checkBidi(), Q3CanvasPolygonalItem::chunks(), QFTOutlineMapper::clipElements(), QX11PaintEnginePrivate::clipPolygon_dev(), closestMatch(), QGraphicsItem::collidesWithPath(), ShadeWidget::colorAt(), QColormap::colorAt(), Q3ListBox::columnAt(), convert_Mono_to_Indexed8(), convert_Mono_to_X32(), convert_RGB_to_Indexed8(), qdesigner_internal::QDesignerResource::createDom(), QTextLayout::createLine(), QRegExpEngine::createState(), QTreeWidgetItem::data(), QGraphicsSceneBspTree::debug(), QDBusMetaType::demarshall(), QGridLayoutPrivate::distribute(), dither_to_Mono(), Q3ListBox::doLayout(), QTextLayout::draw(), QPainter::drawConvexPolygon(), QTextLayout::drawCursor(), QPaintEngine::drawEllipse(), drawLine_midpoint_dashed_i(), QPainter::drawLines(), QX11PaintEngine::drawPath(), QPainter::drawPoints(), QPainter::drawPolygon(), QPainter::drawPolyline(), QPainter::drawRects(), QTreeView::drawTree(), QPainterPath::elementCount(), QTextEngine::elidedText(), QTextLayout::endLayout(), QFontEngineMulti::engine(), HoverPoints::eventFilter(), Q3TextDeleteCommand::execute(), QVector< T >::fill(), QX11PaintEnginePrivate::fillPath(), QTextEngine::findItem(), HoverPoints::firePointChange(), fix_color_table(), QRasterPaintEngine::flush(), QPSPrintEnginePrivate::flushPage(), QTextEngine::freeMemory(), QPdf::generateDashes(), QGradientCache::getBuffer(), QDockWidgetLayout::getGrid(), QTextFormatCollection::hasFormatCached(), Parser::hasNext(), hasNext(), QRegExpCharClass::in(), QTextFormatCollection::indexForFormat(), QVector< T >::indexOf(), QTextDocumentPrivate::insert(), Q3TextString::insert(), QVector< T >::insert(), QSortFilterProxyModelPrivate::insert_source_items(), QTextDocumentPrivate::insertBlock(), QGLColormap::isEmpty(), QPainterPath::isEmpty(), QODBCResult::isNull(), QBrush::isOpaque(), QTextEngine::itemize(), QTextDocumentLayoutPrivate::layoutTable(), QTextLayout::lineCount(), QTextLayout::lineForTextPosition(), QFontEngineMultiFT::loadEngine(), QFontEngineMultiXLFD::loadEngine(), Parser::lookup(), QDBusMetaType::marshall(), QRegExpMatchState::matchHere(), Q3ListBox::maxItemWidth(), QTextFormat::merge(), QVector< T >::mid(), PathStrokeRenderer::mouseMoveEvent(), PathStrokeRenderer::mousePressEvent(), QTextHtmlParser::newNode(), Parser::next(), QSubpathFlatIterator::next(), QSqlCachedResultPrivate::nextIndex(), QImage::numColors(), Q3ListBox::numColumns(), Q3ListBox::numItemsVisible(), Q3ListBox::numRows(), operator<<(), QVector< T >::operator[](), PathStrokeRenderer::paint(), PathDeformRenderer::paint(), GradientRenderer::paint(), QTableView::paintEvent(), HoverPoints::paintPoints(), Moc::parse(), parsePen(), parseQPen(), GradientEditor::pointsUpdated(), QStack< T >::pop(), QRegExp::pos(), QRegExpMatchState::prepareForMatch(), Preprocessor::preprocess(), Preprocessor::preprocessed(), QSortFilterProxyModelPrivate::proxy_intervals_for_source_items(), QSortFilterProxyModelPrivate::proxy_intervals_for_source_items_to_add(), Q3CanvasPixmapArray::Q3CanvasPixmapArray(), Q3MemArray< type >::Q3MemArray(), Q3TextDeleteCommand::Q3TextDeleteCommand(), Q3TextFormatCommand::Q3TextFormatCommand(), Q3TextString::Q3TextString(), qGeomCalc(), qt_closestItemFirst(), qt_polygon_trapezoidation(), qt_tesselate_polygon(), qt_XRenderCompositeTrapezoids(), QVector< T >::realloc(), Q3ListBox::refreshSlot(), QSettings::registerFormat(), QDBusMetaType::registerMarshallOperators(), Q3TextString::remove(), QVector< T >::remove(), QSortFilterProxyModelPrivate::remove_source_items(), QGraphicsSceneBspTree::removeItems(), QVector< T >::replace(), TorrentClient::requestBlocks(), QVector< T >::resize(), resolveColor(), QImage::rgbSwapped(), Q3TextDocument::richText(), Q3ListBox::rowAt(), Q3Header::sectionSizeHint(), separatorMove(), set_shade_points(), QPainter::setClipRegion(), QGradient::setColorAt(), QImage::setColorTable(), QPainterPathStroker::setDashPattern(), QPen::setDashPattern(), ShadeWidget::setGradientStops(), GradientEditor::setGradientStops(), QTableModel::setHeaderData(), QImage::setNumColors(), QPdf::Stroker::setPen(), QImage::setPixel(), HoverPoints::setPoints(), Q3TextDocument::setRichTextMarginsInternal(), QGridLayoutPrivate::setSize(), QGradient::setStops(), PathDeformRenderer::setText(), QGridLayoutPrivate::setupHfwLayoutData(), QRegExpEngine::setupState(), QWidgetPrivate::setWindowIcon_sys(), QGLColormap::size(), Q3ListBox::sizeHint(), Preprocessor::skipBranch(), Preprocessor::skipUntilEndif(), QRegExpEngine::startAtom(), QFontEngineMulti::stringToCMap(), Parser::test(), QRegExpMatchState::testAnchor(), QPainterPath::toFillPolygons(), QVector< T >::toList(), QStack< T >::top(), Q3TextString::toString(), QPainterPath::toSubpathPolygons(), QImage::transformed(), Q3TextString::truncate(), QTextDocumentPrivate::truncateUndoStack(), QDBusMetaType::typeToSignature(), QTextDocumentPrivate::undoRedo(), Q3TextFormatCommand::unexecute(), Moc::until(), QMenuBarPrivate::updateGeometries(), PathStrokeRenderer::updatePoints(), QPdfBaseEngine::updateState(), Q3ListBox::viewportPaintEvent(), QTextEngine::width(), QPdfEnginePrivate::writePage(), QPdfEnginePrivate::writePageRoot(), QPdfEnginePrivate::writeTail(), Q3HeaderData::~Q3HeaderData(), Q3TextDeleteCommand::~Q3TextDeleteCommand(), Q3TextFormatCommand::~Q3TextFormatCommand(), QFontEngineMulti::~QFontEngineMulti(), and QPainterPrivate::~QPainterPrivate().
00081 { return d->size; }
| bool QVector< T >::isEmpty | ( | ) | const [inline] |
Returns true if the vector has size 0; otherwise returns false.
Definition at line 83 of file qvector.h.
Referenced by QHeaderViewPrivate::_q_sectionsRemoved(), QSortFilterProxyModelPrivate::_q_sourceDataChanged(), QPainterPath::addPolygon(), QImage::allGray(), QTextDocumentPrivate::appendUndoItem(), Q3ListView::buildDrawableList(), QTreeWidgetItem::clone(), QTreeViewPrivate::collapse(), convert_RGB_to_Indexed8(), QSvgHandler::currentColor(), QPen::dashPattern(), RCCResourceLibrary::dataFiles(), QGraphicsSceneBspTree::debug(), QTextLayout::draw(), QTextLayout::drawCursor(), QTextDocumentLayoutPrivate::drawFlow(), QTextDocumentLayoutPrivate::drawFrame(), QTextHtmlExporter::emitTable(), QTextDocumentLayoutPrivate::ensureLayouted(), QCoreApplication::exec(), ProReader::finalizeBlock(), QVector< QPoint >::first(), QTextEngine::format(), QTextEngine::formatIndex(), Q3TextBrowser::forward(), QTextDocumentLayoutPrivate::frameIteratorForYPosition(), getToken(), Q3TextCursor::gotoPosition(), QSortFilterProxyModelPrivate::handle_filter_changed(), QStyleSheetStyle::hasStyleRule(), QTreeViewPrivate::hasVisibleChildren(), QListViewPrivate::indexToListViewItem(), QTreeWidgetItem::insertChild(), QTreeWidgetItem::insertChildren(), QTreeModel::insertColumns(), QSvgText::insertFormat(), QSvgText::insertText(), QListViewPrivate::intersectingStaticSet(), QPolygonF::isClosed(), QIndexMapper::isEmpty(), QSqlRecord::isEmpty(), QTreeViewPrivate::itemHeight(), QVector< QPoint >::last(), QTextDocumentLayoutPrivate::layoutFlow(), QHeaderViewPrivate::logicalIndex(), Q3TextEdit::optimParseTags(), PathStrokeRenderer::paint(), Rpp::Preprocessor::parse(), QXmlSimpleReaderPrivate::parseBeginOrContinue(), QXmlSimpleReaderPrivate::parseElement(), ProReader::parseline(), parsePathDataFast(), QListViewPrivate::perItemScrollToValue(), QStyleSheetStyle::polish(), Q3TextCursor::pop(), QVector< QPoint >::pop_back(), QVector< QPoint >::pop_front(), QSortFilterProxyModelPrivate::proxy_intervals_for_source_items(), QSortFilterProxyModelPrivate::proxy_intervals_for_source_items_to_add(), QDBusModel::refresh(), QTextEngine::resolveAdditionalFormats(), Q3TextCursor::restoreState(), QTreeViewPrivate::select(), QDockAreaLayoutInfo::separatorMove(), QDockWidgetLayout::separatorMove(), QPen::setDashPattern(), qdesigner_internal::ObjectInspector::setFormWindow(), QStandardItemPrivate::setModel(), QPdf::Stroker::setPen(), Q3TextDocument::setRichTextInternal(), Q3TextBrowser::setSource(), Q3TextBrowser::source(), QSvgHandler::startElement(), QGradient::stops(), QTreeWidgetItem::takeChild(), QTreeWidgetItem::takeChildren(), tokenize(), QTreeViewPrivate::updateScrollBars(), QFontSubset::widthArray(), RCCResourceLibrary::writeDataBlobs(), RCCResourceLibrary::writeDataNames(), RCCResourceLibrary::writeDataStructure(), and QWSSignalHandler::~QWSSignalHandler().
00083 { return d->size == 0; }
| void QVector< T >::resize | ( | int | size | ) |
Sets the size of the vector to size. If size is greater than the current size, elements are added to the end; the new elements are initialized with a {default-constructed value}. If size is less than the current size, elements are removed from the end.
Definition at line 273 of file qvector.h.
References QVector< T >::d, QVectorData::grow(), QVector< T >::realloc(), QVector< T >::size(), and T.
Referenced by QPolygonalProcessor::add(), Q3Header::addLabel(), QRegExpCharClass::addRange(), QPdfEnginePrivate::addXrefEntry(), QRegExpEngine::anchorAlternation(), Q3TextString::appendParagraphs(), Q3CanvasEllipse::areaPoints(), QSqlResult::bindValue(), calcLines(), Q3CanvasItem::chunks(), QRegExpCharClass::clear(), Q3TextString::clear(), QX11PaintEnginePrivate::clipPolygon_dev(), convert_Mono_to_Indexed8(), convert_RGB_to_Indexed8(), convertWithPalette(), QBspTree::create(), QShortcutMap::createNewSequences(), QListViewPrivate::doItemsLayout(), QPolygonalProcessor::doSpans(), QWindowsStyle::drawComplexControl(), QMotifStyle::drawComplexControl(), QMotifStyle::drawPrimitive(), QTextHtmlExporter::emitTable(), QODBCResult::exec(), QVector< T >::fill(), QDockWidgetLayout::getGrid(), QFontSubset::getReverseMap(), QTextEngine::indexAdditionalFormats(), QSqlCachedResultPrivate::init(), QGraphicsSceneBspTree::initialize(), QHeaderViewPrivate::initializeIndexMapping(), Q3TextString::insert(), QTableModel::insertColumns(), QTreeModel::insertColumns(), QStandardItemPrivate::insertColumns(), QTableModel::insertRows(), QStandardItemPrivate::insertRows(), QTreeViewPrivate::layout(), QTextDocumentLayoutPrivate::layoutFlow(), QTextDocumentLayoutPrivate::layoutTable(), QFontEngineMultiFT::loadEngine(), main(), QRegExpMatchState::match(), QRegExpMatchState::matchHere(), QTextHtmlParser::newNode(), QSqlCachedResultPrivate::nextIndex(), operator>>(), QTextHtmlParser::parse(), PolygonRegion(), QStack< T >::pop(), QRegExpMatchState::prepareForMatch(), QListViewPrivate::prepareItemsLayout(), PtsToRegion(), Q3HeaderData::Q3HeaderData(), qt_closestItemFirst(), Index::readDict(), QDBusMetaType::registerMarshallOperators(), QMetaType::registerType(), Q3TextString::remove(), Q3Header::removeLabel(), QODBCResult::reset(), Q3Header::resizeArrays(), Q3TextDocument::richText(), QTextHtmlImporter::scanTable(), QAccessibleListBox::selection(), QAccessibleListView::selection(), QAccessibleIconView::selection(), QDockAreaLayoutInfo::separatorMove(), QRegExpEngine::Box::set(), QTreeModel::setColumnCount(), Q3CanvasSpline::setControlPoints(), QTreeWidgetItem::setData(), QImage::setNumColors(), HoverPoints::setPoints(), QGridLayoutPrivate::setSize(), QRegExpEngine::setup(), QRegExpEngine::startAtom(), QPainterPath::toFillPolygons(), QFontSubset::toTruetype(), QString::toUcs4(), Q3TextString::truncate(), QTextDocumentPrivate::truncateUndoStack(), Q3ListBox::tryGeometry(), UnionRectWithRegion(), QTextTablePrivate::update(), QMenuBarPrivate::updateGeometries(), and Q3TextDeleteCommand::~Q3TextDeleteCommand().
00274 { realloc(asize, (asize > d->alloc || (asize < d->size && asize < (d->alloc >> 1))) ? 00275 QVectorData::grow(sizeof(Data), asize, sizeof(T), QTypeInfo<T>::isStatic) 00276 : d->alloc); }
Here is the call graph for this function:

| int QVector< T >::capacity | ( | ) | const [inline] |
Returns the maximum number of items that can be stored in the vector without forcing a reallocation.
The sole purpose of this function is to provide a means of fine tuning QVector's memory usage. In general, you will rarely ever need to call this function. If you want to know how many items are in the vector, call size().
Definition at line 87 of file qvector.h.
00087 { return d->alloc; }
| void QVector< T >::reserve | ( | int | size | ) |
Attempts to allocate memory for at least size elements. If you know in advance how large the vector will be, you can call this function, and if you call resize() often you are likely to get better performance. If size is an underestimate, the worst that will happen is that the QVector will be a bit slower.
The sole purpose of this function is to provide a means of fine tuning QVector's memory usage. In general, you will rarely ever need to call this function. If you want to change the size of the vector, call resize().
Definition at line 270 of file qvector.h.
References QVector< T >::d, and QVector< T >::realloc().
Referenced by QTableModel::columnItems(), TokenEngine::copy(), QTableModel::ensureSorted(), QListViewPrivate::initDynamicLayout(), Rpp::RppLexer::lex(), CppLexer::lex(), Rpp::Preprocessor::parseTextLine(), Preprocessor::preprocess(), qDrawShadePanel(), QShortcutMapPrivate::QShortcutMapPrivate(), qt_polygon_trapezoidation(), qt_tesselate_polygon(), QTreeWidgetItem::QTreeWidgetItem(), QTextHtmlImporter::scanTable(), QTableModel::sort(), QStandardItemPrivate::sortChildren(), and QPainterPath::toSubpathPolygons().
Here is the call graph for this function:

| void QVector< T >::squeeze | ( | ) | [inline] |
Releases any memory not required to store the items.
The sole purpose of this function is to provide a means of fine tuning QVector's memory usage. In general, you will rarely ever need to call this function.
Definition at line 89 of file qvector.h.
| void QVector< T >::detach | ( | ) | [inline] |
Definition at line 91 of file qvector.h.
Referenced by Q3CanvasPolygonalItem::areaPointsAdvanced(), QVector< QPoint >::begin(), Q3CanvasPolygonalItem::chunks(), QVector< QPoint >::data(), QVector< QPoint >::end(), QVector< T >::erase(), Q3TextString::Q3TextString(), Q3CanvasPolygon::setPoints(), QVector< QPoint >::setSharable(), and QStack< T >::top().
00091 { if (d->ref != 1) detach_helper(); }
| bool QVector< T >::isDetached | ( | ) | const [inline] |
| void QVector< T >::setSharable | ( | bool | sharable | ) | [inline] |
| T * QVector< T >::data | ( | ) | [inline] |
Returns a pointer to the data stored in the vector. The pointer can be used to access and modify the items in the vector.
Example:
The pointer remains valid as long as the vector isn't reallocated.
This function is mostly useful to pass a vector to a function that accepts a plain C++ array.
Definition at line 95 of file qvector.h.
Referenced by Q3TextString::checkBidi(), QDir::cleanPath(), QX11PaintEnginePrivate::clipPolygon_dev(), QPaintEngine::drawEllipse(), QX11PaintEngine::drawPath(), QX11PaintEnginePrivate::fillPath(), Q3TextString::insert(), QMatrix::map(), QRegExpMatchState::match(), QRegExpMatchState::matchHere(), miRegionOp(), Q3TextString::nextCursorPosition(), QVector< T >::operator[](), parsePen(), parseQPen(), QStack< T >::pop(), QRegExpMatchState::prepareForMatch(), Q3TextString::previousCursorPosition(), PtsToRegion(), Q3TextString::remove(), QVector< T >::replace(), QWidgetPrivate::setWindowIcon_sys(), QStack< T >::top(), Q3TextString::toString(), and QString::toUcs4().
| const T * QVector< T >::data | ( | ) | const [inline] |
| const T * QVector< T >::constData | ( | ) | const [inline] |
Returns a const pointer to the data stored in the vector. The pointer can be used to access the items in the vector. The pointer remains valid as long as the vector isn't reallocated.
This function is mostly useful to pass a vector to a function that accepts a plain C++ array.
Definition at line 97 of file qvector.h.
Referenced by QTextEngine::boundingBox(), QFTOutlineMapper::clipElements(), QPainter::drawConvexPolygon(), QPainter::drawLines(), QPainter::drawPoints(), Q3SVGPaintEngine::drawPolygon(), QPainter::drawPolygon(), QPainter::drawPolyline(), QPainter::drawRects(), Ui3Reader::embed(), EqualRegion(), miSetExtents(), qt_XRenderCompositeTrapezoids(), and QTextEngine::width().
00097 { return d->array; }
| void QVector< T >::clear | ( | ) | [inline] |
Removes all the elements from the vector.
Same as resize(0).
Definition at line 278 of file qvector.h.
Referenced by QSyntaxHighlighterPrivate::_q_reformatBlocks(), QSqlCachedResultPrivate::cleanup(), ProReader::cleanup(), QDBusConnectionPrivate::ObjectTreeNode::clear(), QGraphicsSceneBspTree::clear(), QSqlRecord::clear(), QHeaderViewPrivate::clear(), QListViewPrivate::clear(), QSqlRelationalTableModelPrivate::clearChanges(), QSqlResultPrivate::clearIndex(), QShortcutMap::clearSequence(), QSqlResultPrivate::clearValues(), QSqlRecord::clearValues(), QBspTree::destroy(), dither_to_Mono(), QRegExpMatchState::drain(), QMainWindowLayout::endSeparatorMove(), QTreeWidgetItemIteratorPrivate::ensureValidIterator(), Rpp::RppTreeEvaluator::evaluate(), QShortcutMap::find(), QXmlSimpleReaderPrivate::init(), QListViewPrivate::initBspTree(), PathStrokeRenderer::initializePoints(), QListViewPrivate::initStaticLayout(), HelpDialog::insertContents(), QListViewPrivate::intersectingDynamicSet(), QListViewPrivate::intersectingStaticSet(), QTextEngine::invalidate(), QTextDocumentLayoutPrivate::layoutFlow(), QTextDocumentLayoutPrivate::layoutTable(), operator>>(), QTextDocumentLayoutPrivate::pageBreakInsideTable(), QTextHtmlParser::parse(), QRegExpEngine::parse(), QXmlSimpleReaderPrivate::parseBeginOrContinue(), QTextHtmlParser::parseTag(), QSortFilterProxyModelPrivate::proxy_intervals_for_source_items_to_add(), qDrawShadePanel(), QDBusModel::refresh(), QTreeViewPrivate::relayout(), TorrentClient::requestBlocks(), QODBCResult::reset(), QTextEngine::resolveAdditionalFormats(), QBoxLayoutPrivate::setDirty(), QStandardItemPrivate::setItemData(), QSqlRecord::setNull(), HoverPoints::setPoints(), QGradient::setStops(), QPen::setStyle(), PathDeformRenderer::setText(), QBoxLayoutPrivate::setupGeom(), startTokenizer(), QPainterPath::toFillPolygons(), Tokenizer::tokenize(), QPainterPath::toSubpathPolygons(), and QStandardItemPrivate::~QStandardItemPrivate().
00279 { *this = QVector<T>(); }
| const T & QVector< T >::at | ( | int | i | ) | const [inline] |
Returns the item at index position i in the vector.
i must be a valid index position in the vector (i.e., 0 <= i < size()).
Definition at line 281 of file qvector.h.
References QVector< T >::d, and QVector< T >::size().
Referenced by QTreeViewPrivate::_q_endAnimatedOperation(), QHeaderViewPrivate::_q_sectionsRemoved(), QRegExpEngine::Box::addAnchorsToEngine(), QRegExpEngine::addCatTransitions(), QListViewPrivate::addLeaf(), QRegExpEngine::addPlusTransitions(), QPainterPath::addPolygon(), QPainterPath::addRegion(), QImage::allGray(), QRegExpEngine::anchorAlternation(), QRegExpEngine::anchorConcatenation(), QTextHtmlParserNode::applyCssDeclarations(), QSyntaxHighlighterPrivate::applyFormatChanges(), Rpp::MacroFunctionParser::argument(), QTextHtmlParser::at(), QTreeViewPrivate::beginAnimatedOperation(), QTextTableData::calcRowPosition(), TokenEngine::TokenSectionSequence::calculateInternalIndex(), QRegExp::capturedTexts(), QRegExpEngine::Box::cat(), QRegExpEngine::Box::catAnchor(), QTextTableData::cellPosition(), QTextTableData::cellRect(), QTextTableData::cellWidth(), QTableModel::clear(), QTableModel::clearContents(), QPainterPathData::close(), closestMatch(), QTreeViewPrivate::collapse(), QGraphicsItem::collidesWithPath(), QImage::color(), ShadeWidget::colorAt(), QColormap::colorAt(), QStandardItemModelPrivate::columnsRemoved(), QMetaType::construct(), TokenEngine::TokenList::containerIndex(), convert_Indexed8_to_X32(), convert_Mono_to_X32(), QSqlRecordPrivate::createField(), QTextLayout::createLine(), QFontSubset::createToUnicodeMap(), QTreeWidgetItem::data(), QListWidgetItem::data(), QTableWidgetItem::data(), QODBCResult::data(), QSqlCachedResult::data(), QCss::StyleSelector::declarationsForNode(), QAbstractItemModel::decodeData(), QMetaType::destroy(), dither_to_Mono(), QListViewPrivate::doDynamicLayout(), QTextLayout::draw(), QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QTextDocumentLayoutPrivate::drawFrame(), drawLine_midpoint_dashed_i(), XFormView::drawPixmapType(), XFormView::drawTextType(), QTreeView::drawTree(), XFormView::drawVectorType(), QAbstractTableModel::dropMimeData(), QAbstractListModel::dropMimeData(), QPainterPath::elementAt(), QTextHtmlExporter::emitTable(), QTextLayout::endLayout(), QFontEngineMulti::engine(), QListModel::ensureSorted(), QTreeModel::ensureSorted(), QTableModel::ensureSorted(), QGLColormap::entryColor(), QGLColormap::entryRgb(), HoverPoints::eventFilter(), QRegExp::exactMatch(), QTreeViewPrivate::expand(), QShortcutMap::find(), QGLColormap::findNearest(), TokenEngine::TokenSectionSequence::findSection(), CPP::WriteInitialization::findWidget(), QRegExpEngine::finishAtom(), fix_color_table(), QRasterPaintEngine::flush(), QPSPrintEnginePrivate::flushPage(), QTextFormatCollection::format(), QTextEngine::format(), QTextEngine::formatIndex(), TokenEngine::TokenList::fullText(), QPdf::generateDashes(), QFontSubset::getReverseMap(), QTextFormatCollection::hasFormatCached(), QStyleSheetStyle::hasStyleRule(), QTableModel::headerData(), QRegExpEngine::heuristicallyChooseHeuristic(), QRegExpCharClass::in(), QTreeViewPrivate::indentationForItem(), QDBusModel::index(), QTextFormatCollection::indexForFormat(), QRegExp::indexIn(), QSqlRecord::indexOf(), QListViewPrivate::indexToListViewItem(), QListViewPrivate::initDynamicLayout(), QConfFileSettingsPrivate::initFormat(), Q3TextCursor::insert(), QSortFilterProxyModelPrivate::insert_source_items(), QListViewPrivate::insertItem(), QListViewPrivate::intersectingStaticSet(), QPainterPathData::isClosed(), QImage::isGrayscale(), TokenStreamAdapter::TokenStream::isHidden(), QSqlCachedResult::isNull(), QODBCResult::isNull(), QBrush::isOpaque(), QTableModel::item(), QTreeViewPrivate::itemHeight(), QListViewPrivate::itemIndex(), QRegExp::lastIndexIn(), QTreeViewPrivate::layout(), QTextDocumentLayoutPrivate::layoutTable(), Parser::lexem(), Moc::lexemUntil(), QMetaType::load(), QFontEngineMultiXLFD::loadEngine(), QFontEngineMultiFT::loadEngine(), QHeaderViewPrivate::logicalIndex(), TokenStreamAdapter::TokenStream::lookAhead(), Parser::lookup(), main(), QRegExpMatchState::match(), QRegExp::matchedLength(), QRegExpMatchState::matchHere(), QCss::StyleSelector::matchRules(), QTextFormat::merge(), QVector< T >::mid(), QTreeViewPrivate::modelIndex(), PathStrokeRenderer::mousePressEvent(), HoverPoints::movePoint(), Parser::next(), next(), QSubpathFlatIterator::next(), Model::node(), operator<<(), QRegExpEngine::Box::orx(), QTextDocumentLayoutPrivate::pageBreakInsideTable(), PathStrokeRenderer::paint(), GradientRenderer::paint(), QTableView::paintEvent(), HoverPoints::paintPoints(), QRegExpEngine::parse(), parseColorValue(), parseCSStoXMLAttrs(), Rpp::Preprocessor::parseDefineDirective(), Rpp::Preprocessor::parseIfdefLikeDirective(), parseStopNode(), Rpp::Preprocessor::parseUndefDirective(), QListViewPrivate::perItemScrollToValue(), QColormap::pixel(), QImage::pixel(), HoverPoints::pointBoundingRect(), GradientEditor::pointsUpdated(), QRegExp::pos(), QTreeViewPrivate::prepareAnimatedOperation(), Preprocessor::preprocess(), QTextHtmlStyleSelector::previousSiblingNode(), QSortFilterProxyModelPrivate::proxy_intervals_for_source_items(), QSortFilterProxyModelPrivate::proxy_intervals_for_source_items_to_add(), Q3MemArray< type >::Q3MemArray(), qBinarySearch(), QFontEngineMultiFT::QFontEngineMultiFT(), qMetaTypeType_unlocked(), QRenderRule::QRenderRule(), qt_closestItemFirst(), qt_polygon_trapezoidation(), qt_tesselate_polygon(), QTreeViewPrivate::reexpandChildren(), QTreeViewPrivate::relayout(), QSortFilterProxyModelPrivate::remove_source_items(), QSortFilterProxyModel::removeColumns(), QTableModel::removeColumns(), QListViewPrivate::removeItem(), QAbstractItemModelPrivate::removePersistentIndexData(), QSortFilterProxyModel::removeRows(), QTableModel::removeRows(), QWSSignalHandler::removeSemaphore(), QStyleSheetStyle::renderRule(), TorrentClient::requestBlocks(), QTextEngine::resolveAdditionalFormats(), QTextHtmlParser::resolveNode(), QSqlRelationalTableModelPrivate::revertCachedRow(), QImage::rgbSwapped(), QStandardItemModelPrivate::rowsRemoved(), QMetaType::save(), QTextHtmlImporter::scanTable(), QTreeViewPrivate::select(), separatorMove(), QStandardItemPrivate::setChild(), QGradient::setColorAt(), QImage::setColorTable(), QPainterPathStroker::setDashPattern(), QTableWidgetItem::setData(), QTreeWidgetItem::setData(), QListWidgetItem::setData(), ShadeWidget::setGradientStops(), GradientEditor::setGradientStops(), QDockWidgetLayout::setGrid(), QTableModel::setHeaderData(), QTableModel::setHorizontalHeaderItem(), QTableModel::setItem(), QStandardItemPrivate::setModel(), HoverPoints::setPoints(), XFormView::setRotation(), QGradient::setStops(), QRegExpEngine::Box::setupHeuristics(), QTableModel::setVerticalHeaderItem(), QTreeView::sizeHintForColumn(), Preprocessor::skipBranch(), Preprocessor::skipUntilEndif(), QTableModel::sort(), QStandardItemPrivate::sortChildren(), QFontEngineMulti::stringToCMap(), QCss::StyleSelector::styleRulesForNode(), Parser::symbol(), Parser::symbol_lookup(), QTableModel::takeHorizontalHeaderItem(), QTableModel::takeVerticalHeaderItem(), Parser::test(), QRegExpMatchState::testAnchor(), XFormView::timerEvent(), QPainterPath::toFillPolygons(), Parser::token(), QVector< T >::toList(), QPixmapIconEngine::tryMatch(), Rpp::ExpressionBuilder::typeAt(), QMetaType::typeName(), Q3TextFormatCommand::unexecute(), Parser::unquotedLexem(), Moc::until(), XFormView::updateCtrlPoints(), PathStrokeRenderer::updatePoints(), QPdfBaseEngine::updateState(), QTreeViewPrivate::viewIndex(), QPdfEnginePrivate::writePage(), Q3HeaderData::~Q3HeaderData(), QFontEngineMulti::~QFontEngineMulti(), and QPainterPrivate::~QPainterPrivate().
00282 { Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::at", "index out of range"); 00283 return d->array[i]; }
Here is the call graph for this function:

| T & QVector< T >::operator[] | ( | int | i | ) | [inline] |
Returns the item at index position i as a modifiable reference.
i must be a valid index position in the vector (i.e., 0 <= i < size()).
Definition at line 289 of file qvector.h.
References QVector< T >::data(), and QVector< T >::size().
00290 { Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::operator[]", "index out of range"); 00291 return data()[i]; }
Here is the call graph for this function:

| const T & QVector< T >::operator[] | ( | int | i | ) | const [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as at(i).
Definition at line 285 of file qvector.h.
References QVector< T >::d, and QVector< T >::size().
00286 { Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::operator[]", "index out of range"); 00287 return d->array[i]; }
Here is the call graph for this function:

| void QVector< T >::append | ( | const T & | value | ) |
Inserts value at the end of the vector.
Example:
QVector<QString> vector(0); vector.append("one"); vector.append("two"); vector.append("three"); // vector: ["one", "two", three"]
This is the same as calling resize(size() + 1) and assigning value to the new last element in the vector.
This operation is relatively fast, because QVector typically allocates more memory than necessary, so it can grow without reallocating the entire vector each time.
Definition at line 472 of file qvector.h.
References TokenEngine::copy(), QVector< T >::d, QVectorData::grow(), QVector< T >::realloc(), and T.
Referenced by QSortFilterProxyModelPrivate::_q_sourceDataChanged(), QPdfEnginePrivate::addBrushPattern(), QListViewPrivate::addLeaf(), QWSSignalHandler::addSemaphore(), QBezier::addToPolygon(), QIndexMapper::append(), QSqlRecord::append(), QTextDocumentPrivate::appendUndoItem(), qdesigner_internal::arrowHead(), QSqlResult::bindValue(), Rpp::Preprocessor::cleanEscapedNewLines(), Rpp::Preprocessor::cleanTokenRange(), Rpp::RppTreeEvaluator::cloneTokenList(), QTableModel::columnItems(), TokenEngine::copy(), QListViewPrivate::createItems(), QTextLayout::createLine(), QAbstractItemModel::decodeData(), dither_to_Mono(), QListViewPrivate::doStaticLayout(), QTextDocumentLayoutPrivate::drawBlock(), QPdfBaseEnginePrivate::drawTextItem(), QAbstractTableModel::dropMimeData(), QAbstractListModel::dropMimeData(), QTableModel::ensureSorted(), Index::Entry::Entry(), Rpp::RppTreeEvaluator::evaluateDefineDirective(), Rpp::RppTreeEvaluator::evaluateMacro(), Rpp::RppTreeEvaluator::evaluateMacroInternal(), Rpp::RppTreeEvaluator::evaluateText(), Rpp::RppTreeEvaluator::evaluateUndefDirective(), QTreeViewPrivate::expand(), QSortFilterProxyModelPrivate::handle_filter_changed(), QTextFormatCollection::indexForFormat(), QListViewPrivate::initStaticLayout(), QBspTree::insert(), QTreeModel::insertColumns(), QListViewPrivate::intersectingStaticSet(), QTextDocumentLayoutPrivate::layoutFlow(), QTextFormat::lengthVectorProperty(), Rpp::RppLexer::lex(), CppLexer::lex(), Rpp::MacroFunctionParser::MacroFunctionParser(), QPainterPathData::maybeMoveTo(), QPdfEnginePrivate::newPage(), Q3MemArray< type >::operator QVector(), QVector< QPoint >::operator+=(), QVector< QPoint >::operator<<(), QTextDocumentLayoutPrivate::pageBreakInsideTable(), QLineEdit::paintEvent(), QRegExpEngine::parse(), parseAnimateTransformNode(), parseBrushValue(), Rpp::Preprocessor::parseDefineDirective(), Rpp::Preprocessor::parseIncludeDirective(), parseNumbersList(), parsePathDataFast(), parsePercentageList(), Rpp::Preprocessor::parseTextLine(), QSortFilterProxyModelPrivate::proxy_intervals_for_source_items(), QSortFilterProxyModelPrivate::proxy_intervals_for_source_items_to_add(), QVector< QPoint >::push_back(), qAppendItems(), qt_polygon_trapezoidation(), qt_tesselate_polygon(), QTreeViewPrivate::reexpandChildren(), QSettings::registerFormat(), QSortFilterProxyModel::removeColumns(), QSortFilterProxyModel::removeRows(), QTextHtmlParser::resolveParent(), Rpp::RppTreeEvaluator::RppTreeEvaluator(), QCss::Scanner::scan(), QTextHtmlImporter::scanTable(), QTreeModel::setColumnCount(), QTableWidgetItem::setData(), QTreeWidgetItem::setData(), QListWidgetItem::setData(), qdesigner_internal::ObjectInspector::setFormWindow(), QStandardItemPrivate::setItemData(), Index::setupDummyTerm(), QTableModel::sort(), QStandardItemPrivate::sortChildren(), QSortFilterProxyModelPrivate::source_items_about_to_be_removed(), QSortFilterProxyModelPrivate::source_items_inserted(), QPdfPage::streamImage(), Tokenizer::tokenize(), TokenEngine::TokenSectionSequence::TokenSectionSequence(), QBezier::toPolygon(), QImage::transformed(), QMenuBarPrivate::updateGeometries(), and VersionLabel::VersionLabel().
00473 { 00474 const T copy(t); 00475 if (d->ref != 1 || d->size + 1 > d->alloc) 00476 realloc(d->size, QVectorData::grow(sizeof(Data), d->size + 1, sizeof(T), 00477 QTypeInfo<T>::isStatic)); 00478 if (QTypeInfo<T>::isComplex) 00479 new (d->array + d->size) T(copy); 00480 else 00481 d->array[d->size] = copy; 00482 ++d->size; 00483 }
Here is the call graph for this function:

| void QVector< T >::prepend | ( | const T & | value | ) | [inline] |
Inserts value at the beginning of the vector.
Example:
QVector<QString> vector; vector.prepend("one"); vector.prepend("two"); vector.prepend("three"); // vector: ["three", "two", "one"]
This is the same as vector.insert(0, value).
For large vectors, this operation can be slow ({linear time}), because it requires moving all the items in the vector by one position further in memory. If you want a container class that provides a fast prepend() function, use QList or QLinkedList instead.
Definition at line 309 of file qvector.h.
References QVector< T >::begin(), and QVector< T >::insert().
Referenced by QVector< QPoint >::push_front(), and qt_closestItemFirst().
Here is the call graph for this function:

| void QVector< T >::insert | ( | int | i, | |
| const T & | value | |||
| ) | [inline] |
Inserts value at index position i in the vector. If i is 0, the value is prepended to the vector. If i is size(), the value is appended to the vector.
Example:
QVector<QString> vector; vector << "alpha" << "beta" << "delta"; vector.insert(2, "gamma"); // vector: ["alpha", "beta", "gamma", "delta"]
For large vectors, this operation can be slow ({linear time}), because it requires moving all the items at indexes i and above by one position further in memory. If you want a container class that provides a fast insert() function, use QLinkedList instead.
Definition at line 293 of file qvector.h.
References QVector< T >::begin(), and QVector< T >::size().
Referenced by Q3Header::addLabel(), QStandardItemModelPrivate::columnsInserted(), QTableModel::ensureSorted(), HoverPoints::eventFilter(), QVector< QPoint >::insert(), QVector< T >::insert(), QSqlRecord::insert(), QTableModel::insertColumns(), QStandardItemPrivate::insertColumns(), QTableModel::insertRows(), QStandardItemPrivate::insertRows(), QTreeViewPrivate::layout(), main(), QVector< T >::prepend(), QStandardItemModelPrivate::rowsInserted(), QGradient::setColorAt(), QGLColormap::setEntry(), QTableModel::setItem(), and QTextEngine::splitItem().
00294 { Q_ASSERT_X(i >= 0 && i <= d->size, "QVector<T>::insert", "index out of range"); 00295 insert(begin() + i, 1, t); }
Here is the call graph for this function:

| void QVector< T >::insert | ( | int | i, | |
| int | count, | |||
| const T & | value | |||
| ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Inserts count copies of value at index position i in the vector.
Example:
QVector<double> vector; vector << 2.718 << 1.442 << 0.4342; vector.insert(1, 3, 9.9); // vector: [2.718, 9.9, 9.9, 9.9, 1.442, 0.4342]
Definition at line 297 of file qvector.h.
References QVector< T >::begin(), QVector< T >::insert(), and QVector< T >::size().
00298 { Q_ASSERT_X(i >= 0 && i <= d->size, "QVector<T>::insert", "index out of range"); 00299 insert(begin() + i, n, t); }
Here is the call graph for this function:

| void QVector< T >::replace | ( | int | i, | |
| const T & | value | |||
| ) | [inline] |
Replaces the item at index position i with value.
i must be a valid index position in the vector (i.e., 0 <= i < size()).
Definition at line 313 of file qvector.h.
References TokenEngine::copy(), QVector< T >::data(), QVector< T >::size(), and T.
Referenced by QStandardItemPrivate::childDeleted(), QStandardItemPrivate::insertColumns(), QStandardItemPrivate::insertRows(), and QStandardItemPrivate::setChild().
00314 { 00315 Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::replace", "index out of range"); 00316 const T copy(t); 00317 data()[i] = copy; 00318 }
Here is the call graph for this function:

| void QVector< T >::remove | ( | int | i | ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Removes the element at index position i.
Definition at line 305 of file qvector.h.
References QVector< T >::begin(), QVector< T >::erase(), and QVector< T >::size().
Referenced by QHeaderViewPrivate::_q_sectionsRemoved(), QTreeViewPrivate::collapse(), QStandardItemModelPrivate::columnsRemoved(), QTableModel::ensureSorted(), HoverPoints::eventFilter(), QTreeViewPrivate::layout(), main(), QSqlRecord::remove(), QBspTree::remove(), QTableModel::removeColumns(), QTableModel::removeRows(), QWSSignalHandler::removeSemaphore(), QStandardItemModelPrivate::rowsRemoved(), and QTableModel::setItem().
00306 { Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::remove", "index out of range"); 00307 erase(begin() + i, begin() + i + 1); }
Here is the call graph for this function:

| void QVector< T >::remove | ( | int | i, | |
| int | count | |||
| ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Removes count elements from the middle of the vector, starting at index position i.
Definition at line 301 of file qvector.h.
References QVector< T >::begin(), QVector< T >::erase(), and QVector< T >::size().
00302 { Q_ASSERT_X(i >= 0 && n >= 0 && i + n <= d->size, "QVector<T>::remove", "index out of range"); 00303 erase(begin() + i, begin() + i + n); }
Here is the call graph for this function:

Assigns value to all items in the vector. If size is different from -1 (the default), the vector is resized to size size beforehand.
Example:
QVector<QString> vector(3); vector.fill("Yes"); // vector: ["Yes", "Yes", "Yes"] vector.fill("oh", 5); // vector: ["oh", "oh", "oh", "oh", "oh"]
Definition at line 559 of file qvector.h.
References b, TokenEngine::copy(), QVector< T >::d, i, QVector< T >::resize(), QVector< T >::size(), and T.
Referenced by QRegExpCharClass::addCategories(), QRegExpCharClass::addRange(), QRegExpEngine::Box::Box(), QODBCPrivate::clearValues(), QTextHtmlExporter::emitTable(), QRegExp::lastIndexIn(), QTextDocumentLayoutPrivate::layoutTable(), QFontEngineMulti::QFontEngineMulti(), QRegExpCharClass::QRegExpCharClass(), QRegExpMatchState::QRegExpMatchState(), QSyntaxHighlighterPrivate::reformatBlock(), QRegExpCharClass::setNegative(), HoverPoints::setPoints(), QRegExpEngine::setup(), and QRegExpEngine::Box::setupHeuristics().
00560 { 00561 const T copy(from); 00562 resize(asize < 0 ? d->size : asize); 00563 if (d->size) { 00564 T *i = d->array + d->size; 00565 T *b = d->array; 00566 while (i != b) 00567 *--i = copy; 00568 } 00569 return *this; 00570 }
Here is the call graph for this function:

| int QVector< T >::indexOf | ( | const T & | value, | |
| int | from = 0 | |||
| ) | const |
Returns the index position of the first occurrence of value in the vector, searching forward from index position from. Returns -1 if no item matched.
Example:
QVector<QString> vector; vector << "A" << "B" << "C" << "B" << "A"; vector.indexOf("B"); // returns 1 vector.indexOf("B", 1); // returns 1 vector.indexOf("B", 2); // returns 3 vector.indexOf("X"); // returns -1
This function requires the value type to have an implementation of operator==().
Definition at line 592 of file qvector.h.
References QVector< T >::d, n, qMax(), QVector< T >::size(), and T.
Referenced by QStandardItemPrivate::childIndex(), QTreeViewPrivate::collapse(), QGLColormap::find(), QTableModel::index(), QIndexMapper::indexOf(), QTableModel::itemChanged(), QStandardItemModelPrivate::itemChanged(), QDBusModel::parent(), Rpp::Preprocessor::parseDefineDirective(), QTextHtmlStyleSelector::previousSiblingNode(), QBspTree::remove(), QTableModel::removeItem(), and Index::setupDummyTerm().
00593 { 00594 if (from < 0) 00595 from = qMax(from + d->size, 0); 00596 if (from < d->size) { 00597 T* n = d->array + from - 1; 00598 T* e = d->array + d->size; 00599 while (++n != e) 00600 if (*n == t) 00601 return n - d->array; 00602 } 00603 return -1; 00604 }
Here is the call graph for this function:

| int QVector< T >::lastIndexOf | ( | const T & | value, | |
| int | from = -1 | |||
| ) | const |
Returns the index position of the last occurrence of the value value in the vector, searching backward from index position from. If from is -1 (the default), the search starts at the last item. Returns -1 if no item matched.
Example:
QList<QString> vector; vector << "A" << "B" << "C" << "B" << "A"; vector.lastIndexOf("B"); // returns 3 vector.lastIndexOf("B", 3); // returns 3 vector.lastIndexOf("B", 2); // returns 1 vector.lastIndexOf("X"); // returns -1
This function requires the value type to have an implementation of operator==().
Definition at line 607 of file qvector.h.
References b, QVector< T >::d, n, and T.
Referenced by QWSSignalHandler::removeSemaphore().
00608 { 00609 if (from < 0) 00610 from += d->size; 00611 else if (from >= d->size) 00612 from = d->size-1; 00613 if (from >= 0) { 00614 T* b = d->array; 00615 T* n = d->array + from + 1; 00616 while (n != b) { 00617 if (*--n == t) 00618 return n - b; 00619 } 00620 } 00621 return -1; 00622 }
| bool QVector< T >::contains | ( | const T & | value | ) | const |
Returns true if the vector contains an occurrence of value; otherwise returns false.
This function requires the value type to have an implementation of operator==().
Definition at line 625 of file qvector.h.
References b, QVector< T >::d, i, and T.
Referenced by QListViewPrivate::doDynamicLayout(), QListViewPrivate::doStaticLayout(), QPdfBaseEnginePrivate::drawTextItem(), QPSPrintEnginePrivate::flushPage(), QListViewPrivate::indexToListViewItem(), QListViewPrivate::intersectingStaticSet(), PointInRegion(), QPdfPage::streamImage(), and Preprocessor::substituteUntilNewline().
00626 { 00627 T* b = d->array; 00628 T* i = d->array + d->size; 00629 while (i != b) 00630 if (*--i == t) 00631 return true; 00632 return false; 00633 }
| int QVector< T >::count | ( | const T & | value | ) | const |
Returns the number of occurrences of value in the vector.
This function requires the value type to have an implementation of operator==().
Definition at line 636 of file qvector.h.
References b, c, QVector< T >::d, i, and T.
Referenced by QListViewPrivate::addLeaf(), Q3CanvasItem::addToChunks(), QTextHtmlParserNode::applyCssDeclarations(), QSyntaxHighlighterPrivate::applyFormatChanges(), Rpp::MacroFunctionParser::argument(), Rpp::MacroFunctionParser::argumentCount(), Q3TextBrowser::backward(), QTreeViewPrivate::below(), QSqlResult::bindValue(), QSqlResult::boundValueCount(), Skin::calcRegions(), Q3CanvasItem::changeChunks(), Q3TextString::clear(), QTableModel::clear(), QSqlRelationalTableModelPrivate::clearChanges(), QTableModel::clearContents(), QSqlRecord::clearValues(), Q3Canvas::collisions(), QTableModel::columnCount(), QSqlRecordPrivate::contains(), QTreeViewPrivate::coordinateForItem(), QIndexMapper::cost(), TokenEngine::TokenList::count(), QIndexMapper::count(), QSqlRecord::count(), QTextHtmlParser::count(), QListViewPrivate::createItems(), createPolygonNode(), createPolylineNode(), ProFileEvaluator::currentProFile(), QListWidgetItem::data(), QTableWidgetItem::data(), QCss::StyleSelector::declarationsForNode(), QAbstractItemModel::decodeData(), QListViewPrivate::doDynamicLayout(), QListViewPrivate::doItemsLayout(), QListViewPrivate::doStaticLayout(), QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QTextDocumentLayoutPrivate::drawFrame(), QTreeView::drawTree(), QTextHtmlExporter::emitTable(), QSvgHandler::endElement(), QTableModel::ensureSorted(), ProFileEvaluator::evaluateFile(), Rpp::RppTreeEvaluator::evaluateMacroInternal(), QSqlResult::exec(), QShortcutMap::find(), CPP::WriteInitialization::findWidget(), QTreeViewPrivate::firstVisibleItem(), QTextFormatCollection::format(), TokenEngine::TokenList::fullText(), QGradientCache::generateGradientColorTable(), QStyleSheetStyle::hasStyleRule(), QTableModel::headerData(), QTreeViewPrivate::indentationForItem(), QDBusModel::index(), QListViewPrivate::indexToListViewItem(), QListViewPrivate::initDynamicLayout(), QHeaderViewPrivate::initializeIndexMapping(), QTableModel::insertColumns(), QListViewPrivate::insertItem(), QTableModel::insertRows(), QListViewPrivate::intersectingStaticSet(), QMetaType::isRegistered(), QTableModel::isValid(), QTreeViewPrivate::itemAtCoordinate(), QListViewPrivate::itemIndex(), QTextHtmlParser::last(), QTextDocumentLayoutPrivate::layoutTable(), QBspTree::leafCount(), main(), QCss::StyleSelector::matchRules(), QTextFormat::merge(), QTreeViewPrivate::modelIndex(), QListViewPrivate::moveItem(), QTextHtmlParser::newNode(), QTreeViewPrivate::pageDown(), Q3GridView::paintEmptyArea(), Skin::paintEvent(), Rpp::Preprocessor::parse(), parseAnimateTransformNode(), parseColorValue(), parseCSStoXMLAttrs(), Rpp::Preprocessor::parseDefineDirective(), Rpp::Preprocessor::parseIfdefLikeDirective(), Rpp::Preprocessor::parseIfLikeDirective(), parsePathDataFast(), parseStopNode(), parseTransformationMatrix(), Rpp::Preprocessor::parseUndefDirective(), QListViewPrivate::perItemScrollToValue(), QSvgText::popFormat(), QListViewPrivate::prepareItemsLayout(), Q3CanvasPixmapArray::Q3CanvasPixmapArray(), qMetaTypeType_unlocked(), QRenderRule::QRenderRule(), Q3CanvasSpline::recalcPoly(), QTreeViewPrivate::reexpandChildren(), QDBusModel::refresh(), QMetaType::registerType(), QSortFilterProxyModel::removeColumns(), QTableModel::removeColumns(), Q3CanvasItem::removeFromChunks(), QListViewPrivate::removeItem(), QAbstractItemModelPrivate::removePersistentIndexData(), QSortFilterProxyModel::removeRows(), QTableModel::removeRows(), Q3Table::repaintSelections(), QTextEngine::resolveAdditionalFormats(), QTextHtmlParser::resolveParent(), QSqlRelationalTableModelPrivate::revertCachedRow(), QDBusModel::rowCount(), QTableModel::rowCount(), QTextHtmlImporter::scanTable(), QTreeView::scrollContentsBy(), QTreeViewPrivate::select(), separatorMove(), QSvgAnimateTransform::setArgs(), QTableModel::setColumnCount(), Q3CanvasSpline::setControlPoints(), QTableWidgetItem::setData(), QTreeWidgetItem::setData(), QListWidgetItem::setData(), QTextFormatCollection::setDefaultFont(), QTableModel::setHorizontalHeaderItem(), QTableModel::setItem(), QStandardItemPrivate::setModel(), QTableModel::setRowCount(), Q3TextBrowser::setSource(), QTableModel::setVerticalHeaderItem(), QTreeView::sizeHintForColumn(), QTableModel::sort(), QStandardItemPrivate::sortChildren(), QSvgHandler::startElement(), QCss::StyleSelector::styleRulesForNode(), QTableModel::tableIndex(), QTableModel::takeHorizontalHeaderItem(), QTableModel::takeVerticalHeaderItem(), QPixmapIconEngine::tryMatch(), QMetaType::typeName(), QTreeViewPrivate::updateScrollBars(), QTreeViewPrivate::viewIndex(), ProFileEvaluator::visitEndProFile(), CPP::WriteInitialization::writeProperties(), and QTextLine::xToCursor().
00637 { 00638 int c = 0; 00639 T* b = d->array; 00640 T* i = d->array + d->size; 00641 while (i != b) 00642 if (*--i == t) 00643 ++c; 00644 return c; 00645 }
| QVector::iterator QVector< T >::begin | ( | ) | [inline] |
Returns an {STL-style iterator} pointing to the first item in the vector.
Definition at line 190 of file qvector.h.
Referenced by QDBusAdaptorConnector::addAdaptor(), QRegExpEngine::addPlusTransitions(), QListViewPrivate::closestIndex(), QTextDocumentLayoutPrivate::drawFlow(), QListViewPrivate::drawItems(), QListModel::ensureSorted(), QTreeModel::ensureSorted(), QTableModel::ensureSorted(), HoverPoints::firePointChange(), QVector< QPoint >::first(), QTextDocumentLayoutPrivate::frameIteratorForYPosition(), QVector< T >::insert(), QRegion::intersects(), Q3TextCursor::invalidateNested(), QStandardItemPrivate::itemData(), QListViewPrivate::itemsRect(), QTextDocumentLayoutPrivate::layoutFlow(), Rpp::Preprocessor::parseIfLikeDirective(), GradientEditor::pointsUpdated(), QVector< QPoint >::pop_front(), QVector< T >::prepend(), QSortFilterProxyModelPrivate::proxy_intervals_for_source_items(), Index::query(), QTreeViewPrivate::reexpandChildren(), QVector< T >::remove(), QSortFilterProxyModel::removeRows(), QTableModel::setItem(), Index::setupDummyTerm(), QTableModel::sort(), QSortFilterProxyModelPrivate::sort_source_rows(), QStandardItemPrivate::sortChildren(), QCss::StyleSelector::styleRulesForNode(), Q3TextCursor::totalOffsetX(), and Q3TextCursor::totalOffsetY().
| QVector::const_iterator QVector< T >::begin | ( | ) | const [inline] |
| QVector::const_iterator QVector< T >::constBegin | ( | ) | const [inline] |
Returns a const {STL-style iterator} pointing to the first item in the vector.
Definition at line 192 of file qvector.h.
Referenced by QDBusConnectionPrivate::ObjectTreeNode::clear(), createPolygonNode(), createPolylineNode(), QTextDocumentLayoutPrivate::drawFrame(), QTextDocumentLayoutPrivate::hitTest(), QListView::paintEvent(), QTextHtmlParser::parseTag(), Index::query(), QVector< QPoint >::toStdVector(), and QStandardItemPrivate::~QStandardItemPrivate().
00192 { return d->array; }
| QVector::iterator QVector< T >::end | ( | ) | [inline] |
Returns an {STL-style iterator} pointing to the imaginary item after the last item in the vector.
Definition at line 193 of file qvector.h.
Referenced by QDBusAdaptorConnector::addAdaptor(), QRegExpEngine::addPlusTransitions(), QListViewPrivate::closestIndex(), QTextDocumentLayoutPrivate::drawFlow(), QListViewPrivate::drawItems(), QListModel::ensureSorted(), QTreeModel::ensureSorted(), QTableModel::ensureSorted(), HoverPoints::firePointChange(), QTextDocumentLayoutPrivate::frameIteratorForYPosition(), QRegion::intersects(), Q3TextCursor::invalidateNested(), QStandardItemPrivate::itemData(), QListViewPrivate::itemsRect(), QVector< QPoint >::last(), QTextDocumentLayoutPrivate::layoutFlow(), GradientEditor::pointsUpdated(), QVector< QPoint >::pop_back(), QSortFilterProxyModelPrivate::proxy_intervals_for_source_items(), Index::query(), QTreeViewPrivate::reexpandChildren(), QSortFilterProxyModel::removeRows(), QTableModel::setItem(), Index::setupDummyTerm(), QTableModel::sort(), QSortFilterProxyModelPrivate::sort_source_rows(), QStandardItemPrivate::sortChildren(), QCss::StyleSelector::styleRulesForNode(), Q3TextCursor::totalOffsetX(), and Q3TextCursor::totalOffsetY().
| QVector::const_iterator QVector< T >::end | ( | ) | const [inline] |
| QVector::const_iterator QVector< T >::constEnd | ( | ) | const [inline] |
Returns a const {STL-style iterator} pointing to the imaginary item after the last item in the vector.
Definition at line 195 of file qvector.h.
Referenced by QDBusConnectionPrivate::ObjectTreeNode::clear(), createPolygonNode(), createPolylineNode(), QTextDocumentLayoutPrivate::drawFrame(), QTextDocumentLayoutPrivate::hitTest(), QListView::paintEvent(), Index::query(), QVector< QPoint >::toStdVector(), and QStandardItemPrivate::~QStandardItemPrivate().
| Q_TYPENAME QVector< T >::iterator QVector< T >::insert | ( | iterator | before, | |
| int | count, | |||
| const T & | value | |||
| ) |
Inserts count copies of value in front of the item pointed to by the iterator before. Returns an iterator pointing at the first of the inserted items.
Definition at line 487 of file qvector.h.
References b, TokenEngine::copy(), QVector< T >::d, QVectorData::grow(), i, j, QVector< T >::realloc(), and T.
00488 { 00489 int offset = before - d->array; 00490 if (n != 0) { 00491 const T copy(t); 00492 if (d->ref != 1 || d->size + n > d->alloc) 00493 realloc(d->size, QVectorData::grow(sizeof(Data), d->size + n, sizeof(T), 00494 QTypeInfo<T>::isStatic)); 00495 if (QTypeInfo<T>::isStatic) { 00496 T *b = d->array + d->size; 00497 T *i = d->array + d->size + n; 00498 while (i != b) 00499 new (--i) T; 00500 i = d->array + d->size; 00501 T *j = i + n; 00502 b = d->array + offset; 00503 while (i != b) 00504 *--j = *--i; 00505 i = b+n; 00506 while (i != b) 00507 *--i = copy; 00508 } else { 00509 T *b = d->array + offset; 00510 T *i = b + n; 00511 memmove(i, b, (d->size - offset) * sizeof(T)); 00512 while (i != b) 00513 new (--i) T(copy); 00514 } 00515 d->size += n; 00516 } 00517 return d->array + offset; 00518 }
Here is the call graph for this function:

| QVector::iterator QVector< T >::insert | ( | iterator | before, | |
| const T & | value | |||
| ) | [inline] |
| Q_TYPENAME QVector< T >::iterator QVector< T >::erase | ( | iterator | begin, | |
| iterator | end | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Removes all the items from begin up to (but not including) end. Returns an iterator to the same item that end referred to before the call.
Definition at line 521 of file qvector.h.
References b, QVector< T >::d, QVector< T >::detach(), i, l, n, qCopy(), and T.
Referenced by QVector< QPoint >::erase(), Rpp::Preprocessor::parseIfLikeDirective(), QVector< QPoint >::pop_back(), QVector< QPoint >::pop_front(), Index::query(), QTreeViewPrivate::reexpandChildren(), and QVector< T >::remove().
00522 { 00523 int f = abegin - d->array; 00524 int l = aend - d->array; 00525 int n = l - f; 00526 detach(); 00527 if (QTypeInfo<T>::isComplex) { 00528 qCopy(d->array+l, d->array+d->size, d->array+f); 00529 T *i = d->array+d->size; 00530 T* b = d->array+d->size-n; 00531 while (i != b) { 00532 --i; 00533 i->~T(); 00534 } 00535 } else { 00536 memmove(d->array + f, d->array + l, (d->size-l)*sizeof(T)); 00537 } 00538 d->size -= n; 00539 return d->array + f; 00540 }
Here is the call graph for this function:

| QVector::iterator QVector< T >::erase | ( | iterator | pos | ) | [inline] |
| int QVector< T >::count | ( | ) | const [inline] |
| T & QVector< T >::first | ( | ) | [inline] |
Returns a reference to the first item in the vector. This function assumes that the vector isn't empty.
Definition at line 203 of file qvector.h.
Referenced by QPainterPath::addPolygon(), QGraphicsItem::collidesWithPath(), QTextDocumentLayoutPrivate::drawFrame(), QVector< QPoint >::front(), QGradientCache::generateGradientColorTable(), QPolygonF::isClosed(), QPainterPath::isEmpty(), qt_closestItemFirst(), QPainterPath::toFillPolygon(), and QPainterPath::toFillPolygons().
| const T & QVector< T >::first | ( | ) | const [inline] |
| T & QVector< T >::last | ( | ) | [inline] |
Returns a reference to the last item in the vector. This function assumes that the vector isn't empty.
Definition at line 205 of file qvector.h.
Referenced by QTextHtmlParser::applyAttributes(), QVector< QPoint >::back(), QPainterPathData::close(), QTextDocumentLayoutPrivate::drawFlow(), QTextDocumentLayoutPrivate::ensureLayouted(), QTextHtmlImporter::import(), QTextFormatCollection::indexForFormat(), QListViewPrivate::initStaticLayout(), QPainterPathData::isClosed(), QPolygonF::isClosed(), QIndexMapper::last(), QTextDocumentLayoutPrivate::layoutFlow(), QTextDocumentLayoutPrivate::layoutTable(), QPainterPathData::maybeMoveTo(), QTextHtmlParser::newNode(), QTextHtmlParser::parse(), QTextHtmlParser::parseTag(), QTextHtmlParser::resolveNode(), QTextHtmlParser::resolveParent(), tokenize(), QTextTableData::updateTableSize(), QPdfEnginePrivate::writePage(), QPdfEnginePrivate::writeTail(), and QWSSignalHandler::~QWSSignalHandler().
| const T & QVector< T >::last | ( | ) | const [inline] |
| Q_OUTOFLINE_TEMPLATE QVector< T > QVector< T >::mid | ( | int | pos, | |
| int | length = -1 | |||
| ) | const |
Returns a vector whose elements are copied from this vector, starting at position pos. If length is -1 (the default), all elements after pos are copied; otherwise length elements (or all remaining elements if there are less than length elements) are copied.
Definition at line 648 of file qvector.h.
References QVector< T >::at(), TokenEngine::copy(), i, and QVector< T >::size().
00649 { 00650 if (length < 0) 00651 length = size() - pos; 00652 if (pos == 0 && length == size()) 00653 return *this; 00654 QVector<T> copy; 00655 if (pos + length > size()) 00656 length = size() - pos; 00657 for (int i = pos; i < pos + length; ++i) 00658 copy += at(i); 00659 return copy; 00660 }
Here is the call graph for this function:

| Q_OUTOFLINE_TEMPLATE T QVector< T >::value | ( | int | i | ) | const |
Returns the value at index position i in the vector.
If the index i is out of bounds, the function returns a {default-constructed value}. If you are certain that i is within bounds, you can use at() instead, which is slightly faster.
Definition at line 458 of file qvector.h.
References QVector< T >::d, QVector< T >::p, QVectorData::size, and T.
Referenced by QSqlResult::boundValue(), QSqlResult::exec(), QSqlRecord::field(), QSqlRecord::fieldName(), QTableModel::horizontalHeaderItem(), QSqlRecord::isGenerated(), QSqlRecord::isNull(), QTableModel::item(), Q3Header::label(), QTextHtmlImporter::scanTable(), QTableWidgetItem::setData(), QTreeWidgetItem::setData(), QListWidgetItem::setData(), QTableModel::takeItem(), QSqlRelationalTableModelPrivate::translateFieldNames(), QMenuBarPrivate::updateGeometries(), QSqlRecord::value(), and QTableModel::verticalHeaderItem().
00459 { 00460 if (i < 0 || i >= p->size) { 00461 return T(); 00462 } 00463 return d->array[i]; 00464 }
| Q_OUTOFLINE_TEMPLATE T QVector< T >::value | ( | int | i, | |
| const T & | defaultValue | |||
| ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. If the index i is out of bounds, the function returns defaultValue.
Definition at line 466 of file qvector.h.
References QVector< T >::d, QVector< T >::p, and QVectorData::size.
| void QVector< T >::push_back | ( | const T & | value | ) | [inline] |
This function is provided for STL compatibility. It is equivalent to append(value).
Definition at line 226 of file qvector.h.
Referenced by ProFileEvaluator::evaluateFile(), and QPainterPrivate::QPainterPrivate().
| void QVector< T >::push_front | ( | const T & | value | ) | [inline] |
| void QVector< T >::pop_back | ( | ) | [inline] |
This function is provided for STL compatibility. It is equivalent to erase(end() - 1).
Definition at line 228 of file qvector.h.
Referenced by Rpp::Preprocessor::parseIfLikeDirective(), and QXmlSimpleReaderPrivate::processElementEmptyTag().
| void QVector< T >::pop_front | ( | ) | [inline] |
| bool QVector< T >::empty | ( | ) | const [inline] |
This function is provided for STL compatibility. It is equivalent to isEmpty(), returning true if the vector is empty; otherwise returns false.
Definition at line 230 of file qvector.h.
Referenced by QGridLayoutPrivate::addData(), distributeMultiBox(), QDockWidgetLayout::getGrid(), QDirModelPrivate::invalidate(), qGeomCalc(), and QPdfEnginePrivate::writePage().
00231 { return d->size == 0; }
| T & QVector< T >::front | ( | ) | [inline] |
This function is provided for STL compatibility. It is equivalent to first().
Definition at line 232 of file qvector.h.
Referenced by parsePathDataFast().
00232 { return first(); }
| QVector::const_reference QVector< T >::front | ( | ) | const [inline] |
| QVector::reference QVector< T >::back | ( | ) | [inline] |
This function is provided for STL compatibility. It is equivalent to last().
Definition at line 234 of file qvector.h.
Referenced by QPainterPrivate::QPainterPrivate().
00234 { return last(); }
| QVector::const_reference QVector< T >::back | ( | ) | const [inline] |
Appends the items of the other vector to this vector and returns a reference to this vector.
Definition at line 573 of file qvector.h.
References b, QVector< T >::d, i, l, QVector< T >::realloc(), T, and w.
00574 { 00575 int newSize = d->size + l.d->size; 00576 realloc(d->size, newSize); 00577 00578 T *w = d->array + newSize; 00579 T *i = l.d->array + l.d->size; 00580 T *b = l.d->array; 00581 while (i != b) { 00582 if (QTypeInfo<T>::isComplex) 00583 new (--w) T(*--i); 00584 else 00585 *--w = *--i; 00586 } 00587 d->size = newSize; 00588 return *this; 00589 }
Here is the call graph for this function:

| void QVector< T >::operator+= | ( | const T & | value | ) | [inline] |
Returns a QList object with the data contained in this QVector.
Example:
QVector<double> vect; vect << "red" << "green" << "blue" << "black"; QList<double> list = vect.toList(); // list: ["red", "green", "blue", "black"]
Definition at line 663 of file qvector.h.
References QList< T >::append(), QVector< T >::at(), i, and QVector< T >::size().
Referenced by QList< T >::fromVector(), and operator<<().
00664 { 00665 QList<T> result; 00666 for (int i = 0; i < size(); ++i) 00667 result.append(at(i)); 00668 return result; 00669 }
Here is the call graph for this function:

Returns a QVector object with the data contained in list.
Example:
QStringList list; list << "Sven" << "Kim" << "Ola"; QVector<QString> vect = QVector<QString>::fromList(list); // vect: ["Sven", "Kim", "Ola"]
Definition at line 681 of file qvector.h.
References QList< T >::toVector().
00682 { 00683 return list.toVector(); 00684 }
Here is the call graph for this function:

| QVector< T > QVector< T >::fromStdVector | ( | const std::vector< T > & | vector | ) | [inline, static] |
Returns a QVector object with the data contained in vector. The order of the elements in the QVector is the same as in vector.
Example:
std::vector<double> stdvector;
vector.push_back(1.2);
vector.push_back(0.5);
vector.push_back(3.14);
QVector<double> vector = QVector<double>::fromStdVector(stdvector);
Definition at line 253 of file qvector.h.
00254 { QVector<T> tmp; qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
| std::vector< T > QVector< T >::toStdVector | ( | ) | const [inline] |
Returns a std::vector object with the data contained in this QVector. Example:
QVector<double> vector; vector << 1.2 << 0.5 << 3.14; std::vector<double> stdvector = vector.toStdVector();
Definition at line 255 of file qvector.h.
00256 { std::vector<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
| void QVector< T >::detach_helper | ( | ) | [private] |
Definition at line 267 of file qvector.h.
References QVector< T >::d, and QVector< T >::realloc().
Referenced by QVector< QPoint >::detach(), QVector< T >::operator=(), and QVector< QPoint >::QVector().
Here is the call graph for this function:

| QVectorData * QVector< T >::malloc | ( | int | alloc | ) | [inline, private] |
Definition at line 334 of file qvector.h.
Referenced by QVector< T >::QVector(), and QVector< T >::realloc().
00335 { 00336 return static_cast<QVectorData *>(qMalloc(sizeof(Data) + (aalloc - 1) * sizeof(T))); 00337 }
Here is the call graph for this function:

| void QVector< T >::realloc | ( | int | size, | |
| int | alloc | |||
| ) | [private] |
Definition at line 381 of file qvector.h.
References b, QVector< T >::d, QVector< T >::free(), i, j, QVectorData::malloc(), QVector< T >::malloc(), QVector< T >::p, qAtomicSetPtr(), qMemSet(), qRealloc(), QVector< T >::size(), T, and x.
Referenced by QVector< T >::append(), QVector< T >::detach_helper(), QVector< T >::insert(), QVector< T >::operator+=(), QVector< T >::reserve(), QVector< T >::resize(), and QVector< QPoint >::squeeze().
00382 { 00383 T *j, *i, *b; 00384 union { QVectorData *p; Data *d; } x; 00385 x.d = d; 00386 00387 if (QTypeInfo<T>::isComplex && aalloc == d->alloc && d->ref == 1) { 00388 // pure resize 00389 i = d->array + d->size; 00390 j = d->array + asize; 00391 if (i > j) { 00392 while (i-- != j) 00393 i->~T(); 00394 } else { 00395 while (j-- != i) 00396 new (j) T; 00397 } 00398 d->size = asize; 00399 return; 00400 } 00401 00402 if (aalloc != d->alloc || d->ref != 1) { 00403 // (re)allocate memory 00404 if (QTypeInfo<T>::isStatic) { 00405 x.p = malloc(aalloc); 00406 } else if (d->ref != 1) { 00407 x.p = QVectorData::malloc(sizeof(Data), aalloc, sizeof(T), p); 00408 } else { 00409 if (QTypeInfo<T>::isComplex) { 00410 // call the destructor on all objects that need to be 00411 // destroyed when shrinking 00412 if (asize < d->size) { 00413 j = d->array + asize; 00414 i = d->array + d->size; 00415 while (i-- != j) 00416 i->~T(); 00417 i = d->array + asize; 00418 } 00419 } 00420 x.p = p = 00421 static_cast<QVectorData *>(qRealloc(p, sizeof(Data) + (aalloc - 1) * sizeof(T))); 00422 } 00423 x.d->ref.init(1); 00424 x.d->sharable = true; 00425 } 00426 if (QTypeInfo<T>::isComplex) { 00427 if (asize < d->size) { 00428 j = d->array + asize; 00429 i = x.d->array + asize; 00430 } else { 00431 // construct all new objects when growing 00432 i = x.d->array + asize; 00433 j = x.d->array + d->size; 00434 while (i != j) 00435 new (--i) T; 00436 j = d->array + d->size; 00437 } 00438 if (i != j) { 00439 // copy objects from the old array into the new array 00440 b = x.d->array; 00441 while (i != b) 00442 new (--i) T(*--j); 00443 } 00444 } else if (asize > d->size) { 00445 // initialize newly allocated memory to 0 00446 qMemSet(x.d->array + d->size, 0, (asize - d->size) * sizeof(T)); 00447 } 00448 x.d->size = asize; 00449 x.d->alloc = aalloc; 00450 if (d != x.d) { 00451 x.d = qAtomicSetPtr(&d, x.d); 00452 if (!x.d->ref.deref()) 00453 free(x.d); 00454 } 00455 }
Here is the call graph for this function:

Definition at line 369 of file qvector.h.
References b, i, qFree(), T, and x.
Referenced by QVector< T >::operator=(), QVector< T >::realloc(), and QVector< QPoint >::~QVector().
00370 { 00371 if (QTypeInfo<T>::isComplex) { 00372 T* b = x->array; 00373 T* i = b + x->size; 00374 while (i-- != b) 00375 i->~T(); 00376 } 00377 qFree(x); 00378 }
Here is the call graph for this function:

| QDataStream & operator<< | ( | QDataStream & | out, | |
| const QVector< T > & | vector | |||
| ) | [related] |
Writes the vector vector to stream out.
This function requires the value type to implement operator<<().
Definition at line 275 of file qdatastream.h.
00276 { 00277 s << quint32(v.size()); 00278 for (typename QVector<T>::const_iterator it = v.begin(); it != v.end(); ++it) 00279 s << *it; 00280 return s; 00281 }
| QDataStream & operator>> | ( | QDataStream & | in, | |
| QVector< T > & | vector | |||
| ) | [related] |
Reads a vector from stream in into vector.
This function requires the value type to implement operator>>().
Definition at line 260 of file qdatastream.h.
00261 { 00262 v.clear(); 00263 quint32 c; 00264 s >> c; 00265 v.resize(c); 00266 for(quint32 i = 0; i < c; ++i) { 00267 T t; 00268 s >> t; 00269 v[i] = t; 00270 } 00271 return s; 00272 }
QVectorData* QVector< T >::p [private] |
Definition at line 69 of file qvector.h.
Referenced by Q3TextString::clear(), QVector< T >::QVector(), QVector< T >::realloc(), Q3TextString::remove(), Q3TextString::truncate(), and QVector< T >::value().
QVectorTypedData<T>* QVector< T >::d [private] |
Definition at line 69 of file qvector.h.
Referenced by QVector< T >::append(), QVector< T >::at(), QVector< QPoint >::begin(), QVector< QPoint >::capacity(), QVector< QPoint >::constBegin(), QVector< QPoint >::constData(), QVector< QPoint >::constEnd(), QVector< T >::contains(), QVector< T >::count(), QVector< QPoint >::count(), QVector< QPoint >::data(), QVector< QPoint >::detach(), QVector< T >::detach_helper(), QVector< QPoint >::empty(), QVector< QPoint >::end(), QVector< T >::erase(), QVector< T >::fill(), QVector< T >::indexOf(), QVector< T >::insert(), QVector< QPoint >::isDetached(), QVector< QPoint >::isEmpty(), QVector< T >::lastIndexOf(), QVector< T >::operator+=(), QColormap::operator=(), QVector< T >::operator=(), QVector< T >::operator==(), QVector< T >::operator[](), QVector< T >::QVector(), QVector< QPoint >::QVector(), QVector< T >::realloc(), QVector< T >::reserve(), QVector< T >::resize(), QTextFormatCollection::setDefaultFont(), QVector< QPoint >::setSharable(), QVector< QPoint >::size(), QVector< QPoint >::squeeze(), QVector< T >::value(), and QVector< QPoint >::~QVector().
union { ... } [private] |
1.5.1