Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 1519

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/include/qmap.h:1 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>qmap.h Include File</title>
<style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qmap.h</h1>

<p>This is the verbatim text of the qmap.h include file. It is provided only for illustration; the copyright remains with Trolltech.
<hr>
<pre>
/****************************************************************************
** $Id:  qt/qmap.h   3.0.2   edited Oct 12 12:18 $
**
** Definition of QMap class
**
** Created : 990406
**
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
**
** This file is part of the tools module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
**   information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/

#ifndef QMAP_H
#define QMAP_H

#ifndef QT_H
#include "qshared.h"
#include "qdatastream.h"
#include "qpair.h"
#include "qtl.h"
#endif // QT_H

#ifndef QT_NO_STL
#include &lt;iterator&gt;
#include &lt;map&gt;
#endif

//#define QT_CHECK_MAP_RANGE

struct QMapNodeBase
{
    enum Color { Red, Black };

    QMapNodeBase* left;
    QMapNodeBase* right;
    QMapNodeBase* parent;

    Color color;

    QMapNodeBase* minimum() {
	QMapNodeBase* x = this;
	while ( x-&gt;left )
	    x = x-&gt;left;
	return x;
    }

    QMapNodeBase* maximum() {
	QMapNodeBase* x = this;
	while ( x-&gt;right )
	    x = x-&gt;right;
	return x;
    }
};


template &lt;class K, class T&gt;
struct QMapNode : public QMapNodeBase
{
    QMapNode( const K&amp; _key, const T&amp; _data ) { data = _data; key = _key; }
    QMapNode( const K&amp; _key )	   { key = _key; }
    QMapNode( const QMapNode&lt;K,T&gt;&amp; _n ) { key = _n.key; data = _n.data; }
    QMapNode() { }
    T data;
    K key;
};


template&lt;class K, class T&gt;
class Q_EXPORT QMapIterator
{
 public:
    /**
     * Typedefs
     */
    typedef QMapNode&lt; K, T &gt;* NodePtr;
#ifndef QT_NO_STL
    typedef std::bidirectional_iterator_tag  iterator_category;
#endif
    typedef T          value_type;
#ifndef QT_NO_STL
    typedef ptrdiff_t  difference_type;
#else
    typedef int difference_type;
#endif
    typedef T*         pointer;
    typedef T&amp;         reference;

    /**
     * Variables
     */
    QMapNode&lt;K,T&gt;* node;

    /**
     * Functions
     */
    QMapIterator() : node( 0 ) {}
    QMapIterator( QMapNode&lt;K,T&gt;* p ) : node( p ) {}
    QMapIterator( const QMapIterator&lt;K,T&gt;&amp; it ) : node( it.node ) {}

    bool operator==( const QMapIterator&lt;K,T&gt;&amp; it ) const { return node == it.node; }
    bool operator!=( const QMapIterator&lt;K,T&gt;&amp; it ) const { return node != it.node; }
    T&amp; operator*() { return node-&gt;data; }
    const T&amp; operator*() const { return node-&gt;data; }
    // UDT for T = x*
    // T* operator-&gt;() const { return &amp;node-&gt;data; }

    const K&amp; key() const { return node-&gt;key; }
    T&amp; data() { return node-&gt;data; }
    const T&amp; data() const { return node-&gt;data; }

private:
    int inc() {
	QMapNodeBase* tmp = node;
	if ( tmp-&gt;right ) {
	    tmp = tmp-&gt;right;
	    while ( tmp-&gt;left )
		tmp = tmp-&gt;left;
	} else {
	    QMapNodeBase* y = tmp-&gt;parent;
	    while (tmp == y-&gt;right) {
		tmp = y;
		y = y-&gt;parent;
	    }
	    if (tmp-&gt;right != y)
		tmp = y;
	}
	node = (NodePtr)tmp;
	return 0;
    }

    int dec() {
	QMapNodeBase* tmp = node;
	if (tmp-&gt;color == QMapNodeBase::Red &amp;&amp;
	    tmp-&gt;parent-&gt;parent == tmp ) {
	    tmp = tmp-&gt;right;
	} else if (tmp-&gt;left != 0) {
	    QMapNodeBase* y = tmp-&gt;left;
	    while ( y-&gt;right )
		y = y-&gt;right;
	    tmp = y;
	} else {
	    QMapNodeBase* y = tmp-&gt;parent;
	    while (tmp == y-&gt;left) {
		tmp = y;
		y = y-&gt;parent;
	    }
	    tmp = y;
	}
	node = (NodePtr)tmp;
	return 0;
    }

