| 1 |
/* |
| 2 |
* Copyright (C) 2013-2015, 2019 by the Konclude Developer Team. |
| 3 |
* |
| 4 |
* This file is part of the reasoning system Konclude. |
| 5 |
* For details and support, see <http://konclude.com/>. |
| 6 |
* |
| 7 |
* Konclude is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of version 3 of the GNU Lesser General Public |
| 9 |
* License (LGPLv3) as published by the Free Software Foundation. |
| 10 |
* |
| 11 |
* Konclude is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU (Lesser) General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU (Lesser) General Public |
| 17 |
* License along with Konclude. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
* This file incorporates work covered by the following copyright and |
| 20 |
* permission notice (to be compatible with LGPLv2.1, |
| 21 |
* this code is available/released under GPLv3, |
| 22 |
* see https://www.gnu.org/licenses/gpl-faq.html#AllCompatibility): |
| 23 |
* |
| 24 |
* |
| 25 |
* Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
| 26 |
* Contact: http://www.qt-project.org/legal |
| 27 |
* |
| 28 |
* This file is part of the QtCore module of the Qt Toolkit. |
| 29 |
* |
| 30 |
* $QT_BEGIN_LICENSE:LGPL$ |
| 31 |
* Commercial License Usage |
| 32 |
* Licensees holding valid commercial Qt licenses may use this file in |
| 33 |
* accordance with the commercial license agreement provided with the |
| 34 |
* Software or, alternatively, in accordance with the terms contained in |
| 35 |
* a written agreement between you and Digia. For licensing terms and |
| 36 |
* conditions see http://qt.digia.com/licensing. For further information |
| 37 |
* use the contact form at http://qt.digia.com/contact-us. |
| 38 |
* |
| 39 |
* GNU Lesser General Public License Usage |
| 40 |
* Alternatively, this file may be used under the terms of the GNU Lesser |
| 41 |
* General Public License version 2.1 as published by the Free Software |
| 42 |
* Foundation and appearing in the file LICENSE.LGPL included in the |
| 43 |
* packaging of this file. Please review the following information to |
| 44 |
* ensure the GNU Lesser General Public License version 2.1 requirements |
| 45 |
* will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| 46 |
* |
| 47 |
* In addition, as a special exception, Digia gives you certain additional |
| 48 |
* rights. These rights are described in the Digia Qt LGPL Exception |
| 49 |
* version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| 50 |
* |
| 51 |
* GNU General Public License Usage |
| 52 |
* Alternatively, this file may be used under the terms of the GNU |
| 53 |
* General Public License version 3.0 as published by the Free Software |
| 54 |
* Foundation and appearing in the file LICENSE.GPL included in the |
| 55 |
* packaging of this file. Please review the following information to |
| 56 |
* ensure the GNU General Public License version 3.0 requirements will be |
| 57 |
* met: http://www.gnu.org/copyleft/gpl.html. |
| 58 |
* |
| 59 |
* |
| 60 |
* $QT_END_LICENSE$ |
| 61 |
* |
| 62 |
* |
| 63 |
*/ |
| 64 |
|
| 65 |
#ifndef KONCLUDE_UTILITIES_CONTAINER_CQTMANAGEDRESTRICTEDMODIFICATIONSET_CPP |
| 66 |
#define KONCLUDE_UTILITIES_CONTAINER_CQTMANAGEDRESTRICTEDMODIFICATIONSET_CPP |
| 67 |
|
| 68 |
|
| 69 |
#include "CQtManagedRestrictedModificationSet.h" |
| 70 |
|
| 71 |
|
| 72 |
namespace Konclude { |
| 73 |
|
| 74 |
namespace Utilities { |
| 75 |
|
| 76 |
namespace Container { |
| 77 |
|
| 78 |
|
| 79 |
#ifdef KONCLUDE_EMPLOY_QT_MANAGED_RESTRICTED_MODIFICATION_SET_CONTAINER |
| 80 |
|
| 81 |
template <class T> |
| 82 |
Q_INLINE_TEMPLATE void CQtManagedRestrictedModificationSet<T>::reserve(int asize) { mHash.reserve(asize); } |
| 83 |
|
| 84 |
template <class T> |
| 85 |
Q_INLINE_TEMPLATE CQtManagedRestrictedModificationSet<T> &CQtManagedRestrictedModificationSet<T>::unite(const CQtManagedRestrictedModificationSet<T> &other) |
| 86 |
{ |
| 87 |
CQtManagedRestrictedModificationSet<T> copy(other); |
| 88 |
typename CQtManagedRestrictedModificationSet<T>::const_iterator i = copy.constEnd(); |
| 89 |
while (i != copy.constBegin()) { |
| 90 |
--i; |
| 91 |
insert(*i); |
| 92 |
} |
| 93 |
return *this; |
| 94 |
} |
| 95 |
|
| 96 |
template <class T> |
| 97 |
Q_INLINE_TEMPLATE CQtManagedRestrictedModificationSet<T> &CQtManagedRestrictedModificationSet<T>::intersect(const CQtManagedRestrictedModificationSet<T> &other) |
| 98 |
{ |
| 99 |
CQtManagedRestrictedModificationSet<T> copy1(*this); |
| 100 |
CQtManagedRestrictedModificationSet<T> copy2(other); |
| 101 |
typename CQtManagedRestrictedModificationSet<T>::const_iterator i = copy1.constEnd(); |
| 102 |
while (i != copy1.constBegin()) { |
| 103 |
--i; |
| 104 |
if (!copy2.contains(*i)) |
| 105 |
remove(*i); |
| 106 |
} |
| 107 |
return *this; |
| 108 |
} |
| 109 |
|
| 110 |
template <class T> |
| 111 |
Q_INLINE_TEMPLATE CQtManagedRestrictedModificationSet<T> &CQtManagedRestrictedModificationSet<T>::subtract(const CQtManagedRestrictedModificationSet<T> &other) |
| 112 |
{ |
| 113 |
CQtManagedRestrictedModificationSet<T> copy1(*this); |
| 114 |
CQtManagedRestrictedModificationSet<T> copy2(other); |
| 115 |
typename CQtManagedRestrictedModificationSet<T>::const_iterator i = copy1.constEnd(); |
| 116 |
while (i != copy1.constBegin()) { |
| 117 |
--i; |
| 118 |
if (copy2.contains(*i)) |
| 119 |
remove(*i); |
| 120 |
} |
| 121 |
return *this; |
| 122 |
} |
| 123 |
|
| 124 |
template <class T> |
| 125 |
Q_INLINE_TEMPLATE bool CQtManagedRestrictedModificationSet<T>::contains(const CQtManagedRestrictedModificationSet<T> &other) const |
| 126 |
{ |
| 127 |
typename CQtManagedRestrictedModificationSet<T>::const_iterator i = other.constBegin(); |
| 128 |
while (i != other.constEnd()) { |
| 129 |
if (!contains(*i)) |
| 130 |
return false; |
| 131 |
++i; |
| 132 |
} |
| 133 |
return true; |
| 134 |
} |
| 135 |
|
| 136 |
template <typename T> |
| 137 |
Q_OUTOFLINE_TEMPLATE QList<T> CQtManagedRestrictedModificationSet<T>::toList() const |
| 138 |
{ |
| 139 |
QList<T> result; |
| 140 |
result.reserve(size()); |
| 141 |
typename CQtManagedRestrictedModificationSet<T>::const_iterator i = constBegin(); |
| 142 |
while (i != constEnd()) { |
| 143 |
result.append(*i); |
| 144 |
++i; |
| 145 |
} |
| 146 |
return result; |
| 147 |
} |
| 148 |
|
| 149 |
//template <typename T> |
| 150 |
//Q_OUTOFLINE_TEMPLATE CQtManagedRestrictedModificationSet<T> QList<T>::toSet() const |
| 151 |
//{ |
| 152 |
// CQtManagedRestrictedModificationSet<T> result; |
| 153 |
// result.reserve(size()); |
| 154 |
// for (int i = 0; i < size(); ++i) |
| 155 |
// result.insert(at(i)); |
| 156 |
// return result; |
| 157 |
//} |
| 158 |
|
| 159 |
template <typename T> |
| 160 |
CQtManagedRestrictedModificationSet<T> CQtManagedRestrictedModificationSet<T>::fromList(const QList<T> &list) |
| 161 |
{ |
| 162 |
return list.toSet(); |
| 163 |
} |
| 164 |
|
| 165 |
//template <typename T> |
| 166 |
//QList<T> QList<T>::fromSet(const CQtManagedRestrictedModificationSet<T> &set) |
| 167 |
//{ |
| 168 |
// return set.toList(); |
| 169 |
//} |
| 170 |
|
| 171 |
|
| 172 |
template <typename T> |
| 173 |
CQtManagedRestrictedModificationSet<T>* CQtManagedRestrictedModificationSet<T>::init(CContext* context) { |
| 174 |
mHash.init(mContext); |
| 175 |
mContext = context; |
| 176 |
return this; |
| 177 |
} |
| 178 |
|
| 179 |
template <typename T> |
| 180 |
CQtManagedRestrictedModificationSet<T>* CQtManagedRestrictedModificationSet<T>::init(const CQtManagedRestrictedModificationSet<T> &other, CContext* context) { |
| 181 |
mHash.init(other.mHash,mContext); |
| 182 |
mContext = context; |
| 183 |
return this; |
| 184 |
} |
| 185 |
|
| 186 |
template <typename T> |
| 187 |
CQtManagedRestrictedModificationSet<T>* CQtManagedRestrictedModificationSet<T>::init(CQtManagedRestrictedModificationSet<T> *other, CContext* context) { |
| 188 |
if (other) { |
| 189 |
mHash.init(other->mHash,mContext); |
| 190 |
} else { |
| 191 |
mHash.init(mContext); |
| 192 |
} |
| 193 |
mContext = context; |
| 194 |
return this; |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
#endif // KONCLUDE_EMPLOY_QT_MANAGED_RESTRICTED_MODIFICATION_SET_CONTAINER |
| 200 |
|
| 201 |
|
| 202 |
}; // end namespace Container |
| 203 |
|
| 204 |
}; // end namespace Utilities |
| 205 |
|
| 206 |
}; // end namespace Konclude |
| 207 |
|
| 208 |
#endif // KONCLUDE_UTILITIES_CONTAINER_CQTMANAGEDRESTRICTEDMODIFICATIONSET_CPP |