| 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 |
*/ |
| 20 |
|
| 21 |
#include "CDatatypeCompareValueSpaceMap.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Process { |
| 31 |
|
| 32 |
|
| 33 |
CDatatypeCompareValueSpaceMap::CDatatypeCompareValueSpaceMap(CProcessContext* processContext) : CPROCESSMAP<CDatatypeCompareValueSpaceMapArranger,CDatatypeCompareValueSpaceMapData>(processContext),mProcessContext(processContext) { |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
CDatatypeCompareValueSpaceMap* CDatatypeCompareValueSpaceMap::initDatatypeCompareValueSpaceMap(CDatatypeCompareValueSpaceMap* map) { |
| 38 |
if (map) { |
| 39 |
CPROCESSMAP<CDatatypeCompareValueSpaceMapArranger, CDatatypeCompareValueSpaceMapData>::operator=(*map); |
| 40 |
mAbsoluteMinimumExclusionValue = map->mAbsoluteMinimumExclusionValue; |
| 41 |
mAbsoluteMaximumExclusionValue = map->mAbsoluteMaximumExclusionValue; |
| 42 |
} |
| 43 |
return this; |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
CDatatypeCompareValueSpaceMap* CDatatypeCompareValueSpaceMap::initDatatypeCompareValueSpaceMap(CDatatypeValueSpaceCompareType* valueSpaceType) { |
| 49 |
CPROCESSMAP<CDatatypeCompareValueSpaceMapArranger,CDatatypeCompareValueSpaceMapData>::clear(); |
| 50 |
mAbsoluteMinimumExclusionValue = nullptr; |
| 51 |
mAbsoluteMaximumExclusionValue = nullptr; |
| 52 |
|
| 53 |
excludeMinimum(valueSpaceType->getMinimumDataLiteralCompareValue(),false,nullptr); |
| 54 |
excludeMaximum(valueSpaceType->getMaximumDataLiteralCompareValue(),false,nullptr); |
| 55 |
return this; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
bool CDatatypeCompareValueSpaceMap::getAbsoluteMinimumValue(CDataLiteralCompareValue*& minValue, bool& minValueInclusive, CDependencyTrackPoint** depTrackPoint) { |
| 61 |
if (mAbsoluteMinimumExclusionValue) { |
| 62 |
minValue = mAbsoluteMinimumExclusionValue->getValue(); |
| 63 |
minValueInclusive = true; |
| 64 |
if (depTrackPoint) { |
| 65 |
*depTrackPoint = mAbsoluteMinimumExclusionValue->getLeftExclusionData()->getExcludedDependencyTrackPoint(); |
| 66 |
} |
| 67 |
if (mAbsoluteMinimumExclusionValue->getValueExclusionData()->isExcluded()) { |
| 68 |
if (mAbsoluteMinimumExclusionValue->getValueExclusionData()->getExcludedDependencyTrackPoint() == mAbsoluteMinimumExclusionValue->getLeftExclusionData()->getExcludedDependencyTrackPoint()) { |
| 69 |
minValueInclusive = false; |
| 70 |
} |
| 71 |
} |
| 72 |
return true; |
| 73 |
} |
| 74 |
return false; |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
bool CDatatypeCompareValueSpaceMap::getAbsoluteMaximumValue(CDataLiteralCompareValue*& maxValue, bool& maxValueInclusive, CDependencyTrackPoint** depTrackPoint) { |
| 79 |
if (mAbsoluteMaximumExclusionValue) { |
| 80 |
maxValue = mAbsoluteMaximumExclusionValue->getValue(); |
| 81 |
maxValueInclusive = true; |
| 82 |
if (depTrackPoint) { |
| 83 |
*depTrackPoint = mAbsoluteMaximumExclusionValue->getRightExclusionData()->getExcludedDependencyTrackPoint(); |
| 84 |
} |
| 85 |
if (mAbsoluteMaximumExclusionValue->getValueExclusionData()->isExcluded()) { |
| 86 |
if (mAbsoluteMaximumExclusionValue->getValueExclusionData()->getExcludedDependencyTrackPoint() == mAbsoluteMaximumExclusionValue->getRightExclusionData()->getExcludedDependencyTrackPoint()) { |
| 87 |
maxValueInclusive = false; |
| 88 |
} |
| 89 |
} |
| 90 |
return true; |
| 91 |
} |
| 92 |
return false; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
bool CDatatypeCompareValueSpaceMap::excludeMinimum(CDataLiteralCompareValue* value, bool valueInclusively, CDependencyTrackPoint* depTrackPoint) { |
| 98 |
|
| 99 |
if (mAbsoluteMinimumExclusionValue) { |
| 100 |
if (mAbsoluteMinimumExclusionValue->getValue()->isGreaterThan(value)) { |
| 101 |
return false; |
| 102 |
} |
| 103 |
} |
| 104 |
bool newValuesPotentiallyExcluded = false; |
| 105 |
|
| 106 |
CDatatypeCompareValueData* valueData = getDatatypeCompareValueData(value,true); |
| 107 |
newValuesPotentiallyExcluded |= excludeLeftDataInterval(valueData,depTrackPoint,true); |
| 108 |
if (valueInclusively && !isDataValueExcluded(valueData)) { |
| 109 |
newValuesPotentiallyExcluded |= excludeDataValue(valueData,depTrackPoint,false); |
| 110 |
} |
| 111 |
mAbsoluteMinimumExclusionValue = valueData; |
| 112 |
|
| 113 |
// remove all lower values from map |
| 114 |
CDatatypeCompareValueSpaceMap::iterator it = CDatatypeCompareValueSpaceMap::begin(), itEnd = CDatatypeCompareValueSpaceMap::end(); |
| 115 |
while (it != itEnd) { |
| 116 |
const CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 117 |
CDatatypeCompareValueData* itValueData = mapData.mUseValue; |
| 118 |
if (itValueData == valueData) { |
| 119 |
break; |
| 120 |
} |
| 121 |
newValuesPotentiallyExcluded = true; |
| 122 |
it = CDatatypeCompareValueSpaceMap::erase(it); |
| 123 |
} |
| 124 |
|
| 125 |
return newValuesPotentiallyExcluded; |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
bool CDatatypeCompareValueSpaceMap::excludeMaximum(CDataLiteralCompareValue* value, bool valueInclusively, CDependencyTrackPoint* depTrackPoint) { |
| 131 |
|
| 132 |
if (mAbsoluteMaximumExclusionValue) { |
| 133 |
if (mAbsoluteMaximumExclusionValue->getValue()->isLessThan(value)) { |
| 134 |
return false; |
| 135 |
} |
| 136 |
} |
| 137 |
bool newValuesPotentiallyExcluded = false; |
| 138 |
|
| 139 |
CDatatypeCompareValueData* valueData = getDatatypeCompareValueData(value,true); |
| 140 |
newValuesPotentiallyExcluded |= excludeRightDataInterval(valueData,depTrackPoint,true); |
| 141 |
if (valueInclusively && !isDataValueExcluded(valueData)) { |
| 142 |
newValuesPotentiallyExcluded |= excludeDataValue(valueData,depTrackPoint,false); |
| 143 |
} |
| 144 |
mAbsoluteMaximumExclusionValue = valueData; |
| 145 |
|
| 146 |
// remove all higher values from map |
| 147 |
CDatatypeCompareValueSpaceMapArranger mapValueArranger(value); |
| 148 |
CDatatypeCompareValueSpaceMap::iterator itBegin = CDatatypeCompareValueSpaceMap::begin(), itUB = CDatatypeCompareValueSpaceMap::upperBound(mapValueArranger), itEnd = CDatatypeCompareValueSpaceMap::end(); |
| 149 |
CDatatypeCompareValueSpaceMap::iterator it = itUB; |
| 150 |
while (it != itEnd) { |
| 151 |
const CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 152 |
CDatatypeCompareValueData* itValueData = mapData.mUseValue; |
| 153 |
newValuesPotentiallyExcluded = true; |
| 154 |
it = CDatatypeCompareValueSpaceMap::erase(it); |
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
return newValuesPotentiallyExcluded; |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
bool CDatatypeCompareValueSpaceMap::excludeAll(CDependencyTrackPoint* depTrackPoint) { |
| 168 |
bool newValuesPotentiallyExcluded = false; |
| 169 |
|
| 170 |
CDatatypeCompareValueSpaceMap::iterator itBegin = CDatatypeCompareValueSpaceMap::begin(), itEnd = CDatatypeCompareValueSpaceMap::end(); |
| 171 |
CDatatypeCompareValueSpaceMap::iterator it = itBegin; |
| 172 |
|
| 173 |
while (it != itEnd) { |
| 174 |
CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 175 |
CDatatypeCompareValueData* itValueData = mapData.mUseValue; |
| 176 |
|
| 177 |
if (it == itBegin) { |
| 178 |
if (!isLeftDataIntervalExcluded(itValueData)) { |
| 179 |
itValueData = getDatatypeCompareValueData(itValueData->getValue(),mapData,true,nullptr); |
| 180 |
newValuesPotentiallyExcluded |= excludeLeftDataInterval(itValueData,depTrackPoint,false); |
| 181 |
} |
| 182 |
if (!isDataValueExcluded(itValueData)) { |
| 183 |
itValueData = getDatatypeCompareValueData(itValueData->getValue(),mapData,true,nullptr); |
| 184 |
newValuesPotentiallyExcluded |= excludeDataValue(itValueData,depTrackPoint,false); |
| 185 |
} |
| 186 |
} |
| 187 |
|
| 188 |
++it; |
| 189 |
if (it != itEnd) { |
| 190 |
CDatatypeCompareValueSpaceMapData& nextMapData = it.value(); |
| 191 |
CDatatypeCompareValueData* nextValueData = nextMapData.mUseValue; |
| 192 |
|
| 193 |
if (!isDataIntervalExcluded(itValueData,nextValueData)) { |
| 194 |
itValueData = getDatatypeCompareValueData(itValueData->getValue(),mapData,true,nullptr); |
| 195 |
newValuesPotentiallyExcluded |= excludeRightDataInterval(itValueData,depTrackPoint,false); |
| 196 |
nextValueData = getDatatypeCompareValueData(nextValueData->getValue(),nextMapData,true,nullptr); |
| 197 |
newValuesPotentiallyExcluded |= excludeLeftDataInterval(nextValueData,depTrackPoint,false); |
| 198 |
} |
| 199 |
if (!isDataValueExcluded(nextValueData)) { |
| 200 |
nextValueData = getDatatypeCompareValueData(nextValueData->getValue(),nextMapData,true,nullptr); |
| 201 |
newValuesPotentiallyExcluded |= excludeDataValue(nextValueData,depTrackPoint,false); |
| 202 |
} |
| 203 |
|
| 204 |
|
| 205 |
} else { |
| 206 |
if (!isRightDataIntervalExcluded(itValueData)) { |
| 207 |
itValueData = getDatatypeCompareValueData(itValueData->getValue(),mapData,true,nullptr); |
| 208 |
newValuesPotentiallyExcluded |= excludeRightDataInterval(itValueData,depTrackPoint,false); |
| 209 |
} |
| 210 |
} |
| 211 |
|
| 212 |
} |
| 213 |
|
| 214 |
return newValuesPotentiallyExcluded; |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
bool CDatatypeCompareValueSpaceMap::excludeInterval(CDataLiteralCompareValue* leftValue, bool leftValueInclusive, CDataLiteralCompareValue* rightValue, bool rightValueInclusive, CDependencyTrackPoint* depTrackPoint) { |
| 223 |
bool newValuesPotentiallyExcluded = false; |
| 224 |
|
| 225 |
CDatatypeCompareValueData* leftValueData = getDatatypeCompareValueData(leftValue,true); |
| 226 |
CDatatypeCompareValueData* rightValueData = getDatatypeCompareValueData(rightValue,true); |
| 227 |
|
| 228 |
if (leftValueInclusive && !isDataValueExcluded(leftValueData)) { |
| 229 |
newValuesPotentiallyExcluded |= excludeDataValue(leftValueData,depTrackPoint,false); |
| 230 |
} |
| 231 |
|
| 232 |
if (leftValueInclusive && !isDataValueExcluded(rightValueData)) { |
| 233 |
newValuesPotentiallyExcluded |= excludeDataValue(rightValueData,depTrackPoint,false); |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
CDatatypeCompareValueSpaceMapArranger mapValueArranger(leftValue); |
| 238 |
CDatatypeCompareValueSpaceMap::iterator itBegin = CDatatypeCompareValueSpaceMap::begin(), itLB = CDatatypeCompareValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeCompareValueSpaceMap::end(); |
| 239 |
CDatatypeCompareValueSpaceMap::iterator it = itLB; |
| 240 |
while (it != itEnd) { |
| 241 |
CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 242 |
CDatatypeCompareValueData* itValueData = mapData.mUseValue; |
| 243 |
|
| 244 |
++it; |
| 245 |
if (it != itEnd) { |
| 246 |
CDatatypeCompareValueSpaceMapData& nextMapData = it.value(); |
| 247 |
CDatatypeCompareValueData* nextValueData = nextMapData.mUseValue; |
| 248 |
|
| 249 |
if (!isDataIntervalExcluded(itValueData,nextValueData)) { |
| 250 |
itValueData = getDatatypeCompareValueData(itValueData->getValue(),mapData,true,nullptr); |
| 251 |
newValuesPotentiallyExcluded |= excludeRightDataInterval(itValueData,depTrackPoint,false); |
| 252 |
nextValueData = getDatatypeCompareValueData(nextValueData->getValue(),nextMapData,true,nullptr); |
| 253 |
newValuesPotentiallyExcluded |= excludeLeftDataInterval(nextValueData,depTrackPoint,false); |
| 254 |
} |
| 255 |
|
| 256 |
if (nextValueData == rightValueData) { |
| 257 |
break; |
| 258 |
} |
| 259 |
|
| 260 |
if (!isDataValueExcluded(nextValueData)) { |
| 261 |
nextValueData = getDatatypeCompareValueData(nextValueData->getValue(),nextMapData,true,nullptr); |
| 262 |
newValuesPotentiallyExcluded |= excludeDataValue(nextValueData,depTrackPoint,false); |
| 263 |
} |
| 264 |
} |
| 265 |
} |
| 266 |
|
| 267 |
return newValuesPotentiallyExcluded; |
| 268 |
} |
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
bool CDatatypeCompareValueSpaceMap::countDataIntervalValues(CDatatypeCompareValueData* leftValueExcluded, CDatatypeCompareValueData* rightValueExcluded, CDatatypeValueSpaceValuesCounter* counter) { |
| 277 |
return countDataIntervalValues(leftValueExcluded->getValue(),rightValueExcluded->getValue(),leftValueExcluded->getRightExclusionData(),counter); |
| 278 |
} |
| 279 |
|
| 280 |
bool CDatatypeCompareValueSpaceMap::countDataIntervalValues(CDataLiteralCompareValue* leftValueExcluded, CDatatypeCompareValueData* rightValueExcluded, CDatatypeValueSpaceValuesCounter* counter) { |
| 281 |
return countDataIntervalValues(leftValueExcluded,rightValueExcluded->getValue(),rightValueExcluded->getLeftExclusionData(),counter); |
| 282 |
} |
| 283 |
|
| 284 |
|
| 285 |
bool CDatatypeCompareValueSpaceMap::countDataIntervalValues(CDatatypeCompareValueData* leftValueExcluded, CDataLiteralCompareValue* rightValueExcluded, CDatatypeValueSpaceValuesCounter* counter) { |
| 286 |
return countDataIntervalValues(leftValueExcluded->getValue(),rightValueExcluded,leftValueExcluded->getRightExclusionData(),counter); |
| 287 |
} |
| 288 |
|
| 289 |
|
| 290 |
bool CDatatypeCompareValueSpaceMap::countDataIntervalValues(CDataLiteralCompareValue* leftValueExcluded, CDataLiteralCompareValue* rightValueExcluded, CDatatypeCompareValueDataExclusion* exlcusionData, CDatatypeValueSpaceValuesCounter* counter) { |
| 291 |
bool counted = false; |
| 292 |
if (!exlcusionData->isExcluded()) { |
| 293 |
|
| 294 |
if (representsInfinitelyManyValues(leftValueExcluded) || representsInfinitelyManyValues(rightValueExcluded) || representsInfinitelyManyValues(leftValueExcluded,rightValueExcluded)) { |
| 295 |
counted |= counter->incInfinite(); |
| 296 |
} else { |
| 297 |
cuint64 valueCount = getIntervalValueCount(leftValueExcluded,rightValueExcluded); |
| 298 |
counted |= counter->incValueCount(valueCount); |
| 299 |
} |
| 300 |
|
| 301 |
} |
| 302 |
return counted; |
| 303 |
} |
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
bool CDatatypeCompareValueSpaceMap::countDataValue(CDatatypeCompareValueData* dataValue, CDatatypeValueSpaceValuesCounter* counter) { |
| 309 |
return countDataValue(dataValue->getValue(),dataValue->getValueExclusionData(),counter); |
| 310 |
} |
| 311 |
|
| 312 |
|
| 313 |
bool CDatatypeCompareValueSpaceMap::countDataValue(CDataLiteralCompareValue* value, CDatatypeCompareValueDataExclusion* exlcusionData, CDatatypeValueSpaceValuesCounter* counter) { |
| 314 |
bool counted = false; |
| 315 |
if (!exlcusionData->isExcluded()) { |
| 316 |
|
| 317 |
if (representsInfinitelyManyValues(value)) { |
| 318 |
counted |= counter->incInfinite(); |
| 319 |
} else { |
| 320 |
counted |= counter->incValueCount(1); |
| 321 |
} |
| 322 |
} |
| 323 |
return counted; |
| 324 |
} |
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
bool CDatatypeCompareValueSpaceMap::countValueValues(CDataLiteralCompareValue* value, CDatatypeValueSpaceValuesCounter* counter) { |
| 330 |
bool counted = false; |
| 331 |
if (mAbsoluteMinimumExclusionValue) { |
| 332 |
if (value->isLessThan(mAbsoluteMinimumExclusionValue->getValue())) { |
| 333 |
return false; |
| 334 |
} |
| 335 |
} |
| 336 |
if (mAbsoluteMaximumExclusionValue) { |
| 337 |
if (value->isGreaterThan(mAbsoluteMaximumExclusionValue->getValue())) { |
| 338 |
return false; |
| 339 |
} |
| 340 |
} |
| 341 |
|
| 342 |
CDatatypeCompareValueSpaceMapArranger mapValueArranger(value); |
| 343 |
CDatatypeCompareValueSpaceMap::iterator itBegin = CDatatypeCompareValueSpaceMap::begin(), itLB = CDatatypeCompareValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeCompareValueSpaceMap::end(); |
| 344 |
CDatatypeCompareValueSpaceMap::iterator it = itLB; |
| 345 |
|
| 346 |
|
| 347 |
if (it != itEnd) { |
| 348 |
CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 349 |
CDatatypeCompareValueData* itValueData = mapData.mUseValue; |
| 350 |
|
| 351 |
if (value->isEqualTo(itValueData->getValue())) { |
| 352 |
if (!isDataValueExcluded(itValueData)) { |
| 353 |
counted |= countDataValue(itValueData,counter); |
| 354 |
} |
| 355 |
} else { |
| 356 |
if (!isDataValueExcluded(value)) { |
| 357 |
counted |= countDataValue(value,itValueData->getLeftExclusionData(),counter); |
| 358 |
} |
| 359 |
} |
| 360 |
} |
| 361 |
|
| 362 |
return counted; |
| 363 |
} |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
bool CDatatypeCompareValueSpaceMap::addIntervalExclusionDependencies(CDataLiteralCompareValue* leftValue, bool leftValueInclusive, CDataLiteralCompareValue* rightValue, bool rightValueInclusive, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 372 |
if (mAbsoluteMinimumExclusionValue) { |
| 373 |
if (leftValue->isLessThan(mAbsoluteMinimumExclusionValue->getValue())) { |
| 374 |
leftValue = mAbsoluteMinimumExclusionValue->getValue(); |
| 375 |
} |
| 376 |
} |
| 377 |
if (mAbsoluteMaximumExclusionValue) { |
| 378 |
if (rightValue->isGreaterThan(mAbsoluteMaximumExclusionValue->getValue())) { |
| 379 |
rightValue = mAbsoluteMaximumExclusionValue->getValue(); |
| 380 |
} |
| 381 |
} |
| 382 |
|
| 383 |
if (leftValue->isGreaterThan(rightValue)) { |
| 384 |
return false; |
| 385 |
} else if (leftValue->isEqualTo(rightValue)) { |
| 386 |
if (!leftValueInclusive && !rightValueInclusive) { |
| 387 |
return false; |
| 388 |
} |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
bool depAdded = false; |
| 393 |
|
| 394 |
CDatatypeCompareValueSpaceMapArranger mapValueArranger(leftValue); |
| 395 |
CDatatypeCompareValueSpaceMap::iterator itBegin = CDatatypeCompareValueSpaceMap::begin(), itLB = CDatatypeCompareValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeCompareValueSpaceMap::end(); |
| 396 |
CDatatypeCompareValueSpaceMap::iterator it = itLB; |
| 397 |
|
| 398 |
|
| 399 |
while (it != itEnd) { |
| 400 |
CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 401 |
CDatatypeCompareValueData* itValueData = mapData.mUseValue; |
| 402 |
|
| 403 |
if (it == itLB) { |
| 404 |
if (leftValue->isEqualTo(itValueData->getValue())) { |
| 405 |
if (leftValueInclusive) { |
| 406 |
depAdded |= addDataValueExclusionDependencies(itValueData,depCollector); |
| 407 |
} |
| 408 |
} else { |
| 409 |
depAdded |= addExclusionDependencies(itValueData->getLeftExclusionData(),depCollector); |
| 410 |
} |
| 411 |
} |
| 412 |
|
| 413 |
++it; |
| 414 |
if (it != itEnd) { |
| 415 |
CDatatypeCompareValueSpaceMapData& nextMapData = it.value(); |
| 416 |
CDatatypeCompareValueData* nextValueData = nextMapData.mUseValue; |
| 417 |
|
| 418 |
depAdded |= addDataIntervalExclusionDependencies(itValueData,nextValueData,depCollector); |
| 419 |
|
| 420 |
if (nextValueData->getValue()->isEqualTo(rightValue)) { |
| 421 |
if (rightValueInclusive) { |
| 422 |
depAdded |= addDataValueExclusionDependencies(nextValueData,depCollector); |
| 423 |
} |
| 424 |
break; |
| 425 |
} else if (nextValueData->getValue()->isGreaterThan(rightValue)) { |
| 426 |
depAdded |= addExclusionDependencies(itValueData->getRightExclusionData(),depCollector); |
| 427 |
break; |
| 428 |
} |
| 429 |
|
| 430 |
depAdded |= addDataValueExclusionDependencies(nextValueData,depCollector); |
| 431 |
} |
| 432 |
} |
| 433 |
|
| 434 |
return depAdded; |
| 435 |
|
| 436 |
} |
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
bool CDatatypeCompareValueSpaceMap::addValueExclusionDependencies(CDataLiteralCompareValue* value, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 443 |
if (mAbsoluteMinimumExclusionValue) { |
| 444 |
if (value->isLessThan(mAbsoluteMinimumExclusionValue->getValue())) { |
| 445 |
return false; |
| 446 |
} |
| 447 |
} |
| 448 |
if (mAbsoluteMaximumExclusionValue) { |
| 449 |
if (value->isGreaterThan(mAbsoluteMaximumExclusionValue->getValue())) { |
| 450 |
return false; |
| 451 |
} |
| 452 |
} |
| 453 |
|
| 454 |
|
| 455 |
bool depAdded = false; |
| 456 |
|
| 457 |
CDatatypeCompareValueSpaceMapArranger mapValueArranger(value); |
| 458 |
CDatatypeCompareValueSpaceMap::iterator itBegin = CDatatypeCompareValueSpaceMap::begin(), itLB = CDatatypeCompareValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeCompareValueSpaceMap::end(); |
| 459 |
CDatatypeCompareValueSpaceMap::iterator it = itLB; |
| 460 |
|
| 461 |
|
| 462 |
if (it != itEnd) { |
| 463 |
CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 464 |
CDatatypeCompareValueData* itValueData = mapData.mUseValue; |
| 465 |
|
| 466 |
if (value->isEqualTo(itValueData->getValue())) { |
| 467 |
depAdded |= addDataValueExclusionDependencies(itValueData,depCollector); |
| 468 |
} else if (value->isGreaterThan(itValueData->getValue())) { |
| 469 |
depAdded |= addExclusionDependencies(itValueData->getRightExclusionData(),depCollector); |
| 470 |
} else { |
| 471 |
depAdded |= addExclusionDependencies(itValueData->getLeftExclusionData(),depCollector); |
| 472 |
} |
| 473 |
} |
| 474 |
|
| 475 |
return depAdded; |
| 476 |
} |
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
bool CDatatypeCompareValueSpaceMap::countAllValues(CDatatypeValueSpaceValuesCounter* counter) { |
| 483 |
if (mAbsoluteMaximumExclusionValue && mAbsoluteMinimumExclusionValue) { |
| 484 |
return countIntervalValues(mAbsoluteMinimumExclusionValue->getValue(),true,mAbsoluteMaximumExclusionValue->getValue(),true,counter); |
| 485 |
} |
| 486 |
return false; |
| 487 |
} |
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
bool CDatatypeCompareValueSpaceMap::countIntervalValues(CDataLiteralCompareValue* leftValue, bool leftValueInclusive, CDataLiteralCompareValue* rightValue, bool rightValueInclusive, CDatatypeValueSpaceValuesCounter* counter) { |
| 492 |
bool counted = false; |
| 493 |
|
| 494 |
if (mAbsoluteMinimumExclusionValue) { |
| 495 |
if (leftValue->isLessThan(mAbsoluteMinimumExclusionValue->getValue())) { |
| 496 |
leftValue = mAbsoluteMinimumExclusionValue->getValue(); |
| 497 |
} |
| 498 |
} |
| 499 |
if (mAbsoluteMaximumExclusionValue) { |
| 500 |
if (rightValue->isGreaterThan(mAbsoluteMaximumExclusionValue->getValue())) { |
| 501 |
rightValue = mAbsoluteMaximumExclusionValue->getValue(); |
| 502 |
} |
| 503 |
} |
| 504 |
|
| 505 |
if (leftValue->isGreaterThan(rightValue)) { |
| 506 |
return false; |
| 507 |
} else if (leftValue->isEqualTo(rightValue)) { |
| 508 |
if (!leftValueInclusive && !rightValueInclusive) { |
| 509 |
return false; |
| 510 |
} |
| 511 |
} |
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
CDatatypeCompareValueSpaceMapArranger mapValueArranger(leftValue); |
| 516 |
CDatatypeCompareValueSpaceMap::iterator itBegin = CDatatypeCompareValueSpaceMap::begin(), itLB = CDatatypeCompareValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeCompareValueSpaceMap::end(); |
| 517 |
CDatatypeCompareValueSpaceMap::iterator it = itLB; |
| 518 |
|
| 519 |
|
| 520 |
while (it != itEnd && !counter->isInfinite()) { |
| 521 |
CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 522 |
CDatatypeCompareValueData* itValueData = mapData.mUseValue; |
| 523 |
|
| 524 |
if (it == itLB) { |
| 525 |
if (leftValue->isEqualTo(itValueData->getValue())) { |
| 526 |
if (leftValueInclusive) { |
| 527 |
if (!isDataValueExcluded(itValueData)) { |
| 528 |
counted |= countDataValue(itValueData,counter); |
| 529 |
} |
| 530 |
} |
| 531 |
} else { |
| 532 |
if (leftValueInclusive) { |
| 533 |
if (!isDataValueExcluded(leftValue)) { |
| 534 |
counted |= countDataValue(leftValue,itValueData->getLeftExclusionData(),counter); |
| 535 |
} |
| 536 |
} |
| 537 |
if (!isDataIntervalExcluded(leftValue,itValueData)) { |
| 538 |
counted |= countDataIntervalValues(leftValue,itValueData,counter); |
| 539 |
} |
| 540 |
} |
| 541 |
} |
| 542 |
|
| 543 |
++it; |
| 544 |
if (it != itEnd) { |
| 545 |
CDatatypeCompareValueSpaceMapData& nextMapData = it.value(); |
| 546 |
CDatatypeCompareValueData* nextValueData = nextMapData.mUseValue; |
| 547 |
|
| 548 |
if (!isDataIntervalExcluded(itValueData,nextValueData)) { |
| 549 |
counted |= countDataIntervalValues(itValueData,nextValueData,counter); |
| 550 |
} |
| 551 |
|
| 552 |
if (nextValueData->getValue()->isEqualTo(rightValue)) { |
| 553 |
if (rightValueInclusive) { |
| 554 |
if (!isDataValueExcluded(nextValueData)) { |
| 555 |
counted |= countDataValue(nextValueData,counter); |
| 556 |
} |
| 557 |
} |
| 558 |
break; |
| 559 |
} else if (nextValueData->getValue()->isGreaterThan(rightValue)) { |
| 560 |
if (rightValueInclusive) { |
| 561 |
if (!isDataValueExcluded(rightValue)) { |
| 562 |
counted |= countDataValue(rightValue,nextValueData->getLeftExclusionData(),counter); |
| 563 |
} |
| 564 |
} |
| 565 |
if (!isDataIntervalExcluded(nextValueData,rightValue)) { |
| 566 |
counted |= countDataIntervalValues(nextValueData,rightValue,counter); |
| 567 |
} |
| 568 |
break; |
| 569 |
} |
| 570 |
|
| 571 |
if (!isDataValueExcluded(nextValueData)) { |
| 572 |
counted |= countDataValue(nextValueData,counter); |
| 573 |
} |
| 574 |
} |
| 575 |
} |
| 576 |
|
| 577 |
return counted; |
| 578 |
} |
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
bool CDatatypeCompareValueSpaceMap::excludeData(CDatatypeCompareValueDataExclusion* exlcusionData, CDependencyTrackPoint* depTrackPoint, bool force) { |
| 591 |
if (force || !exlcusionData->isExcluded()) { |
| 592 |
exlcusionData->setExcluded(true); |
| 593 |
exlcusionData->setExcludedDependencyTrackPoint(depTrackPoint); |
| 594 |
return true; |
| 595 |
} |
| 596 |
return false; |
| 597 |
} |
| 598 |
|
| 599 |
|
| 600 |
bool CDatatypeCompareValueSpaceMap::excludeDataValue(CDatatypeCompareValueData* dataValue, CDependencyTrackPoint* depTrackPoint, bool force) { |
| 601 |
return excludeData(dataValue->getValueExclusionData(),depTrackPoint,force); |
| 602 |
} |
| 603 |
|
| 604 |
bool CDatatypeCompareValueSpaceMap::excludeLeftDataInterval(CDatatypeCompareValueData* dataValue, CDependencyTrackPoint* depTrackPoint, bool force) { |
| 605 |
return excludeData(dataValue->getLeftExclusionData(),depTrackPoint,force); |
| 606 |
} |
| 607 |
|
| 608 |
bool CDatatypeCompareValueSpaceMap::excludeRightDataInterval(CDatatypeCompareValueData* dataValue, CDependencyTrackPoint* depTrackPoint, bool force) { |
| 609 |
return excludeData(dataValue->getRightExclusionData(),depTrackPoint,force); |
| 610 |
} |
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
bool CDatatypeCompareValueSpaceMap::testValueSpaceReturnClashed() { |
| 617 |
|
| 618 |
CDatatypeCompareValueSpaceMap::const_iterator itBegin = CDatatypeCompareValueSpaceMap::constBegin(), itEnd = CDatatypeCompareValueSpaceMap::constEnd(); |
| 619 |
CDatatypeCompareValueSpaceMap::const_iterator it = itBegin; |
| 620 |
|
| 621 |
// test whether value space is empty |
| 622 |
CDatatypeCompareValueData* firstValueData = nullptr; |
| 623 |
|
| 624 |
while (it != itEnd) { |
| 625 |
|
| 626 |
const CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 627 |
CDatatypeCompareValueData* itValueData = mapData.mUseValue; |
| 628 |
if (!firstValueData) { |
| 629 |
firstValueData = itValueData; |
| 630 |
if (!isLeftDataIntervalExcluded(firstValueData)) { |
| 631 |
return false; |
| 632 |
} |
| 633 |
} |
| 634 |
if (!isDataValueExcluded(itValueData)) { |
| 635 |
return false; |
| 636 |
} |
| 637 |
++it; |
| 638 |
|
| 639 |
if (it != itEnd) { |
| 640 |
const CDatatypeCompareValueSpaceMapData& nextMapData = it.value(); |
| 641 |
CDatatypeCompareValueData* nextValueData = nextMapData.mUseValue; |
| 642 |
if (!isDataIntervalExcluded(itValueData,nextValueData)) { |
| 643 |
return false; |
| 644 |
} |
| 645 |
} else { |
| 646 |
if (!isRightDataIntervalExcluded(itValueData)) { |
| 647 |
return false; |
| 648 |
} |
| 649 |
} |
| 650 |
} |
| 651 |
return true; |
| 652 |
} |
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
bool CDatatypeCompareValueSpaceMap::addValueSpaceDependencies(CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 658 |
|
| 659 |
CDatatypeCompareValueSpaceMap::const_iterator itBegin = CDatatypeCompareValueSpaceMap::constBegin(), itEnd = CDatatypeCompareValueSpaceMap::constEnd(); |
| 660 |
CDatatypeCompareValueSpaceMap::const_iterator it = itBegin; |
| 661 |
|
| 662 |
it = itBegin; |
| 663 |
while (it != itEnd) { |
| 664 |
const CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 665 |
CDatatypeCompareValueData* itValueData = mapData.mUseValue; |
| 666 |
addDataValueExclusionDependencies(itValueData,depCollector); |
| 667 |
|
| 668 |
if (it == itBegin) { |
| 669 |
addLeftIntervalExclusionDependencies(itValueData,depCollector); |
| 670 |
} |
| 671 |
|
| 672 |
++it; |
| 673 |
if (it == itEnd) { |
| 674 |
addRightIntervalExclusionDependencies(itValueData,depCollector); |
| 675 |
} else { |
| 676 |
const CDatatypeCompareValueSpaceMapData& nextMapData = it.value(); |
| 677 |
CDatatypeCompareValueData* nextValueData = nextMapData.mUseValue; |
| 678 |
|
| 679 |
addDataIntervalExclusionDependencies(itValueData,nextValueData,depCollector); |
| 680 |
|
| 681 |
} |
| 682 |
} |
| 683 |
return true; |
| 684 |
|
| 685 |
} |
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
bool CDatatypeCompareValueSpaceMap::restrictToValue(CDataLiteralCompareValue* value, CDependencyTrackPoint* depTrackPoint) { |
| 694 |
bool newValuesPotentiallyExcluded = false; |
| 695 |
newValuesPotentiallyExcluded |= excludeMinimum(value,false,depTrackPoint); |
| 696 |
newValuesPotentiallyExcluded |= excludeMaximum(value,false,depTrackPoint); |
| 697 |
return newValuesPotentiallyExcluded; |
| 698 |
} |
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
bool CDatatypeCompareValueSpaceMap::excludeValue(CDataLiteralCompareValue* value, CDependencyTrackPoint* depTrackPoint) { |
| 703 |
bool newValuesPotentiallyExcluded = false; |
| 704 |
if (mAbsoluteMinimumExclusionValue) { |
| 705 |
if (mAbsoluteMinimumExclusionValue->getValue()->isGreaterThan(value)) { |
| 706 |
return false; |
| 707 |
} |
| 708 |
if (mAbsoluteMinimumExclusionValue->getValue()->isEqualTo(value)) { |
| 709 |
if (isDataValueExcluded(mAbsoluteMinimumExclusionValue)) { |
| 710 |
return false; |
| 711 |
} |
| 712 |
} |
| 713 |
} |
| 714 |
if (mAbsoluteMaximumExclusionValue) { |
| 715 |
if (mAbsoluteMaximumExclusionValue->getValue()->isGreaterThan(value)) { |
| 716 |
return false; |
| 717 |
} |
| 718 |
if (mAbsoluteMaximumExclusionValue->getValue()->isEqualTo(value)) { |
| 719 |
if (isDataValueExcluded(mAbsoluteMaximumExclusionValue)) { |
| 720 |
return false; |
| 721 |
} |
| 722 |
} |
| 723 |
} |
| 724 |
|
| 725 |
|
| 726 |
CDatatypeCompareValueData* valueData = getDatatypeCompareValueData(value,true); |
| 727 |
if (!isDataValueExcluded(valueData)) { |
| 728 |
newValuesPotentiallyExcluded |= excludeDataValue(valueData,depTrackPoint,false); |
| 729 |
} |
| 730 |
|
| 731 |
|
| 732 |
return newValuesPotentiallyExcluded; |
| 733 |
} |
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
bool CDatatypeCompareValueSpaceMap::addDataValueExclusionDependencies(CDatatypeCompareValueData* dataValue, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 742 |
CDatatypeCompareValueDataExclusion* exclusionData = dataValue->getValueExclusionData(); |
| 743 |
return addExclusionDependencies(exclusionData,depCollector); |
| 744 |
} |
| 745 |
|
| 746 |
bool CDatatypeCompareValueSpaceMap::addDataIntervalExclusionDependencies(CDatatypeCompareValueData* leftValueExcluded, CDatatypeCompareValueData* rightValueExcluded, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 747 |
CDatatypeCompareValueDataExclusion* exclusionData = leftValueExcluded->getRightExclusionData(); |
| 748 |
return addExclusionDependencies(exclusionData,depCollector); |
| 749 |
} |
| 750 |
|
| 751 |
bool CDatatypeCompareValueSpaceMap::addLeftIntervalExclusionDependencies(CDatatypeCompareValueData* valueData, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 752 |
CDatatypeCompareValueDataExclusion* exclusionData = valueData->getLeftExclusionData(); |
| 753 |
return addExclusionDependencies(exclusionData,depCollector); |
| 754 |
} |
| 755 |
|
| 756 |
bool CDatatypeCompareValueSpaceMap::addRightIntervalExclusionDependencies(CDatatypeCompareValueData* valueData, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 757 |
CDatatypeCompareValueDataExclusion* exclusionData = valueData->getRightExclusionData(); |
| 758 |
return addExclusionDependencies(exclusionData,depCollector); |
| 759 |
} |
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
bool CDatatypeCompareValueSpaceMap::addExclusionDependencies(CDatatypeCompareValueDataExclusion* exclusionData, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 765 |
bool dependenciesAdded = false; |
| 766 |
CDependencyTrackPoint* depTrackPoint = nullptr; |
| 767 |
if (depCollector) { |
| 768 |
if (exclusionData->isExcluded()) { |
| 769 |
depTrackPoint = exclusionData->getExcludedDependencyTrackPoint(); |
| 770 |
if (depTrackPoint) { |
| 771 |
dependenciesAdded |= depCollector->addDependency(depTrackPoint); |
| 772 |
} |
| 773 |
} |
| 774 |
} |
| 775 |
return dependenciesAdded; |
| 776 |
} |
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
bool CDatatypeCompareValueSpaceMap::isLeftDataIntervalExcluded(CDatatypeCompareValueData* dataValue) { |
| 790 |
CDatatypeCompareValueDataExclusion* exclusionData = dataValue->getLeftExclusionData(); |
| 791 |
if (exclusionData->isExcluded()) { |
| 792 |
return true; |
| 793 |
} |
| 794 |
return false; |
| 795 |
} |
| 796 |
|
| 797 |
|
| 798 |
bool CDatatypeCompareValueSpaceMap::isRightDataIntervalExcluded(CDatatypeCompareValueData* dataValue) { |
| 799 |
CDatatypeCompareValueDataExclusion* exclusionData = dataValue->getRightExclusionData(); |
| 800 |
if (exclusionData->isExcluded()) { |
| 801 |
return true; |
| 802 |
} |
| 803 |
return false; |
| 804 |
} |
| 805 |
|
| 806 |
|
| 807 |
bool CDatatypeCompareValueSpaceMap::isDataIntervalExcluded(CDataLiteralCompareValue* leftValueExcluded, CDatatypeCompareValueData* rightValueExcluded) { |
| 808 |
CDatatypeCompareValueDataExclusion* exclusionData = rightValueExcluded->getLeftExclusionData(); |
| 809 |
if (exclusionData->isExcluded()) { |
| 810 |
return true; |
| 811 |
} |
| 812 |
return false; |
| 813 |
} |
| 814 |
|
| 815 |
|
| 816 |
bool CDatatypeCompareValueSpaceMap::isDataIntervalExcluded(CDatatypeCompareValueData* leftValueExcluded, CDataLiteralCompareValue* rightValueExcluded) { |
| 817 |
CDatatypeCompareValueDataExclusion* exclusionData = leftValueExcluded->getRightExclusionData(); |
| 818 |
if (exclusionData->isExcluded()) { |
| 819 |
return true; |
| 820 |
} |
| 821 |
return false; |
| 822 |
} |
| 823 |
|
| 824 |
|
| 825 |
bool CDatatypeCompareValueSpaceMap::isDataIntervalExcluded(CDatatypeCompareValueData* leftValueExcluded, CDatatypeCompareValueData* rightValueExcluded) { |
| 826 |
return isDataIntervalExcluded(leftValueExcluded,rightValueExcluded->getValue()); |
| 827 |
} |
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
bool CDatatypeCompareValueSpaceMap::isDataValueExcluded(CDatatypeCompareValueData* valueData) { |
| 835 |
CDatatypeCompareValueDataExclusion* exclusionData = valueData->getValueExclusionData(); |
| 836 |
if (exclusionData->isExcluded()) { |
| 837 |
return true; |
| 838 |
} |
| 839 |
return false; |
| 840 |
} |
| 841 |
|
| 842 |
|
| 843 |
bool CDatatypeCompareValueSpaceMap::isDataValueExcluded(CDataLiteralCompareValue* value) { |
| 844 |
CDatatypeCompareValueSpaceMapArranger mapValueArranger(value); |
| 845 |
CDatatypeCompareValueSpaceMap::const_iterator itBegin = CDatatypeCompareValueSpaceMap::constBegin(), itLB = CDatatypeCompareValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeCompareValueSpaceMap::constEnd(); |
| 846 |
|
| 847 |
if (itBegin == itEnd) { |
| 848 |
return false; |
| 849 |
} |
| 850 |
if (itLB == itEnd) { |
| 851 |
return true; |
| 852 |
} |
| 853 |
const CDatatypeCompareValueSpaceMapData& mapData = itLB.value(); |
| 854 |
CDatatypeCompareValueData* valueData = mapData.mUseValue; |
| 855 |
CDatatypeCompareValueDataExclusion* exclusionData = nullptr; |
| 856 |
if (valueData->getValue()->isEqualTo(value)) { |
| 857 |
exclusionData = valueData->getValueExclusionData(); |
| 858 |
} else if (valueData->getValue()->isLessThan(value)) { |
| 859 |
exclusionData = valueData->getLeftExclusionData(); |
| 860 |
} else { |
| 861 |
exclusionData = valueData->getRightExclusionData(); |
| 862 |
} |
| 863 |
|
| 864 |
if (exclusionData) { |
| 865 |
CDatatypeCompareValueDataExclusion* exclusionData = valueData->getValueExclusionData(); |
| 866 |
if (exclusionData->isExcluded()) { |
| 867 |
return true; |
| 868 |
} |
| 869 |
} |
| 870 |
return false; |
| 871 |
} |
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
bool CDatatypeCompareValueSpaceMap::adaptNewCompareValueDataToNeighbours(CDatatypeCompareValueData* valueData) { |
| 876 |
CDatatypeCompareValueSpaceMapArranger mapValueArranger(valueData->getValue()); |
| 877 |
CDatatypeCompareValueSpaceMap::const_iterator itBegin = CDatatypeCompareValueSpaceMap::constBegin(), itLB = CDatatypeCompareValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeCompareValueSpaceMap::constEnd(); |
| 878 |
CDatatypeCompareValueSpaceMap::const_iterator itAdapt = itLB; |
| 879 |
bool rightNeighbour = true; |
| 880 |
++itAdapt; |
| 881 |
if (itAdapt == itEnd) { |
| 882 |
itAdapt = itLB; |
| 883 |
--itAdapt; |
| 884 |
rightNeighbour = false; |
| 885 |
} |
| 886 |
if (itAdapt != itEnd) { |
| 887 |
const CDatatypeCompareValueSpaceMapData& adaptMapData = itAdapt.value(); |
| 888 |
CDatatypeCompareValueData* adaptValueData = adaptMapData.mUseValue; |
| 889 |
CDatatypeCompareValueDataExclusion* exclusionData = nullptr; |
| 890 |
if (rightNeighbour) { |
| 891 |
exclusionData = adaptValueData->getLeftExclusionData(); |
| 892 |
} else { |
| 893 |
exclusionData = adaptValueData->getRightExclusionData(); |
| 894 |
} |
| 895 |
valueData->getValueExclusionData()->initDataExclusion(exclusionData); |
| 896 |
valueData->getLeftExclusionData()->initDataExclusion(exclusionData); |
| 897 |
valueData->getRightExclusionData()->initDataExclusion(exclusionData); |
| 898 |
return true; |
| 899 |
} |
| 900 |
return false; |
| 901 |
} |
| 902 |
|
| 903 |
|
| 904 |
CDatatypeCompareValueData* CDatatypeCompareValueSpaceMap::getDatatypeCompareValueData(CDataLiteralCompareValue* value, CDatatypeCompareValueSpaceMapData& valueMapData, bool createOrLocalize, bool* newValueInsertion) { |
| 905 |
if (newValueInsertion) { |
| 906 |
*newValueInsertion = false; |
| 907 |
} |
| 908 |
CDatatypeCompareValueData* compareValueData = nullptr; |
| 909 |
if (!valueMapData.mLocValue) { |
| 910 |
bool newlyCreated = false; |
| 911 |
CMemoryAllocationManager* taskMemMan = mProcessContext->getUsedMemoryAllocationManager(); |
| 912 |
compareValueData = CObjectParameterizingAllocator< CDatatypeCompareValueData,CProcessContext* >::allocateAndConstructAndParameterize(taskMemMan,mProcessContext); |
| 913 |
compareValueData->initCompareValueData(valueMapData.mUseValue,value); |
| 914 |
if (!valueMapData.mUseValue) { |
| 915 |
newlyCreated = true; |
| 916 |
} |
| 917 |
valueMapData.mUseValue = valueMapData.mLocValue = compareValueData; |
| 918 |
if (newlyCreated) { |
| 919 |
adaptNewCompareValueDataToNeighbours(compareValueData); |
| 920 |
} |
| 921 |
if (newlyCreated && newValueInsertion) { |
| 922 |
*newValueInsertion = true; |
| 923 |
} |
| 924 |
} else { |
| 925 |
compareValueData = valueMapData.mUseValue; |
| 926 |
} |
| 927 |
return compareValueData; |
| 928 |
} |
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
CDatatypeCompareValueData* CDatatypeCompareValueSpaceMap::getDatatypeCompareValueData(CDataLiteralCompareValue* value, bool createOrLocalize, bool* newValueInsertion) { |
| 933 |
if (newValueInsertion) { |
| 934 |
*newValueInsertion = false; |
| 935 |
} |
| 936 |
CDatatypeCompareValueData* compareValueData = nullptr; |
| 937 |
CDatatypeCompareValueSpaceMapArranger mapValueArranger(value); |
| 938 |
if (createOrLocalize) { |
| 939 |
CDatatypeCompareValueSpaceMapData& data = CPROCESSMAP<CDatatypeCompareValueSpaceMapArranger,CDatatypeCompareValueSpaceMapData>::operator[](mapValueArranger); |
| 940 |
compareValueData = getDatatypeCompareValueData(value,data,createOrLocalize,newValueInsertion); |
| 941 |
} else { |
| 942 |
CDatatypeCompareValueSpaceMapData data = CPROCESSMAP<CDatatypeCompareValueSpaceMapArranger,CDatatypeCompareValueSpaceMapData>::value(mapValueArranger); |
| 943 |
compareValueData = data.mUseValue; |
| 944 |
} |
| 945 |
return compareValueData; |
| 946 |
} |
| 947 |
|
| 948 |
|
| 949 |
bool CDatatypeCompareValueSpaceMap::hasExcludedMinimum(CDataLiteralCompareValue* value, bool valueInclusively) { |
| 950 |
|
| 951 |
if (mAbsoluteMinimumExclusionValue) { |
| 952 |
if (mAbsoluteMinimumExclusionValue->getValue()->isGreaterThan(value)) { |
| 953 |
return true; |
| 954 |
} |
| 955 |
if (mAbsoluteMinimumExclusionValue->getValue()->isEqualTo(value)) { |
| 956 |
if (isDataValueExcluded(mAbsoluteMinimumExclusionValue)) { |
| 957 |
return true; |
| 958 |
} |
| 959 |
if (!valueInclusively) { |
| 960 |
return true; |
| 961 |
} |
| 962 |
} |
| 963 |
} |
| 964 |
|
| 965 |
CDatatypeCompareValueSpaceMapArranger mapValueArranger(value); |
| 966 |
CDatatypeCompareValueSpaceMap::const_iterator itLB = CDatatypeCompareValueSpaceMap::lowerBound(mapValueArranger), it = CDatatypeCompareValueSpaceMap::constBegin(), itEnd = CDatatypeCompareValueSpaceMap::constEnd(); |
| 967 |
if (it == itEnd) { |
| 968 |
// no restrictions in value map |
| 969 |
return false; |
| 970 |
} |
| 971 |
if (it == itLB) { |
| 972 |
const CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 973 |
CDatatypeCompareValueData* compareValueData = mapData.mUseValue; |
| 974 |
if (!valueInclusively) { |
| 975 |
// value is before first value --> excluded |
| 976 |
return isLeftDataIntervalExcluded(compareValueData); |
| 977 |
} else { |
| 978 |
if (!isDataValueExcluded(compareValueData)) { |
| 979 |
return false; |
| 980 |
} |
| 981 |
return true; |
| 982 |
} |
| 983 |
} |
| 984 |
if (itLB == itEnd) { |
| 985 |
// value is after last value --> not excluded assuming value space is not clashed |
| 986 |
return false; |
| 987 |
} |
| 988 |
while (it != itEnd && it != itLB) { |
| 989 |
// try to find valid values before tested minimum value limit |
| 990 |
const CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 991 |
CDatatypeCompareValueData* compareValueData = mapData.mUseValue; |
| 992 |
if (!isDataValueExcluded(compareValueData)) { |
| 993 |
return false; |
| 994 |
} |
| 995 |
++it; |
| 996 |
|
| 997 |
if (it != itEnd) { |
| 998 |
const CDatatypeCompareValueSpaceMapData& nextMapData = it.value(); |
| 999 |
CDatatypeCompareValueData* nextCompareValueData = nextMapData.mUseValue; |
| 1000 |
if (it != itLB) { |
| 1001 |
if (!isDataIntervalExcluded(compareValueData,nextCompareValueData)) { |
| 1002 |
return false; |
| 1003 |
} |
| 1004 |
} else { |
| 1005 |
if (nextCompareValueData->getValue()->isEqualTo(value)) { |
| 1006 |
// value is in the value space map |
| 1007 |
if (!isDataIntervalExcluded(compareValueData,nextCompareValueData)) { |
| 1008 |
return false; |
| 1009 |
} |
| 1010 |
if (valueInclusively && !isDataValueExcluded(nextCompareValueData)) { |
| 1011 |
return false; |
| 1012 |
} |
| 1013 |
} else { |
| 1014 |
// test only to the tested minimum value limit |
| 1015 |
if (!isDataIntervalExcluded(compareValueData,value)) { |
| 1016 |
return false; |
| 1017 |
} |
| 1018 |
if (valueInclusively && !isDataValueExcluded(value)) { |
| 1019 |
return false; |
| 1020 |
} |
| 1021 |
} |
| 1022 |
} |
| 1023 |
} |
| 1024 |
} |
| 1025 |
return true; |
| 1026 |
} |
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
bool CDatatypeCompareValueSpaceMap::hasExcludedMaximum(CDataLiteralCompareValue* value, bool valueInclusively) { |
| 1031 |
|
| 1032 |
if (mAbsoluteMaximumExclusionValue) { |
| 1033 |
if (mAbsoluteMaximumExclusionValue->getValue()->isLessThan(value)) { |
| 1034 |
return true; |
| 1035 |
} |
| 1036 |
if (mAbsoluteMaximumExclusionValue->getValue()->isEqualTo(value)) { |
| 1037 |
if (isDataValueExcluded(mAbsoluteMaximumExclusionValue)) { |
| 1038 |
return true; |
| 1039 |
} |
| 1040 |
if (!valueInclusively) { |
| 1041 |
return true; |
| 1042 |
} |
| 1043 |
} |
| 1044 |
} |
| 1045 |
|
| 1046 |
CDatatypeCompareValueSpaceMapArranger mapValueArranger(value); |
| 1047 |
CDatatypeCompareValueSpaceMap::const_iterator itLB = CDatatypeCompareValueSpaceMap::lowerBound(mapValueArranger), it = CDatatypeCompareValueSpaceMap::constBegin(), itEnd = CDatatypeCompareValueSpaceMap::constEnd(); |
| 1048 |
if (it == itEnd) { |
| 1049 |
// no restrictions in value map |
| 1050 |
return false; |
| 1051 |
} |
| 1052 |
if (itLB == itEnd) { |
| 1053 |
// value is after last value --> excluded |
| 1054 |
return true; |
| 1055 |
} |
| 1056 |
it = itLB; |
| 1057 |
while (it != itEnd) { |
| 1058 |
const CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 1059 |
CDatatypeCompareValueData* compareValueData = mapData.mUseValue; |
| 1060 |
if (it == itLB) { |
| 1061 |
if (compareValueData->getValue()->isEqualTo(value)) { |
| 1062 |
if (valueInclusively && !isDataValueExcluded(compareValueData)) { |
| 1063 |
return false; |
| 1064 |
} |
| 1065 |
} else { |
| 1066 |
if (!isDataIntervalExcluded(value,compareValueData)) { |
| 1067 |
return false; |
| 1068 |
} |
| 1069 |
if (!isDataValueExcluded(compareValueData)) { |
| 1070 |
return false; |
| 1071 |
} |
| 1072 |
if (valueInclusively && !isDataValueExcluded(value)) { |
| 1073 |
return false; |
| 1074 |
} |
| 1075 |
} |
| 1076 |
} |
| 1077 |
++it; |
| 1078 |
if (it != itEnd) { |
| 1079 |
const CDatatypeCompareValueSpaceMapData& nextMapData = it.value(); |
| 1080 |
CDatatypeCompareValueData* nextCompareValueData = nextMapData.mUseValue; |
| 1081 |
|
| 1082 |
if (!isDataValueExcluded(nextCompareValueData)) { |
| 1083 |
return false; |
| 1084 |
} |
| 1085 |
if (!isDataIntervalExcluded(compareValueData,nextCompareValueData)) { |
| 1086 |
return false; |
| 1087 |
} |
| 1088 |
} else { |
| 1089 |
if (!isRightDataIntervalExcluded(compareValueData)) { |
| 1090 |
return false; |
| 1091 |
} |
| 1092 |
} |
| 1093 |
} |
| 1094 |
return true; |
| 1095 |
} |
| 1096 |
|
| 1097 |
|
| 1098 |
bool CDatatypeCompareValueSpaceMap::isValueExcluded(CDataLiteralCompareValue* value) { |
| 1099 |
if (isDataValueExcluded(value)) { |
| 1100 |
return true; |
| 1101 |
} |
| 1102 |
return false; |
| 1103 |
} |
| 1104 |
|
| 1105 |
|
| 1106 |
|
| 1107 |
bool CDatatypeCompareValueSpaceMap::getNextPossibleDataValue(CDataLiteralCompareValue* nextValue, CDataLiteralCompareValue* lastValue) { |
| 1108 |
|
| 1109 |
if (!lastValue) { |
| 1110 |
if (!mAbsoluteMinimumExclusionValue) { |
| 1111 |
return false; |
| 1112 |
} |
| 1113 |
lastValue = mAbsoluteMinimumExclusionValue->getValue(); |
| 1114 |
if (!isDataValueExcluded(mAbsoluteMinimumExclusionValue)) { |
| 1115 |
if (representsInfinitelyManyValues(lastValue)) { |
| 1116 |
return false; |
| 1117 |
} else { |
| 1118 |
getValueCopy(nextValue,lastValue); |
| 1119 |
return true; |
| 1120 |
} |
| 1121 |
} |
| 1122 |
} |
| 1123 |
|
| 1124 |
|
| 1125 |
CDatatypeCompareValueSpaceMapArranger mapValueArranger(lastValue); |
| 1126 |
CDatatypeCompareValueSpaceMap::iterator itBegin = CDatatypeCompareValueSpaceMap::begin(), itLB = CDatatypeCompareValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeCompareValueSpaceMap::end(); |
| 1127 |
CDatatypeCompareValueSpaceMap::iterator it = itLB; |
| 1128 |
while (it != itEnd) { |
| 1129 |
|
| 1130 |
if (it == itLB) { |
| 1131 |
CDatatypeCompareValueData* itValueData = it.value().mUseValue; |
| 1132 |
while (lastValue->isLessThan(itValueData->getValue())) { |
| 1133 |
CDatatypeCompareValueSpaceMap::iterator itLast = it; |
| 1134 |
--itLast; |
| 1135 |
if (itLast != itEnd) { |
| 1136 |
--it; |
| 1137 |
} else { |
| 1138 |
if (!isLeftDataIntervalExcluded(itValueData)) { |
| 1139 |
getValueNext(nextValue,lastValue); |
| 1140 |
if (nextValue->isLessThan(itValueData->getValue())) { |
| 1141 |
return true; |
| 1142 |
} else if (nextValue->isEqualTo(itValueData->getValue())) { |
| 1143 |
if (!isDataValueExcluded(itValueData)) { |
| 1144 |
return true; |
| 1145 |
} |
| 1146 |
} |
| 1147 |
} |
| 1148 |
break; |
| 1149 |
} |
| 1150 |
} |
| 1151 |
} |
| 1152 |
CDatatypeCompareValueSpaceMapData& mapData = it.value(); |
| 1153 |
CDatatypeCompareValueData* itValueData = mapData.mUseValue; |
| 1154 |
|
| 1155 |
if (itValueData->getValue()->isGreaterThan(lastValue)) { |
| 1156 |
lastValue = itValueData->getValue(); |
| 1157 |
} |
| 1158 |
|
| 1159 |
++it; |
| 1160 |
if (it != itEnd) { |
| 1161 |
CDatatypeCompareValueSpaceMapData& nextMapData = it.value(); |
| 1162 |
CDatatypeCompareValueData* nextValueData = nextMapData.mUseValue; |
| 1163 |
|
| 1164 |
if (!isDataIntervalExcluded(itValueData,nextValueData)) { |
| 1165 |
getValueNext(nextValue,lastValue); |
| 1166 |
if (nextValue->isLessThan(nextValueData->getValue())) { |
| 1167 |
return true; |
| 1168 |
} else if (nextValue->isEqualTo(nextValueData->getValue())) { |
| 1169 |
if (!isDataValueExcluded(nextValueData)) { |
| 1170 |
return true; |
| 1171 |
} |
| 1172 |
} |
| 1173 |
} else if (!isDataValueExcluded(nextValueData)) { |
| 1174 |
getValueNext(nextValue,lastValue); |
| 1175 |
if (nextValue->isEqualTo(nextValueData->getValue())) { |
| 1176 |
return true; |
| 1177 |
} |
| 1178 |
} |
| 1179 |
} else { |
| 1180 |
if (!isRightDataIntervalExcluded(itValueData)) { |
| 1181 |
return false; |
| 1182 |
} else { |
| 1183 |
getValueNext(nextValue,lastValue); |
| 1184 |
return true; |
| 1185 |
} |
| 1186 |
} |
| 1187 |
|
| 1188 |
} |
| 1189 |
return false; |
| 1190 |
} |
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
}; // end namespace Process |
| 1195 |
|
| 1196 |
}; // end namespace Kernel |
| 1197 |
|
| 1198 |
}; // end namespace Reasoner |
| 1199 |
|
| 1200 |
}; // end namespace Konclude |