public:
    QMapIterator&lt;K,T&gt;&amp; operator++() {
	inc();
	return *this;
    }

    QMapIterator&lt;K,T&gt; operator++(int) {
	QMapIterator&lt;K,T&gt; tmp = *this;
	inc();
	return tmp;
    }

    QMapIterator&lt;K,T&gt;&amp; operator--() {
	dec();
	return *this;
    }

    QMapIterator&lt;K,T&gt; operator--(int) {
	QMapIterator&lt;K,T&gt; tmp = *this;
	dec();
	return tmp;
    }
};

template&lt;class K, class T&gt;
class Q_EXPORT QMapConstIterator
{
 public:
    /**
     * Typedefs
     */
    typedef QMapNode&lt; K, T &gt;* NodePtr;
#ifndef QT_NO_STL
    typedef std::bidirectional_iterator_tag  iterator_category;
#endif
    typedef T          value_type;
#ifndef QT_NO_STL
    typedef ptrdiff_t  difference_type;
#else
    typedef int difference_type;
#endif
    typedef const T*   pointer;
    typedef const T&amp;   reference;


    /**
     * Variables
     */
    QMapNode&lt;K,T&gt;* node;

    /**
     * Functions
     */
    QMapConstIterator() : node( 0 ) {}
    QMapConstIterator( QMapNode&lt;K,T&gt;* p ) : node( p ) {}
    QMapConstIterator( const QMapConstIterator&lt;K,T&gt;&amp; it ) : node( it.node ) {}
    QMapConstIterator( const QMapIterator&lt;K,T&gt;&amp; it ) : node( it.node ) {}

    bool operator==( const QMapConstIterator&lt;K,T&gt;&amp; it ) const { return node == it.node; }
    bool operator!=( const QMapConstIterator&lt;K,T&gt;&amp; it ) const { return node != it.node; }
    const T&amp; operator*()  const { return node-&gt;data; }
    // UDT for T = x*
    // const T* operator-&gt;() const { return &amp;node-&gt;data; }

    const K&amp; key() const { return node-&gt;key; }
    const T&amp; data() const { return node-&gt;data; }

private:
    int inc() {
	QMapNodeBase* tmp = node;
	if ( tmp-&gt;right ) {
	    tmp = tmp-&gt;right;
	    while ( tmp-&gt;left )
		tmp = tmp-&gt;left;
	} else {
	    QMapNodeBase* y = tmp-&gt;parent;
	    while (tmp == y-&gt;right) {
		tmp = y;
		y = y-&gt;parent;
	    }
	    if (tmp-&gt;right != y)
		tmp = y;
	}
	node = (NodePtr)tmp;
	return 0;
    }

    int dec() {
	QMapNodeBase* tmp = node;
	if (tmp-&gt;color == QMapNodeBase::Red &amp;&amp;
	    tmp-&gt;parent-&gt;parent == tmp ) {
	    tmp = tmp-&gt;right;
	} else if (tmp-&gt;left != 0) {
	    QMapNodeBase* y = tmp-&gt;left;
	    while ( y-&gt;right )
		y = y-&gt;right;
	    tmp = y;
	} else {
	    QMapNodeBase* y = tmp-&gt;parent;
	    while (tmp == y-&gt;left) {
		tmp = y;
		y = y-&gt;parent;
	    }
	    tmp = y;
	}
	node = (NodePtr)tmp;
	return 0;
    }

public:
    QMapConstIterator&lt;K,T&gt;&amp; operator++() {
	inc();
	return *this;
    }

