qvaluelist-h.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 690 行 · 第 1/2 页

HTML
690
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/include/qvaluelist.h:1 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta name="Translator" content="Cavendish"><meta name="Qt zh_CN Documents Website" content="http://www.qiliang.net/qt"><title>qvaluelist.h包含文件</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; font-family: "Times New Roman" }--></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">主页</font></a> | <a href="classes.html"><font color="#004faf">所有的类</font></a> | <a href="mainclasses.html"><font color="#004faf">主要的类</font></a> | <a href="annotated.html"><font color="#004faf">注释的类</font></a> | <a href="groups.html"><font color="#004faf">分组的类</font></a> | <a href="functions.html"><font color="#004faf">函数</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>qvaluelist.h</h1><p>这里是qvaluelist.h包含文件的所有文本,一字不差。它仅仅用来说明,版权由Trolltech保留。<hr><pre>/****************************************************************************** $Id:  qt/qvaluelist.h   3.0.5   edited Jun 7 04:17 $**** Definition of QValueList 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 QVALUELIST_H#define QVALUELIST_H#ifndef QT_H#include "qtl.h"#include "qshared.h"#include "qdatastream.h"#endif // QT_H#ifndef QT_NO_STL#include &lt;iterator&gt;#include &lt;list&gt;#endif//#define QT_CHECK_VALUELIST_RANGE#if defined(Q_CC_MSVC)#pragma warning(disable:4284) // "return type for operator -&gt; is not a UDT"#endiftemplate &lt;class T&gt;class QValueListNode{public:    QValueListNode( const T&amp; t ) : data( t ) { }    QValueListNode() { }#if defined(Q_TEMPLATEDLL)    // Workaround MS bug in memory de/allocation in DLL vs. EXE    virtual ~QValueListNode() { }#endif    QValueListNode&lt;T&gt;* next;    QValueListNode&lt;T&gt;* prev;    T data;};template&lt;class T&gt;class QValueListIterator{ public:    /**     * Typedefs     */    typedef QValueListNode&lt;T&gt;* NodePtr;#ifndef QT_NO_STL    typedef std::bidirectional_iterator_tag  iterator_category;#endif    typedef T        value_type;    typedef size_t size_type;#ifndef QT_NO_STL    typedef ptrdiff_t  difference_type;#else    typedef int difference_type;#endif    typedef T*   pointer;    typedef T&amp; reference;    /**     * Variables     */    NodePtr node;    /**     * Functions     */    QValueListIterator() : node( 0 ) {}    QValueListIterator( NodePtr p ) : node( p ) {}    QValueListIterator( const QValueListIterator&lt;T&gt;&amp; it ) : node( it.node ) {}    bool operator==( const QValueListIterator&lt;T&gt;&amp; it ) const { return node == it.node; }    bool operator!=( const QValueListIterator&lt;T&gt;&amp; it ) const { return node != it.node; }    const T&amp; operator*() const { return node-&gt;data; }    T&amp; operator*() { return node-&gt;data; }    // UDT for T = x*    // T* operator-&gt;() const { return &amp;node-&gt;data; }    QValueListIterator&lt;T&gt;&amp; operator++() {	node = node-&gt;next;	return *this;    }    QValueListIterator&lt;T&gt; operator++(int) {	QValueListIterator&lt;T&gt; tmp = *this;	node = node-&gt;next;	return tmp;    }    QValueListIterator&lt;T&gt;&amp; operator--() {	node = node-&gt;prev;	return *this;    }    QValueListIterator&lt;T&gt; operator--(int) {	QValueListIterator&lt;T&gt; tmp = *this;	node = node-&gt;prev;	return tmp;    }};template&lt;class T&gt;class QValueListConstIterator{ public:    /**     * Typedefs     */    typedef QValueListNode&lt;T&gt;* NodePtr;#ifndef QT_NO_STL    typedef std::bidirectional_iterator_tag  iterator_category;#endif    typedef T        value_type;    typedef size_t size_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     */    NodePtr node;    /**     * Functions     */    QValueListConstIterator() : node( 0 ) {}    QValueListConstIterator( NodePtr p ) : node( p ) {}    QValueListConstIterator( const QValueListConstIterator&lt;T&gt;&amp; it ) : node( it.node ) {}    QValueListConstIterator( const QValueListIterator&lt;T&gt;&amp; it ) : node( it.node ) {}    bool operator==( const QValueListConstIterator&lt;T&gt;&amp; it ) const { return node == it.node; }    bool operator!=( const QValueListConstIterator&lt;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; }    QValueListConstIterator&lt;T&gt;&amp; operator++() {	node = node-&gt;next;	return *this;    }    QValueListConstIterator&lt;T&gt; operator++(int) {	QValueListConstIterator&lt;T&gt; tmp = *this;	node = node-&gt;next;	return tmp;    }    QValueListConstIterator&lt;T&gt;&amp; operator--() {	node = node-&gt;prev;	return *this;    }    QValueListConstIterator&lt;T&gt; operator--(int) {	QValueListConstIterator&lt;T&gt; tmp = *this;	node = node-&gt;prev;	return tmp;    }};template &lt;class T&gt;class QValueListPrivate     : public QShared{public:    /**     * Typedefs     */    typedef QValueListIterator&lt;T&gt; Iterator;    typedef QValueListConstIterator&lt;T&gt; ConstIterator;    typedef QValueListNode&lt;T&gt; Node;    typedef QValueListNode&lt;T&gt;* NodePtr;    typedef size_t size_type;    /**     * Functions     */    QValueListPrivate();    QValueListPrivate( const QValueListPrivate&lt;T&gt;&amp; _p );    void derefAndDelete() // ### hack to get around hp-cc brain damage    {	if ( deref() )	    delete this;    }#if defined(Q_TEMPLATEDLL)    // Workaround MS bug in memory de/allocation in DLL vs. EXE    virtual#endif    ~QValueListPrivate();    Iterator insert( Iterator it, const T&amp; x );    Iterator remove( Iterator it );    NodePtr find( NodePtr start, const T&amp; x ) const;    int findIndex( NodePtr start, const T&amp; x ) const;    uint contains( const T&amp; x ) const;    uint remove( const T&amp; x );    NodePtr at( size_type i ) const;    void clear();    NodePtr node;    size_type nodes;};template &lt;class T&gt;Q_INLINE_TEMPLATES QValueListPrivate&lt;T&gt;::QValueListPrivate(){    node = new Node; node-&gt;next = node-&gt;prev = node; nodes = 0;}template &lt;class T&gt;Q_INLINE_TEMPLATES QValueListPrivate&lt;T&gt;::QValueListPrivate( const QValueListPrivate&lt;T&gt;&amp; _p )    : QShared(){    node = new Node; node-&gt;next = node-&gt;prev = node; nodes = 0;    Iterator b( _p.node-&gt;next );    Iterator e( _p.node );    Iterator i( node );    while( b != e )	insert( i, *b++ );}template &lt;class T&gt;Q_INLINE_TEMPLATES QValueListPrivate&lt;T&gt;::~QValueListPrivate() {    NodePtr p = node-&gt;next;    while( p != node ) {	NodePtr x = p-&gt;next;	delete p;	p = x;    }    delete node;}template &lt;class T&gt;Q_INLINE_TEMPLATES Q_TYPENAME QValueListPrivate&lt;T&gt;::Iterator QValueListPrivate&lt;T&gt;::insert( Q_TYPENAME QValueListPrivate&lt;T&gt;::Iterator it, const T&amp; x ){    NodePtr p = new Node( x );    p-&gt;next = it.node;    p-&gt;prev = it.node-&gt;prev;    it.node-&gt;prev-&gt;next = p;    it.node-&gt;prev = p;    nodes++;    return p;}template &lt;class T&gt;Q_INLINE_TEMPLATES Q_TYPENAME QValueListPrivate&lt;T&gt;::Iterator QValueListPrivate&lt;T&gt;::remove( Q_TYPENAME QValueListPrivate&lt;T&gt;::Iterator it ){    Q_ASSERT ( it.node != node );    NodePtr next = it.node-&gt;next;    NodePtr prev = it.node-&gt;prev;    prev-&gt;next = next;    next-&gt;prev = prev;    delete it.node;    nodes--;    return Iterator( next );}template &lt;class T&gt;Q_INLINE_TEMPLATES Q_TYPENAME QValueListPrivate&lt;T&gt;::NodePtr QValueListPrivate&lt;T&gt;::find( Q_TYPENAME QValueListPrivate&lt;T&gt;::NodePtr start, const T&amp; x ) const{    ConstIterator first( start );    ConstIterator last( node );    while( first != last) {	if ( *first == x )	    return first.node;	++first;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?