Blame qtools/qarray.h

Packit Service 50c9f2
/****************************************************************************
Packit Service 50c9f2
** 
Packit Service 50c9f2
**
Packit Service 50c9f2
** Definition of QArray template/macro class
Packit Service 50c9f2
**
Packit Service 50c9f2
** Created : 930906
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 QARRAY_H
Packit Service 50c9f2
#define QARRAY_H
Packit Service 50c9f2
Packit Service 50c9f2
#ifndef QT_H
Packit Service 50c9f2
#include "qgarray.h"
Packit Service 50c9f2
#endif // QT_H
Packit Service 50c9f2
Packit Service 50c9f2
Packit Service 50c9f2
template<class type> class Q_EXPORT QArray : public QGArray
Packit Service 50c9f2
{
Packit Service 50c9f2
public:
Packit Service 50c9f2
    typedef type* Iterator;
Packit Service 50c9f2
    typedef const type* ConstIterator;
Packit Service 50c9f2
    typedef type ValueType;
Packit Service 50c9f2
Packit Service 50c9f2
protected:
Packit Service 50c9f2
    QArray( int, int ) : QGArray( 0, 0 ) {}
Packit Service 50c9f2
Packit Service 50c9f2
public:
Packit Service 50c9f2
    QArray() {}
Packit Service 50c9f2
    QArray( int size ) : QGArray(size*(int)sizeof(type)) {}
Packit Service 50c9f2
    QArray( const QArray<type> &a ) : QGArray(a) {}
Packit Service 50c9f2
   ~QArray() {}
Packit Service 50c9f2
    QArray<type> &operator=(const QArray<type> &a)
Packit Service 50c9f2
				{ return (QArray<type>&)QGArray::assign(a); }
Packit Service 50c9f2
    type *data()    const	{ return (type *)QGArray::data(); }
Packit Service 50c9f2
    uint  nrefs()   const	{ return QGArray::nrefs(); }
Packit Service 50c9f2
    uint  size()    const	{ return QGArray::size()/(int)sizeof(type); }
Packit Service 50c9f2
    uint  count()   const 	{ return size(); }
Packit Service 50c9f2
    bool  isEmpty() const	{ return QGArray::size() == 0; }
Packit Service 50c9f2
    bool  isNull()  const	{ return QGArray::data() == 0; }
Packit Service 50c9f2
    bool  resize( uint size )	{ return QGArray::resize(size*(int)sizeof(type)); }
Packit Service 50c9f2
    bool  truncate( uint pos )	{ return QGArray::resize(pos*(int)sizeof(type)); }
Packit Service 50c9f2
    bool  fill( const type &d, int size = -1 )
Packit Service 50c9f2
	{ return QGArray::fill((char*)&d,size,sizeof(type) ); }
Packit Service 50c9f2
    void  detach()		{ QGArray::detach(); }
Packit Service 50c9f2
    QArray<type>   copy() const
Packit Service 50c9f2
	{ QArray<type> tmp; return tmp.duplicate(*this); }
Packit Service 50c9f2
    QArray<type>& assign( const QArray<type>& a )
Packit Service 50c9f2
	{ return (QArray<type>&)QGArray::assign(a); }
Packit Service 50c9f2
    QArray<type>& assign( const type *a, uint n )
Packit Service 50c9f2
	{ return (QArray<type>&)QGArray::assign((char*)a,n*sizeof(type)); }
Packit Service 50c9f2
    QArray<type>& duplicate( const QArray<type>& a )
Packit Service 50c9f2
	{ return (QArray<type>&)QGArray::duplicate(a); }
Packit Service 50c9f2
    QArray<type>& duplicate( const type *a, uint n )
Packit Service 50c9f2
	{ return (QArray<type>&)QGArray::duplicate((char*)a,n*sizeof(type)); }
Packit Service 50c9f2
    QArray<type>& setRawData( const type *a, uint n )
Packit Service 50c9f2
	{ return (QArray<type>&)QGArray::setRawData((char*)a,
Packit Service 50c9f2
						     n*sizeof(type)); }
Packit Service 50c9f2
    void resetRawData( const type *a, uint n )
Packit Service 50c9f2
	{ QGArray::resetRawData((char*)a,n*sizeof(type)); }
Packit Service 50c9f2
    int	 find( const type &d, uint i=0 ) const
Packit Service 50c9f2
	{ return QGArray::find((char*)&d,i,sizeof(type)); }
Packit Service 50c9f2
    int	 contains( const type &d ) const
Packit Service 50c9f2
	{ return QGArray::contains((char*)&d,sizeof(type)); }
Packit Service 50c9f2
    void sort() { QGArray::sort(sizeof(type)); }
Packit Service 50c9f2
    int  bsearch( const type &d ) const
Packit Service 50c9f2
	{ return QGArray::bsearch((const char*)&d,sizeof(type)); }
Packit Service 50c9f2
    type& operator[]( int i ) const
Packit Service 50c9f2
	{ return (type &)(*(type *)QGArray::at(i*(int)sizeof(type))); }
Packit Service 50c9f2
    type& at( uint i ) const
Packit Service 50c9f2
	{ return (type &)(*(type *)QGArray::at(i*(int)sizeof(type))); }
Packit Service 50c9f2
	 operator const type*() const { return (const type *)QGArray::data(); }
Packit Service 50c9f2
    bool operator==( const QArray<type> &a ) const { return isEqual(a); }
Packit Service 50c9f2
    bool operator!=( const QArray<type> &a ) const { return !isEqual(a); }
Packit Service 50c9f2
    Iterator begin() { return data(); }
Packit Service 50c9f2
    Iterator end() { return data() + size(); }
Packit Service 50c9f2
    ConstIterator begin() const { return data(); }
Packit Service 50c9f2
    ConstIterator end() const { return data() + size(); }
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
Packit Service 50c9f2
#endif // QARRAY_H