    QMapConstIterator&lt;K,T&gt; operator++(int) {
	QMapConstIterator&lt;K,T&gt; tmp = *this;
	inc();
	return tmp;
    }

    QMapConstIterator&lt;K,T&gt;&amp; operator--() {
	dec();
	return *this;
    }

    QMapConstIterator&lt;K,T&gt; operator--(int) {
	QMapConstIterator&lt;K,T&gt; tmp = *this;
	dec();
	return tmp;
    }
};


class Q_EXPORT QMapPrivateBase : public QShared
{
public:
    QMapPrivateBase() {
	node_count = 0;
    }
    QMapPrivateBase( const QMapPrivateBase* _map) {
	node_count = _map-&gt;node_count;
    }

    /**
     * Implementations of basic tree algorithms
     */
    void rotateLeft( QMapNodeBase* x, QMapNodeBase*&amp; root);
    void rotateRight( QMapNodeBase* x, QMapNodeBase*&amp; root );
    void rebalance( QMapNodeBase* x, QMapNodeBase*&amp; root );
    QMapNodeBase* removeAndRebalance( QMapNodeBase* z, QMapNodeBase*&amp; root,
				      QMapNodeBase*&amp; leftmost,
				      QMapNodeBase*&amp; rightmost );

    /**
     * Variables
     */
    int node_count;
};


template &lt;class Key, class T&gt;
class QMapPrivate : public QMapPrivateBase
{
public:
    /**
     * Typedefs
     */
    typedef QMapIterator&lt; Key, T &gt; Iterator;
    typedef QMapConstIterator&lt; Key, T &gt; ConstIterator;
    typedef QMapNode&lt; Key, T &gt; Node;
    typedef QMapNode&lt; Key, T &gt;* NodePtr;

    /**
     * Functions
     */
    QMapPrivate() {
	header = new Node;
	header-&gt;color = QMapNodeBase::Red; // Mark the header
	header-&gt;parent = 0;
	header-&gt;left = header-&gt;right = header;
    }
    QMapPrivate( const QMapPrivate&lt; Key, T &gt;* _map ) : QMapPrivateBase( _map ) {
	header = new Node;
	header-&gt;color = QMapNodeBase::Red; // Mark the header
	if ( _map-&gt;header-&gt;parent == 0 ) {
	    header-&gt;parent = 0;
	    header-&gt;left = header-&gt;right = header;
	} else {
	    header-&gt;parent = copy( (NodePtr)(_map-&gt;header-&gt;parent) );
	    header-&gt;parent-&gt;parent = header;
	    header-&gt;left = header-&gt;parent-&gt;minimum();
	    header-&gt;right = header-&gt;parent-&gt;maximum();
	}
    }
    ~QMapPrivate() { clear(); delete header; }

    NodePtr copy( NodePtr p ) {
	if ( !p )
	    return 0;
	NodePtr n = new Node( *p );
	n-&gt;color = p-&gt;color;
	if ( p-&gt;left ) {
	    n-&gt;left = copy( (NodePtr)(p-&gt;left) );
	    n-&gt;left-&gt;parent = n;
	} else {
	    n-&gt;left = 0;
	}
	if ( p-&gt;right ) {
	    n-&gt;right = copy( (NodePtr)(p-&gt;right) );
	    n-&gt;right-&gt;parent = n;
	} else {
	    n-&gt;right = 0;
	}
	return n;
    }

    void clear() {
	clear( (NodePtr)(header-&gt;parent) );
	header-&gt;color = QMapNodeBase::Red;
	header-&gt;parent = 0;
	header-&gt;left = header-&gt;right = header;
	node_count = 0;
    }

    void clear( NodePtr p ) {
	while ( p != 0 ) {
	    clear( (NodePtr)p-&gt;right );
	    NodePtr y = (NodePtr)p-&gt;left;
	    delete p;
	    p = y;
	}
    }

    Iterator begin()	{ return Iterator( (NodePtr)(header-&gt;left ) ); }
    Iterator end()	{ return Iterator( header ); }
    ConstIterator begin() const { return ConstIterator( (NodePtr)(header-&gt;left ) ); }
    ConstIterator end() const { return ConstIterator( header ); }

