00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef QPAIR_H
00037 #define QPAIR_H
00038
00039 #ifndef QT_H
00040 #include "qglobal.h"
00041 #include "qdatastream.h"
00042 #endif // QT_H
00043
00044 template <class T1, class T2>
00045 struct QPair
00046 {
00047 typedef T1 first_type;
00048 typedef T2 second_type;
00049
00050 QPair()
00051 : first( T1() ), second( T2() )
00052 {}
00053 QPair( const T1& t1, const T2& t2 )
00054 : first( t1 ), second( t2 )
00055 {}
00056
00057 T1 first;
00058 T2 second;
00059 };
00060
00061 template <class T1, class T2>
00062 Q_INLINE_TEMPLATES bool operator==( const QPair<T1, T2>& x, const QPair<T1, T2>& y )
00063 {
00064 return x.first == y.first && x.second == y.second;
00065 }
00066
00067 template <class T1, class T2>
00068 Q_INLINE_TEMPLATES bool operator<( const QPair<T1, T2>& x, const QPair<T1, T2>& y )
00069 {
00070 return x.first < y.first ||
00071 ( !( y.first < x.first ) && x.second < y.second );
00072 }
00073
00074 template <class T1, class T2>
00075 Q_INLINE_TEMPLATES QPair<T1, T2> qMakePair( const T1& x, const T2& y )
00076 {
00077 return QPair<T1, T2>( x, y );
00078 }
00079
00080 #ifndef QT_NO_DATASTREAM
00081 template <class T1, class T2>
00082 inline QDataStream& operator>>( QDataStream& s, QPair<T1, T2>& p )
00083 {
00084 s >> p.first >> p.second;
00085 return s;
00086 }
00087
00088 template <class T1, class T2>
00089 inline QDataStream& operator<<( QDataStream& s, const QPair<T1, T2>& p )
00090 {
00091 s << p.first << p.second;
00092 return s;
00093 }
00094 #endif
00095
00096 #endif