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 <iterator>#include <list>#endif//#define QT_CHECK_VALUELIST_RANGE#if defined(Q_CC_MSVC)#pragma warning(disable:4284) // "return type for operator -> is not a UDT"#endiftemplate <class T>class QValueListNode{public: QValueListNode( const T& t ) : data( t ) { } QValueListNode() { }#if defined(Q_TEMPLATEDLL) // Workaround MS bug in memory de/allocation in DLL vs. EXE virtual ~QValueListNode() { }#endif QValueListNode<T>* next; QValueListNode<T>* prev; T data;};template<class T>class QValueListIterator{ public: /** * Typedefs */ typedef QValueListNode<T>* 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& reference; /** * Variables */ NodePtr node; /** * Functions */ QValueListIterator() : node( 0 ) {} QValueListIterator( NodePtr p ) : node( p ) {} QValueListIterator( const QValueListIterator<T>& it ) : node( it.node ) {} bool operator==( const QValueListIterator<T>& it ) const { return node == it.node; } bool operator!=( const QValueListIterator<T>& it ) const { return node != it.node; } const T& operator*() const { return node->data; } T& operator*() { return node->data; } // UDT for T = x* // T* operator->() const { return &node->data; } QValueListIterator<T>& operator++() { node = node->next; return *this; } QValueListIterator<T> operator++(int) { QValueListIterator<T> tmp = *this; node = node->next; return tmp; } QValueListIterator<T>& operator--() { node = node->prev; return *this; } QValueListIterator<T> operator--(int) { QValueListIterator<T> tmp = *this; node = node->prev; return tmp; }};template<class T>class QValueListConstIterator{ public: /** * Typedefs */ typedef QValueListNode<T>* 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& reference; /** * Variables */ NodePtr node; /** * Functions */ QValueListConstIterator() : node( 0 ) {} QValueListConstIterator( NodePtr p ) : node( p ) {} QValueListConstIterator( const QValueListConstIterator<T>& it ) : node( it.node ) {} QValueListConstIterator( const QValueListIterator<T>& it ) : node( it.node ) {} bool operator==( const QValueListConstIterator<T>& it ) const { return node == it.node; } bool operator!=( const QValueListConstIterator<T>& it ) const { return node != it.node; } const T& operator*() const { return node->data; } // UDT for T = x* // const T* operator->() const { return &node->data; } QValueListConstIterator<T>& operator++() { node = node->next; return *this; } QValueListConstIterator<T> operator++(int) { QValueListConstIterator<T> tmp = *this; node = node->next; return tmp; } QValueListConstIterator<T>& operator--() { node = node->prev; return *this; } QValueListConstIterator<T> operator--(int) { QValueListConstIterator<T> tmp = *this; node = node->prev; return tmp; }};template <class T>class QValueListPrivate : public QShared{public: /** * Typedefs */ typedef QValueListIterator<T> Iterator; typedef QValueListConstIterator<T> ConstIterator; typedef QValueListNode<T> Node; typedef QValueListNode<T>* NodePtr; typedef size_t size_type; /** * Functions */ QValueListPrivate(); QValueListPrivate( const QValueListPrivate<T>& _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& x ); Iterator remove( Iterator it ); NodePtr find( NodePtr start, const T& x ) const; int findIndex( NodePtr start, const T& x ) const; uint contains( const T& x ) const; uint remove( const T& x ); NodePtr at( size_type i ) const; void clear(); NodePtr node; size_type nodes;};template <class T>Q_INLINE_TEMPLATES QValueListPrivate<T>::QValueListPrivate(){ node = new Node; node->next = node->prev = node; nodes = 0;}template <class T>Q_INLINE_TEMPLATES QValueListPrivate<T>::QValueListPrivate( const QValueListPrivate<T>& _p ) : QShared(){ node = new Node; node->next = node->prev = node; nodes = 0; Iterator b( _p.node->next ); Iterator e( _p.node ); Iterator i( node ); while( b != e ) insert( i, *b++ );}template <class T>Q_INLINE_TEMPLATES QValueListPrivate<T>::~QValueListPrivate() { NodePtr p = node->next; while( p != node ) { NodePtr x = p->next; delete p; p = x; } delete node;}template <class T>Q_INLINE_TEMPLATES Q_TYPENAME QValueListPrivate<T>::Iterator QValueListPrivate<T>::insert( Q_TYPENAME QValueListPrivate<T>::Iterator it, const T& x ){ NodePtr p = new Node( x ); p->next = it.node; p->prev = it.node->prev; it.node->prev->next = p; it.node->prev = p; nodes++; return p;}template <class T>Q_INLINE_TEMPLATES Q_TYPENAME QValueListPrivate<T>::Iterator QValueListPrivate<T>::remove( Q_TYPENAME QValueListPrivate<T>::Iterator it ){ Q_ASSERT ( it.node != node ); NodePtr next = it.node->next; NodePtr prev = it.node->prev; prev->next = next; next->prev = prev; delete it.node; nodes--; return Iterator( next );}template <class T>Q_INLINE_TEMPLATES Q_TYPENAME QValueListPrivate<T>::NodePtr QValueListPrivate<T>::find( Q_TYPENAME QValueListPrivate<T>::NodePtr start, const T& 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 + -
显示快捷键?