    ConstIterator find(const Key&amp; k) const {
	QMapNodeBase* y = header;        // Last node
	QMapNodeBase* x = header-&gt;parent; // Root node.

	while ( x != 0 ) {
	    // If as k &lt;= key(x) go left
	    if ( !( key(x) &lt; k ) ) {
		y = x;
		x = x-&gt;left;
	    } else {
		x = x-&gt;right;
	    }
	}

	// Was k bigger/smaller then the biggest/smallest
	// element of the tree ? Return end()
	if ( y == header || k &lt; key(y) )
	    return ConstIterator( header );
	return ConstIterator( (NodePtr)y );
    }

    void remove( Iterator it ) {
	NodePtr del = (NodePtr) removeAndRebalance( it.node, header-&gt;parent, header-&gt;left, header-&gt;right );
	delete del;
	--node_count;
    }

#ifdef QT_QMAP_DEBUG
    void inorder( QMapNodeBase* x = 0, int level = 0 ){
	if ( !x )
	    x = header-&gt;parent;
	if ( x-&gt;left )
	    inorder( x-&gt;left, level + 1 );
    //cout &lt;&lt; level &lt;&lt; " Key=" &lt;&lt; key(x) &lt;&lt; " Value=" &lt;&lt; ((NodePtr)x)-&gt;data &lt;&lt; endl;
	if ( x-&gt;right )
	    inorder( x-&gt;right, level + 1 );
    }
#endif

#if 0
    Iterator insertMulti(const Key&amp; v){
	QMapNodeBase* y = header;
	QMapNodeBase* x = header-&gt;parent;
	while (x != 0){
	    y = x;
	    x = ( v &lt; key(x) ) ? x-&gt;left : x-&gt;right;
	}
	return insert(x, y, v);
    }
#endif

    Iterator insertSingle( const Key&amp; k ) {
	// Search correct position in the tree
	QMapNodeBase* y = header;
	QMapNodeBase* x = header-&gt;parent;
	bool result = TRUE;
	while ( x != 0 ) {
	    result = ( k &lt; key(x) );
	    y = x;
	    x = result ? x-&gt;left : x-&gt;right;
	}
	// Get iterator on the last not empty one
	Iterator j( (NodePtr)y );
	if ( result ) {
	    // Smaller then the leftmost one ?
	    if ( j == begin() ) {
		return insert(x, y, k );
	    } else {
		// Perhaps daddy is the right one ?
		--j;
	    }
	}
	// Really bigger ?
	if ( (j.node-&gt;key) &lt; k )
	    return insert(x, y, k );
	// We are going to replace a node
	return j;
    }

    Iterator insert( QMapNodeBase* x, QMapNodeBase* y, const Key&amp; k ) {
	NodePtr z = new Node( k );
	if (y == header || x != 0 || k &lt; key(y) ) {
	    y-&gt;left = z;                // also makes leftmost = z when y == header
	    if ( y == header ) {
		header-&gt;parent = z;
		header-&gt;right = z;
	    } else if ( y == header-&gt;left )
		header-&gt;left = z;           // maintain leftmost pointing to min node
	} else {
	    y-&gt;right = z;
	    if ( y == header-&gt;right )
		header-&gt;right = z;          // maintain rightmost pointing to max node
	}
	z-&gt;parent = y;
	z-&gt;left = 0;
	z-&gt;right = 0;
	rebalance( z, header-&gt;parent );
	++node_count;
	return Iterator(z);
    }

protected:
    /**
     * Helpers
     */
    const Key&amp; key( QMapNodeBase* b ) const { return ((NodePtr)b)-&gt;key; }

    /**
     * Variables
     */
    NodePtr header;
};

