|
Packit |
1c1d7e |
/****************************************************************************
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Definition of QGVector class
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Created : 930907
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** This file is part of the tools module of the Qt GUI Toolkit.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** This file may be distributed under the terms of the Q Public License
|
|
Packit |
1c1d7e |
** as defined by Trolltech AS of Norway and appearing in the file
|
|
Packit |
1c1d7e |
** LICENSE.QPL included in the packaging of this file.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** This file may be distributed and/or modified under the terms of the
|
|
Packit |
1c1d7e |
** GNU General Public License version 2 as published by the Free Software
|
|
Packit |
1c1d7e |
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
Packit |
1c1d7e |
** packaging of this file.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
|
Packit |
1c1d7e |
** licenses may use this file in accordance with the Qt Commercial License
|
|
Packit |
1c1d7e |
** Agreement provided with the Software.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
Packit |
1c1d7e |
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
|
Packit |
1c1d7e |
** information about Qt Commercial License Agreements.
|
|
Packit |
1c1d7e |
** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
|
Packit |
1c1d7e |
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Contact info@trolltech.com if any conditions of this licensing are
|
|
Packit |
1c1d7e |
** not clear to you.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
**********************************************************************/
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#ifndef QGVECTOR_H
|
|
Packit |
1c1d7e |
#define QGVECTOR_H
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#ifndef QT_H
|
|
Packit |
1c1d7e |
#include "qcollection.h"
|
|
Packit |
1c1d7e |
#endif // QT_H
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
class Q_EXPORT QGVector : public QCollection // generic vector
|
|
Packit |
1c1d7e |
{
|
|
Packit |
1c1d7e |
friend class QGList; // needed by QGList::toVector
|
|
Packit |
1c1d7e |
public:
|
|
Packit |
1c1d7e |
#ifndef QT_NO_DATASTREAM
|
|
Packit |
1c1d7e |
QDataStream &read( QDataStream & ); // read vector from stream
|
|
Packit |
1c1d7e |
QDataStream &write( QDataStream & ) const; // write vector to stream
|
|
Packit |
1c1d7e |
#endif
|
|
Packit |
1c1d7e |
virtual int compareItems( Item, Item );
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
protected:
|
|
Packit |
1c1d7e |
QGVector(); // create empty vector
|
|
Packit |
1c1d7e |
QGVector( uint size ); // create vector with nullptrs
|
|
Packit |
1c1d7e |
QGVector( const QGVector &v ); // make copy of other vector
|
|
Packit |
1c1d7e |
~QGVector();
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
QGVector &operator=( const QGVector &v ); // assign from other vector
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
Item *data() const { return vec; }
|
|
Packit |
1c1d7e |
uint size() const { return len; }
|
|
Packit |
1c1d7e |
uint count() const { return numItems; }
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
bool insert( uint index, Item ); // insert item at index
|
|
Packit |
1c1d7e |
bool remove( uint index ); // remove item
|
|
Packit |
1c1d7e |
Item take( uint index ); // take out item
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
void clear(); // clear vector
|
|
Packit |
1c1d7e |
bool resize( uint newsize ); // resize vector
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
bool fill( Item, int flen ); // resize and fill vector
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
void sort(); // sort vector
|
|
Packit |
1c1d7e |
int bsearch( Item ) const; // binary search (when sorted)
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
int findRef( Item, uint index ) const; // find exact item in vector
|
|
Packit |
1c1d7e |
int find( Item, uint index ) const; // find equal item in vector
|
|
Packit |
1c1d7e |
uint containsRef( Item ) const; // get number of exact matches
|
|
Packit |
1c1d7e |
uint contains( Item ) const; // get number of equal matches
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
Item at( uint index ) const // return indexed item
|
|
Packit |
1c1d7e |
{
|
|
Packit |
1c1d7e |
#if defined(CHECK_RANGE)
|
|
Packit |
1c1d7e |
if ( index >= len )
|
|
Packit |
1c1d7e |
warningIndexRange( index );
|
|
Packit |
1c1d7e |
#endif
|
|
Packit |
1c1d7e |
return vec[index];
|
|
Packit |
1c1d7e |
}
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
bool insertExpand( uint index, Item ); // insert, expand if necessary
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
void toList( QGList * ) const; // put items in list
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#ifndef QT_NO_DATASTREAM
|
|
Packit |
1c1d7e |
virtual QDataStream &read( QDataStream &, Item & );
|
|
Packit |
1c1d7e |
virtual QDataStream &write( QDataStream &, Item ) const;
|
|
Packit |
1c1d7e |
#endif
|
|
Packit |
1c1d7e |
private:
|
|
Packit |
1c1d7e |
Item *vec;
|
|
Packit |
1c1d7e |
uint len;
|
|
Packit |
1c1d7e |
uint numItems;
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
static void warningIndexRange( uint );
|
|
Packit |
1c1d7e |
};
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
/*****************************************************************************
|
|
Packit |
1c1d7e |
QGVector stream functions
|
|
Packit |
1c1d7e |
*****************************************************************************/
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#ifndef QT_NO_DATASTREAM
|
|
Packit |
1c1d7e |
Q_EXPORT QDataStream &operator>>( QDataStream &, QGVector & );
|
|
Packit |
1c1d7e |
Q_EXPORT QDataStream &operator<<( QDataStream &, const QGVector & );
|
|
Packit |
1c1d7e |
#endif
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#endif // QGVECTOR_H
|