Blame qtools/qgvector.h

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