#ifdef QT_CHECK_RANGE
# if !defined( QT_NO_DEBUG ) &amp;&amp; defined( QT_CHECK_MAP_RANGE )
#  define QT_CHECK_INVALID_MAP_ELEMENT if ( empty() ) qWarning( "QMap: Warning invalid element" )
#  define QT_CHECK_INVALID_MAP_ELEMENT_FATAL Q_ASSERT( !empty() );
# else
#  define QT_CHECK_INVALID_MAP_ELEMENT
#  define QT_CHECK_INVALID_MAP_ELEMENT_FATAL
# endif
#else
# define QT_CHECK_INVALID_MAP_ELEMENT
# define QT_CHECK_INVALID_MAP_ELEMENT_FATAL
#endif

template&lt;class Key, class T&gt;
class Q_EXPORT QMap
{
public:
    /**
     * Typedefs
     */
    typedef Key key_type;
    typedef T mapped_type;
    typedef QPair&lt;const key_type, mapped_type&gt; value_type;
    typedef value_type* pointer;
    typedef const value_type* const_pointer;
    typedef value_type&amp; reference;
    typedef const value_type&amp; const_reference;
#ifndef QT_NO_STL
    typedef ptrdiff_t  difference_type;
#else
    typedef int difference_type;
#endif
    typedef size_t      size_type;
    typedef QMapIterator&lt;Key,T&gt; iterator;
    typedef QMapConstIterator&lt;Key,T&gt; const_iterator;

    /**
     * API
     */
    QMap()
    {
	sh = new QMapPrivate&lt; Key, T &gt;;
    }
    QMap( const QMap&lt;Key,T&gt;&amp; m )
    {
	sh = m.sh; sh-&gt;ref();
    }

#ifndef QT_NO_STL
    QMap( const Q_TYPENAME std::map&lt;Key,T&gt;&amp; m )
    {
	sh = new QMapPrivate&lt;Key,T&gt;;
#if defined(Q_OS_WIN32)
	std::map&lt;Key,T&gt;::const_iterator it = m.begin();
#else
	QMapConstIterator&lt;Key,T&gt; it = m.begin();
#endif
	for ( ; it != m.end(); ++it ) {
	    value_type p( (*it).first, (*it).second );
	    insert( p );
	}
    }
#endif
    ~QMap()
    {
	if ( sh-&gt;deref() )
	    delete sh;
    }
    QMap&lt;Key,T&gt;&amp; operator= ( const QMap&lt;Key,T&gt;&amp; m )
    {
	m.sh-&gt;ref();
	if ( sh-&gt;deref() )
	    delete sh;
	sh = m.sh;
	return *this;
    }
#ifndef QT_NO_STL
    QMap&lt;Key,T&gt;&amp; operator= ( const Q_TYPENAME std::map&lt;Key,T&gt;&amp; m )
    {
	clear();
#if defined(Q_OS_WIN32)
	std::map&lt;Key,T&gt;::const_iterator it = m.begin();
#else
	QMapConstIterator&lt;Key,T&gt; it = m.begin();
#endif
	for ( ; it != m.end(); ++it ) {
	    value_type p( (*it).first, (*it).second );
	    insert( p );
	}
	return *this;
    }
#endif

    iterator begin()
    {
	detach();
	return sh-&gt;begin();
    }
    iterator end()
    {
	detach();
	return sh-&gt;end();
    }
    const_iterator begin() const
    {
	return ((const Priv*)sh)-&gt;begin();
    }
    const_iterator end() const
    {
	return ((const Priv*)sh)-&gt;end();
    }
    iterator replace( const Key&amp; k, const T&amp; v )
    {
	remove( k );
	return insert( k, v );
    }

    size_type size() const
    {
	return sh-&gt;node_count;
    }
    bool empty() const
    {
	return sh-&gt;node_count == 0;
    }
    QPair&lt;iterator,bool&gt; insert( const value_type&amp; x )
    {
	detach();
	size_type n = size();
	iterator it = sh-&gt;insertSingle( x.first );
	bool inserted = FALSE;
	if ( n &lt; size() ) {
	    inserted = TRUE;
	    it.data() = x.second;
	}
	return QPair&lt;iterator,bool&gt;( it, inserted );
    }
    void erase( iterator it )
    {
	detach();
	sh-&gt;remove( it );
    }
    void erase( const key_type&amp; k )
    {
	detach();
	iterator it( sh-&gt;find( k ).node );
	if ( it != end() )
	    sh-&gt;remove( it );
    }
    size_type count( const key_type&amp; k ) const
    {
	const_iterator it( sh-&gt;find( k ).node );
	if ( it != end() ) {
	    size_type c = 0;
	    while ( it != end() ) {
		++it;
		++c;
	    }
	    return c;
	}
	return 0;
    }

