Nepomuk
util.h
Go to the documentation of this file.
00001 /* 00002 This file is part of the Nepomuk KDE project. 00003 Copyright (C) 2008-2010 Sebastian Trueg <trueg@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef _NEPOMUK_QUERY_UTILS_H_ 00021 #define _NEPOMUK_QUERY_UTILS_H_ 00022 00023 #include <QtCore/QList> 00024 #include <QtCore/QHash> 00025 00026 template<typename T> 00027 bool compareQList( const QList<T>& rp1, const QList<T>& rp2 ) { 00028 if( rp1.count() != rp2.count() ) 00029 return false; 00030 foreach( const T& rp, rp1 ) { 00031 if ( !rp2.contains( rp ) ) { 00032 return false; 00033 } 00034 } 00035 return true; 00036 } 00037 00038 template<typename Key, typename Value> 00039 bool compareHash( const QHash<Key, Value>& h1, const QHash<Key, Value>& h2 ) { 00040 if( h1.count() != h2.count() ) 00041 return false; 00042 for( typename QHash<Key, Value>::ConstIterator it1 = h1.constBegin(); 00043 it1 != h1.constEnd(); ++it1 ) { 00044 typename QHash<Key, Value>::ConstIterator it2 = h2.find( it1.key() ); 00045 if( it2 == h2.constEnd() || 00046 *it1 != *it2 ) 00047 return false; 00048 } 00049 return true; 00050 } 00051 00052 #endif
KDE 4.6 API Reference