    T&amp; operator[] ( const Key&amp; k )
    {
	detach();
	QMapNode&lt;Key,T&gt;* p = sh-&gt;find( k ).node;
	if ( p != sh-&gt;end().node )
	    return p-&gt;data;
	return insert( k, T() ).data();
    }

    void clear()
    {
	if ( sh-&gt;count == 1 )
	    sh-&gt;clear();
	else {
	    sh-&gt;deref();
	    sh = new QMapPrivate&lt;Key,T&gt;;
	}
    }

    typedef QMapIterator&lt; Key, T &gt; Iterator;
    typedef QMapConstIterator&lt; Key, T &gt; ConstIterator;
    typedef T ValueType;
    typedef QMapPrivate&lt; Key, T &gt; Priv;

    iterator find ( const Key&amp; k )
    {
	detach();
	return iterator( sh-&gt;find( k ).node );
    }
    const_iterator find ( const Key&amp; k ) const {	return sh-&gt;find( k ); }

    const T&amp; operator[] ( const Key&amp; k ) const
	{ QT_CHECK_INVALID_MAP_ELEMENT; return sh-&gt;find( k ).data(); }
    bool contains ( const Key&amp; k ) const
	{ return find( k ) != end(); }
	//{ return sh-&gt;find( k ) != ((const Priv*)sh)-&gt;end(); }

    size_type count() const { return sh-&gt;node_count; }

    bool isEmpty() const { return sh-&gt;node_count == 0; }


    iterator insert( const Key&amp; key, const T&amp; value, bool overwrite = TRUE ) {
	detach();
	size_type n = size();
	iterator it = sh-&gt;insertSingle( key );
	if ( overwrite || n &lt; size() )
	    it.data() = value;
	return it;
    }

    void remove( iterator it ) { detach(); sh-&gt;remove( it ); }
    void remove( const Key&amp; k ) {
	detach();
	iterator it( sh-&gt;find( k ).node );
	if ( it != end() )
	    sh-&gt;remove( it );
    }

#if defined(Q_FULL_TEMPLATE_INSTANTIATION)
    bool operator==( const QMap&lt;Key,T&gt;&amp; ) const { return FALSE; }
#ifndef QT_NO_STL
    bool operator==( const Q_TYPENAME std::map&lt;Key,T&gt;&amp; ) const { return FALSE; }
#endif
#endif

protected:
    /**
     * Helpers
     */
    void detach() { if ( sh-&gt;count &gt; 1 ) { sh-&gt;deref(); sh = new QMapPrivate&lt;Key,T&gt;( sh ); } }

    Priv* sh;
};


#ifndef QT_NO_DATASTREAM
template&lt;class Key, class T&gt;
inline QDataStream&amp; operator&gt;&gt;( QDataStream&amp; s, QMap&lt;Key,T&gt;&amp; m ) {
    m.clear();
    Q_UINT32 c;
    s &gt;&gt; c;
    for( Q_UINT32 i = 0; i &lt; c; ++i ) {
	Key k; T t;
	s &gt;&gt; k &gt;&gt; t;
	m.insert( k, t );
    }
    return s;
}


template&lt;class Key, class T&gt;
inline QDataStream&amp; operator&lt;&lt;( QDataStream&amp; s, const QMap&lt;Key,T&gt;&amp; m ) {
    s &lt;&lt; (Q_UINT32)m.size();
    QMapConstIterator&lt;Key,T&gt; it = m.begin();
    for( ; it != m.end(); ++it )
	s &lt;&lt; it.key() &lt;&lt; it.data();
    return s;
}
#endif

#endif // QMAP_H
</pre>
<!-- eof -->
<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>