| 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 "CDatatypeRealValueSpaceMap.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Process { |
| 31 |
|
| 32 |
|
| 33 |
CDatatypeRealValueSpaceMap::CDatatypeRealValueSpaceMap(CProcessContext* processContext) : CPROCESSMAP<CDatatypeRealValueSpaceMapArranger,CDatatypeRealValueSpaceMapData>(processContext),mProcessContext(processContext) { |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
CDatatypeRealValueSpaceMap* CDatatypeRealValueSpaceMap::initDatatypeRealValueSpaceMap(CDatatypeRealValueSpaceMap* map) { |
| 38 |
if (map) { |
| 39 |
CPROCESSMAP<CDatatypeRealValueSpaceMapArranger, CDatatypeRealValueSpaceMapData>::operator=(*map); |
| 40 |
mAbsoluteMinimumExclusionValue = map->mAbsoluteMinimumExclusionValue; |
| 41 |
mAbsoluteMaximumExclusionValue = map->mAbsoluteMaximumExclusionValue; |
| 42 |
} |
| 43 |
return this; |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
CDatatypeRealValueSpaceMap* CDatatypeRealValueSpaceMap::initDatatypeRealValueSpaceMap(CDatatypeValueSpaceRealType* valueSpaceType) { |
| 49 |
CPROCESSMAP<CDatatypeRealValueSpaceMapArranger,CDatatypeRealValueSpaceMapData>::clear(); |
| 50 |
mAbsoluteMinimumExclusionValue = nullptr; |
| 51 |
mAbsoluteMaximumExclusionValue = nullptr; |
| 52 |
|
| 53 |
excludeMinimum(valueSpaceType->getMinimumDataLiteralRealValue(),false,nullptr); |
| 54 |
excludeMaximum(valueSpaceType->getMaximumDataLiteralRealValue(),false,nullptr); |
| 55 |
return this; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
bool CDatatypeRealValueSpaceMap::getAbsoluteMinimumValue(CDataLiteralRealValue*& 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 CDatatypeRealValueSpaceMap::getAbsoluteMaximumValue(CDataLiteralRealValue*& 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 CDatatypeRealValueSpaceMap::excludeMinimum(CDataLiteralRealValue* 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 |
CDatatypeRealValueData* valueData = getDatatypeRealValueData(value,true); |
| 107 |
newValuesPotentiallyExcluded |= excludeLeftDataInterval(valueData,depTrackPoint,nullptr,true); |
| 108 |
if (valueInclusively && !isDataValueExcluded(valueData,nullptr)) { |
| 109 |
newValuesPotentiallyExcluded |= excludeDataValue(valueData,depTrackPoint,nullptr,false); |
| 110 |
} |
| 111 |
mAbsoluteMinimumExclusionValue = valueData; |
| 112 |
|
| 113 |
// remove all lower values from map |
| 114 |
CDatatypeRealValueSpaceMap::iterator it = CDatatypeRealValueSpaceMap::begin(), itEnd = CDatatypeRealValueSpaceMap::end(); |
| 115 |
while (it != itEnd) { |
| 116 |
const CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 117 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 118 |
if (itValueData == valueData) { |
| 119 |
break; |
| 120 |
} |
| 121 |
newValuesPotentiallyExcluded = true; |
| 122 |
it = CDatatypeRealValueSpaceMap::erase(it); |
| 123 |
} |
| 124 |
|
| 125 |
return newValuesPotentiallyExcluded; |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
bool CDatatypeRealValueSpaceMap::excludeMaximum(CDataLiteralRealValue* 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 |
CDatatypeRealValueData* valueData = getDatatypeRealValueData(value,true); |
| 140 |
newValuesPotentiallyExcluded |= excludeRightDataInterval(valueData,depTrackPoint,nullptr,true); |
| 141 |
if (valueInclusively && !isDataValueExcluded(valueData,nullptr)) { |
| 142 |
newValuesPotentiallyExcluded |= excludeDataValue(valueData,depTrackPoint,nullptr,false); |
| 143 |
} |
| 144 |
mAbsoluteMaximumExclusionValue = valueData; |
| 145 |
|
| 146 |
// remove all higher values from map |
| 147 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(value); |
| 148 |
CDatatypeRealValueSpaceMap::iterator itBegin = CDatatypeRealValueSpaceMap::begin(), itUB = CDatatypeRealValueSpaceMap::upperBound(mapValueArranger), itEnd = CDatatypeRealValueSpaceMap::end(); |
| 149 |
CDatatypeRealValueSpaceMap::iterator it = itUB; |
| 150 |
while (it != itEnd) { |
| 151 |
const CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 152 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 153 |
it = CDatatypeRealValueSpaceMap::erase(it); |
| 154 |
newValuesPotentiallyExcluded = true; |
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
return newValuesPotentiallyExcluded; |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
bool CDatatypeRealValueSpaceMap::excludeMinimum(CDataLiteralRealValue* value, bool valueInclusively, CDependencyTrackPoint* depTrackPoint, CDatatypeRealValueExclusionType* exclusionType) { |
| 172 |
bool newValuesPotentiallyExcluded = false; |
| 173 |
|
| 174 |
CDatatypeRealValueData* valueData = getDatatypeRealValueData(value,true); |
| 175 |
if (valueInclusively && !isDataValueExcluded(valueData,exclusionType)) { |
| 176 |
newValuesPotentiallyExcluded |= excludeDataValue(valueData,depTrackPoint,exclusionType,false); |
| 177 |
} |
| 178 |
|
| 179 |
CDatatypeRealValueSpaceMap::iterator itBegin = CDatatypeRealValueSpaceMap::begin(), itEnd = CDatatypeRealValueSpaceMap::end(); |
| 180 |
CDatatypeRealValueSpaceMap::iterator it = itBegin; |
| 181 |
while (it != itEnd) { |
| 182 |
CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 183 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 184 |
|
| 185 |
if (it == itBegin) { |
| 186 |
if (!isLeftDataIntervalExcluded(itValueData,exclusionType)) { |
| 187 |
itValueData = getDatatypeRealValueData(itValueData->getValue(),mapData,true,nullptr); |
| 188 |
newValuesPotentiallyExcluded |= excludeLeftDataInterval(itValueData,depTrackPoint,exclusionType,false); |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
if (itValueData != valueData) { |
| 193 |
if (!isDataValueExcluded(itValueData,exclusionType)) { |
| 194 |
itValueData = getDatatypeRealValueData(itValueData->getValue(),mapData,true,nullptr); |
| 195 |
newValuesPotentiallyExcluded |= excludeDataValue(itValueData,depTrackPoint,exclusionType,false); |
| 196 |
} |
| 197 |
|
| 198 |
++it; |
| 199 |
if (it != itEnd) { |
| 200 |
CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 201 |
CDatatypeRealValueData* nextValueData = nextMapData.mUseValue; |
| 202 |
|
| 203 |
if (!isDataIntervalExcluded(itValueData,nextValueData,exclusionType)) { |
| 204 |
itValueData = getDatatypeRealValueData(itValueData->getValue(),mapData,true,nullptr); |
| 205 |
newValuesPotentiallyExcluded |= excludeRightDataInterval(itValueData,depTrackPoint,exclusionType,false); |
| 206 |
nextValueData = getDatatypeRealValueData(nextValueData->getValue(),nextMapData,true,nullptr); |
| 207 |
newValuesPotentiallyExcluded |= excludeLeftDataInterval(nextValueData,depTrackPoint,exclusionType,false); |
| 208 |
} |
| 209 |
} |
| 210 |
} else { |
| 211 |
break; |
| 212 |
} |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
return newValuesPotentiallyExcluded; |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
bool CDatatypeRealValueSpaceMap::excludeMaximum(CDataLiteralRealValue* value, bool valueInclusively, CDependencyTrackPoint* depTrackPoint, CDatatypeRealValueExclusionType* exclusionType) { |
| 222 |
bool newValuesPotentiallyExcluded = false; |
| 223 |
|
| 224 |
CDatatypeRealValueData* valueData = getDatatypeRealValueData(value,true); |
| 225 |
if (valueInclusively && !isDataValueExcluded(valueData,nullptr)) { |
| 226 |
newValuesPotentiallyExcluded |= excludeDataValue(valueData,depTrackPoint,nullptr,false); |
| 227 |
} |
| 228 |
|
| 229 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(value); |
| 230 |
CDatatypeRealValueSpaceMap::iterator itBegin = CDatatypeRealValueSpaceMap::begin(), itLB = CDatatypeRealValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeRealValueSpaceMap::end(); |
| 231 |
CDatatypeRealValueSpaceMap::iterator it = itLB; |
| 232 |
while (it != itEnd) { |
| 233 |
CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 234 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 235 |
|
| 236 |
if (itValueData != valueData) { |
| 237 |
if (!isDataValueExcluded(itValueData,exclusionType)) { |
| 238 |
itValueData = getDatatypeRealValueData(itValueData->getValue(),mapData,true,nullptr); |
| 239 |
newValuesPotentiallyExcluded |= excludeDataValue(itValueData,depTrackPoint,exclusionType,false); |
| 240 |
} |
| 241 |
} |
| 242 |
|
| 243 |
++it; |
| 244 |
if (it != itEnd) { |
| 245 |
CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 246 |
CDatatypeRealValueData* nextValueData = nextMapData.mUseValue; |
| 247 |
|
| 248 |
if (!isDataIntervalExcluded(itValueData,nextValueData,exclusionType)) { |
| 249 |
itValueData = getDatatypeRealValueData(itValueData->getValue(),mapData,true,nullptr); |
| 250 |
newValuesPotentiallyExcluded |= excludeRightDataInterval(itValueData,depTrackPoint,exclusionType,false); |
| 251 |
nextValueData = getDatatypeRealValueData(nextValueData->getValue(),nextMapData,true,nullptr); |
| 252 |
newValuesPotentiallyExcluded |= excludeLeftDataInterval(nextValueData,depTrackPoint,exclusionType,false); |
| 253 |
} |
| 254 |
} else { |
| 255 |
|
| 256 |
if (!isRightDataIntervalExcluded(itValueData,exclusionType)) { |
| 257 |
itValueData = getDatatypeRealValueData(itValueData->getValue(),mapData,true,nullptr); |
| 258 |
newValuesPotentiallyExcluded |= excludeLeftDataInterval(itValueData,depTrackPoint,exclusionType,false); |
| 259 |
} |
| 260 |
} |
| 261 |
} |
| 262 |
|
| 263 |
return newValuesPotentiallyExcluded; |
| 264 |
} |
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
bool CDatatypeRealValueSpaceMap::excludeAll(CDependencyTrackPoint* depTrackPoint, CDatatypeRealValueExclusionType* exclusionType) { |
| 269 |
bool newValuesPotentiallyExcluded = false; |
| 270 |
|
| 271 |
CDatatypeRealValueSpaceMap::iterator itBegin = CDatatypeRealValueSpaceMap::begin(), itEnd = CDatatypeRealValueSpaceMap::end(); |
| 272 |
CDatatypeRealValueSpaceMap::iterator it = itBegin; |
| 273 |
|
| 274 |
while (it != itEnd) { |
| 275 |
CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 276 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 277 |
|
| 278 |
if (it == itBegin) { |
| 279 |
if (!isLeftDataIntervalExcluded(itValueData,exclusionType)) { |
| 280 |
itValueData = getDatatypeRealValueData(itValueData->getValue(),mapData,true,nullptr); |
| 281 |
newValuesPotentiallyExcluded |= excludeLeftDataInterval(itValueData,depTrackPoint,exclusionType,false); |
| 282 |
} |
| 283 |
if (!isDataValueExcluded(itValueData,exclusionType)) { |
| 284 |
itValueData = getDatatypeRealValueData(itValueData->getValue(),mapData,true,nullptr); |
| 285 |
newValuesPotentiallyExcluded |= excludeDataValue(itValueData,depTrackPoint,exclusionType,false); |
| 286 |
} |
| 287 |
} |
| 288 |
|
| 289 |
++it; |
| 290 |
if (it != itEnd) { |
| 291 |
CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 292 |
CDatatypeRealValueData* nextValueData = nextMapData.mUseValue; |
| 293 |
|
| 294 |
if (!isDataIntervalExcluded(itValueData,nextValueData,exclusionType)) { |
| 295 |
itValueData = getDatatypeRealValueData(itValueData->getValue(),mapData,true,nullptr); |
| 296 |
newValuesPotentiallyExcluded |= excludeRightDataInterval(itValueData,depTrackPoint,exclusionType,false); |
| 297 |
nextValueData = getDatatypeRealValueData(nextValueData->getValue(),nextMapData,true,nullptr); |
| 298 |
newValuesPotentiallyExcluded |= excludeLeftDataInterval(nextValueData,depTrackPoint,exclusionType,false); |
| 299 |
} |
| 300 |
if (!isDataValueExcluded(nextValueData,exclusionType)) { |
| 301 |
nextValueData = getDatatypeRealValueData(nextValueData->getValue(),nextMapData,true,nullptr); |
| 302 |
newValuesPotentiallyExcluded |= excludeDataValue(nextValueData,depTrackPoint,exclusionType,false); |
| 303 |
} |
| 304 |
|
| 305 |
|
| 306 |
} else { |
| 307 |
if (!isRightDataIntervalExcluded(itValueData,exclusionType)) { |
| 308 |
itValueData = getDatatypeRealValueData(itValueData->getValue(),mapData,true,nullptr); |
| 309 |
newValuesPotentiallyExcluded |= excludeRightDataInterval(itValueData,depTrackPoint,exclusionType,false); |
| 310 |
} |
| 311 |
} |
| 312 |
|
| 313 |
} |
| 314 |
|
| 315 |
return newValuesPotentiallyExcluded; |
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
bool CDatatypeRealValueSpaceMap::excludeInterval(CDataLiteralRealValue* leftValue, bool leftValueInclusive, CDataLiteralRealValue* rightValue, bool rightValueInclusive, CDependencyTrackPoint* depTrackPoint, CDatatypeRealValueExclusionType* exclusionType) { |
| 324 |
bool newValuesPotentiallyExcluded = false; |
| 325 |
|
| 326 |
CDatatypeRealValueData* leftValueData = getDatatypeRealValueData(leftValue,true); |
| 327 |
CDatatypeRealValueData* rightValueData = getDatatypeRealValueData(rightValue,true); |
| 328 |
|
| 329 |
if (leftValueInclusive && !isDataValueExcluded(leftValueData,exclusionType)) { |
| 330 |
newValuesPotentiallyExcluded |= excludeDataValue(leftValueData,depTrackPoint,exclusionType,false); |
| 331 |
} |
| 332 |
|
| 333 |
if (leftValueInclusive && !isDataValueExcluded(rightValueData,exclusionType)) { |
| 334 |
newValuesPotentiallyExcluded |= excludeDataValue(rightValueData,depTrackPoint,exclusionType,false); |
| 335 |
} |
| 336 |
|
| 337 |
|
| 338 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(leftValue); |
| 339 |
CDatatypeRealValueSpaceMap::iterator itBegin = CDatatypeRealValueSpaceMap::begin(), itLB = CDatatypeRealValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeRealValueSpaceMap::end(); |
| 340 |
CDatatypeRealValueSpaceMap::iterator it = itLB; |
| 341 |
while (it != itEnd) { |
| 342 |
CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 343 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 344 |
|
| 345 |
++it; |
| 346 |
if (it != itEnd) { |
| 347 |
CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 348 |
CDatatypeRealValueData* nextValueData = nextMapData.mUseValue; |
| 349 |
|
| 350 |
if (!isDataIntervalExcluded(itValueData,nextValueData,exclusionType)) { |
| 351 |
itValueData = getDatatypeRealValueData(itValueData->getValue(),mapData,true,nullptr); |
| 352 |
newValuesPotentiallyExcluded |= excludeRightDataInterval(itValueData,depTrackPoint,exclusionType,false); |
| 353 |
nextValueData = getDatatypeRealValueData(nextValueData->getValue(),nextMapData,true,nullptr); |
| 354 |
newValuesPotentiallyExcluded |= excludeLeftDataInterval(nextValueData,depTrackPoint,exclusionType,false); |
| 355 |
} |
| 356 |
|
| 357 |
if (nextValueData == rightValueData) { |
| 358 |
break; |
| 359 |
} |
| 360 |
|
| 361 |
if (!isDataValueExcluded(nextValueData,exclusionType)) { |
| 362 |
nextValueData = getDatatypeRealValueData(nextValueData->getValue(),nextMapData,true,nullptr); |
| 363 |
newValuesPotentiallyExcluded |= excludeDataValue(nextValueData,depTrackPoint,exclusionType,false); |
| 364 |
} |
| 365 |
} |
| 366 |
} |
| 367 |
|
| 368 |
return newValuesPotentiallyExcluded; |
| 369 |
} |
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
bool CDatatypeRealValueSpaceMap::countDataIntervalValues(CDatatypeRealValueData* leftValueExcluded, CDatatypeRealValueData* rightValueExcluded, CDatatypeValueSpaceValuesCounter* counter) { |
| 378 |
return countDataIntervalValues(leftValueExcluded->getValue(),rightValueExcluded->getValue(),leftValueExcluded->getRightExclusionData(),counter); |
| 379 |
} |
| 380 |
|
| 381 |
bool CDatatypeRealValueSpaceMap::countDataIntervalValues(CDataLiteralRealValue* leftValueExcluded, CDatatypeRealValueData* rightValueExcluded, CDatatypeValueSpaceValuesCounter* counter) { |
| 382 |
return countDataIntervalValues(leftValueExcluded,rightValueExcluded->getValue(),rightValueExcluded->getLeftExclusionData(),counter); |
| 383 |
} |
| 384 |
|
| 385 |
|
| 386 |
bool CDatatypeRealValueSpaceMap::countDataIntervalValues(CDatatypeRealValueData* leftValueExcluded, CDataLiteralRealValue* rightValueExcluded, CDatatypeValueSpaceValuesCounter* counter) { |
| 387 |
return countDataIntervalValues(leftValueExcluded->getValue(),rightValueExcluded,leftValueExcluded->getRightExclusionData(),counter); |
| 388 |
} |
| 389 |
|
| 390 |
|
| 391 |
bool CDatatypeRealValueSpaceMap::countDataIntervalValues(CDataLiteralRealValue* leftValueExcluded, CDataLiteralRealValue* rightValueExcluded, CDatatypeRealValueDataExclusion* exlcusionData, CDatatypeValueSpaceValuesCounter* counter) { |
| 392 |
bool counted = false; |
| 393 |
if (!exlcusionData->isEverythingExcluded()) { |
| 394 |
|
| 395 |
if (leftValueExcluded->isInfiniteBigNumber() || rightValueExcluded->isInfiniteBigNumber()) { |
| 396 |
counted |= counter->incInfinite(); |
| 397 |
} else { |
| 398 |
if (exlcusionData->areOnlyIntegerValuesAllowed()) { |
| 399 |
if (rightValueExcluded->hasFlag(CDataLiteralRealValue::DLRV_INTEGER_FLAG)) { |
| 400 |
cint64 incCount = rightValueExcluded->getPosNegInteger() - leftValueExcluded->getPosNegInteger() - 1; |
| 401 |
counted |= counter->incValueCount(incCount); |
| 402 |
} else { |
| 403 |
cint64 incCount = rightValueExcluded->getPosNegInteger() - leftValueExcluded->getPosNegInteger(); |
| 404 |
counted |= counter->incValueCount(incCount); |
| 405 |
} |
| 406 |
} else { |
| 407 |
counted |= counter->incInfinite(); |
| 408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
CDatatypeValueSpaceRealValuesCounter* realValuesCounter = dynamic_cast<CDatatypeValueSpaceRealValuesCounter*>(counter); |
| 412 |
if (realValuesCounter) { |
| 413 |
if (!exlcusionData->areIntegerValuesExcluded()) { |
| 414 |
if (leftValueExcluded->isInfiniteBigNumber() || rightValueExcluded->isInfiniteBigNumber()) { |
| 415 |
counted |= realValuesCounter->incInfinite(CDatatypeValueSpaceRealValuesCounter::RVT_INTEGER_ALL_COUNT); |
| 416 |
} |
| 417 |
if (rightValueExcluded->hasFlag(CDataLiteralRealValue::DLRV_INTEGER_FLAG)) { |
| 418 |
cint64 incCount = rightValueExcluded->getPosNegInteger() - leftValueExcluded->getPosNegInteger() - 1; |
| 419 |
counted |= realValuesCounter->incValueCount(CDatatypeValueSpaceRealValuesCounter::RVT_INTEGER_ALL_COUNT,incCount); |
| 420 |
} else { |
| 421 |
cint64 incCount = rightValueExcluded->getPosNegInteger() - leftValueExcluded->getPosNegInteger(); |
| 422 |
counted |= realValuesCounter->incValueCount(CDatatypeValueSpaceRealValuesCounter::RVT_INTEGER_ALL_COUNT,incCount); |
| 423 |
} |
| 424 |
} |
| 425 |
|
| 426 |
if (!exlcusionData->areDecimalValuesExcluded()) { |
| 427 |
counted |= realValuesCounter->incInfinite(CDatatypeValueSpaceRealValuesCounter::RVT_DECIMAL_ALL_COUNT); |
| 428 |
} else if (!exlcusionData->areRationalValuesExcluded()) { |
| 429 |
counted |= realValuesCounter->incInfinite(CDatatypeValueSpaceRealValuesCounter::RVT_RATIONAL_ALL_COUNT); |
| 430 |
} |
| 431 |
|
| 432 |
if (!exlcusionData->areRealValuesExcluded()) { |
| 433 |
counted |= realValuesCounter->incInfinite(CDatatypeValueSpaceRealValuesCounter::RVT_NON_RATIONAL_ALL_COUNT); |
| 434 |
} else if (!exlcusionData->areRationalValuesExcluded()) { |
| 435 |
counted |= realValuesCounter->incInfinite(CDatatypeValueSpaceRealValuesCounter::RVT_NON_DECIMAL_ALL_COUNT); |
| 436 |
} else if (!exlcusionData->areDecimalValuesExcluded()) { |
| 437 |
counted |= realValuesCounter->incInfinite(CDatatypeValueSpaceRealValuesCounter::RVT_NON_INTEGER_ALL_COUNT); |
| 438 |
} |
| 439 |
|
| 440 |
} |
| 441 |
} |
| 442 |
return counted; |
| 443 |
} |
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
bool CDatatypeRealValueSpaceMap::countDataValue(CDatatypeRealValueData* dataValue, CDatatypeValueSpaceValuesCounter* counter) { |
| 449 |
return countDataValue(dataValue->getValue(),dataValue->getValueExclusionData(),counter); |
| 450 |
} |
| 451 |
|
| 452 |
|
| 453 |
bool CDatatypeRealValueSpaceMap::countDataValue(CDataLiteralRealValue* value, CDatatypeRealValueDataExclusion* exlcusionData, CDatatypeValueSpaceValuesCounter* counter) { |
| 454 |
bool counted = false; |
| 455 |
if (!exlcusionData->isEverythingExcluded()) { |
| 456 |
|
| 457 |
if (value->isInfinite()) { |
| 458 |
counted |= counter->incInfinite(); |
| 459 |
} else { |
| 460 |
counted |= counter->incValueCount(1); |
| 461 |
} |
| 462 |
|
| 463 |
CDatatypeValueSpaceRealValuesCounter* realValuesCounter = dynamic_cast<CDatatypeValueSpaceRealValuesCounter*>(counter); |
| 464 |
if (realValuesCounter) { |
| 465 |
|
| 466 |
if (value->isInfinite()) { |
| 467 |
counted |= realValuesCounter->incInfinite(CDatatypeValueSpaceRealValuesCounter::RVT_INTEGER_ALL_COUNT); |
| 468 |
if (!exlcusionData->areDecimalValuesExcluded()) { |
| 469 |
counted |= realValuesCounter->incInfinite(CDatatypeValueSpaceRealValuesCounter::RVT_NON_INTEGER_ONLY_COUNT); |
| 470 |
} |
| 471 |
if (!exlcusionData->areRationalValuesExcluded()) { |
| 472 |
counted |= realValuesCounter->incInfinite(CDatatypeValueSpaceRealValuesCounter::RVT_NON_INTEGER_ONLY_COUNT); |
| 473 |
counted |= realValuesCounter->incInfinite(CDatatypeValueSpaceRealValuesCounter::RVT_NON_DECIMAL_ONLY_COUNT); |
| 474 |
} |
| 475 |
} else { |
| 476 |
if (value->hasFlag(CDataLiteralRealValue::DLRV_INTEGER_FLAG)) { |
| 477 |
counted |= realValuesCounter->incValueCount(CDatatypeValueSpaceRealValuesCounter::RVT_INTEGER_ONLY_COUNT,1); |
| 478 |
} else { |
| 479 |
counted |= realValuesCounter->incValueCount(CDatatypeValueSpaceRealValuesCounter::RVT_NON_INTEGER_ONLY_COUNT,1); |
| 480 |
} |
| 481 |
if (value->hasFlag(CDataLiteralRealValue::DLRV_DECIMAL_FLAG)) { |
| 482 |
counted |= realValuesCounter->incValueCount(CDatatypeValueSpaceRealValuesCounter::RVT_DECIMAL_ONLY_COUNT,1); |
| 483 |
} else { |
| 484 |
counted |= realValuesCounter->incValueCount(CDatatypeValueSpaceRealValuesCounter::RVT_NON_DECIMAL_ONLY_COUNT,1); |
| 485 |
} |
| 486 |
counted |= realValuesCounter->incValueCount(CDatatypeValueSpaceRealValuesCounter::RVT_RATIONAL_ONLY_COUNT,1); |
| 487 |
} |
| 488 |
|
| 489 |
|
| 490 |
} |
| 491 |
|
| 492 |
} |
| 493 |
return counted; |
| 494 |
} |
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
bool CDatatypeRealValueSpaceMap::countValueValues(CDataLiteralRealValue* value, CDatatypeValueSpaceValuesCounter* counter) { |
| 500 |
bool counted = false; |
| 501 |
if (mAbsoluteMinimumExclusionValue) { |
| 502 |
if (value->isLessThan(mAbsoluteMinimumExclusionValue->getValue())) { |
| 503 |
return false; |
| 504 |
} |
| 505 |
} |
| 506 |
if (mAbsoluteMaximumExclusionValue) { |
| 507 |
if (value->isGreaterThan(mAbsoluteMaximumExclusionValue->getValue())) { |
| 508 |
return false; |
| 509 |
} |
| 510 |
} |
| 511 |
|
| 512 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(value); |
| 513 |
CDatatypeRealValueSpaceMap::iterator itBegin = CDatatypeRealValueSpaceMap::begin(), itLB = CDatatypeRealValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeRealValueSpaceMap::end(); |
| 514 |
CDatatypeRealValueSpaceMap::iterator it = itLB; |
| 515 |
|
| 516 |
|
| 517 |
if (it != itEnd) { |
| 518 |
CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 519 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 520 |
|
| 521 |
if (value->isEqualTo(itValueData->getValue())) { |
| 522 |
if (!isDataValueExcluded(itValueData,nullptr)) { |
| 523 |
counted |= countDataValue(itValueData,counter); |
| 524 |
} |
| 525 |
} else { |
| 526 |
if (!isDataValueExcluded(value,nullptr)) { |
| 527 |
counted |= countDataValue(value,itValueData->getLeftExclusionData(),counter); |
| 528 |
} |
| 529 |
} |
| 530 |
} |
| 531 |
|
| 532 |
return counted; |
| 533 |
} |
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
bool CDatatypeRealValueSpaceMap::addIntervalExclusionDependencies(CDataLiteralRealValue* leftValue, bool leftValueInclusive, CDataLiteralRealValue* rightValue, bool rightValueInclusive, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 542 |
if (mAbsoluteMinimumExclusionValue) { |
| 543 |
if (leftValue->isLessThan(mAbsoluteMinimumExclusionValue->getValue())) { |
| 544 |
leftValue = mAbsoluteMinimumExclusionValue->getValue(); |
| 545 |
} |
| 546 |
} |
| 547 |
if (mAbsoluteMaximumExclusionValue) { |
| 548 |
if (rightValue->isGreaterThan(mAbsoluteMaximumExclusionValue->getValue())) { |
| 549 |
rightValue = mAbsoluteMaximumExclusionValue->getValue(); |
| 550 |
} |
| 551 |
} |
| 552 |
|
| 553 |
if (leftValue->isGreaterThan(rightValue)) { |
| 554 |
return false; |
| 555 |
} else if (leftValue->isEqualTo(rightValue)) { |
| 556 |
if (!leftValueInclusive && !rightValueInclusive) { |
| 557 |
return false; |
| 558 |
} |
| 559 |
} |
| 560 |
|
| 561 |
|
| 562 |
bool depAdded = false; |
| 563 |
|
| 564 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(leftValue); |
| 565 |
CDatatypeRealValueSpaceMap::iterator itBegin = CDatatypeRealValueSpaceMap::begin(), itLB = CDatatypeRealValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeRealValueSpaceMap::end(); |
| 566 |
CDatatypeRealValueSpaceMap::iterator it = itLB; |
| 567 |
|
| 568 |
|
| 569 |
while (it != itEnd) { |
| 570 |
CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 571 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 572 |
|
| 573 |
if (it == itLB) { |
| 574 |
if (leftValue->isEqualTo(itValueData->getValue())) { |
| 575 |
if (leftValueInclusive) { |
| 576 |
depAdded |= addDataValueExclusionDependencies(itValueData,depCollector); |
| 577 |
} |
| 578 |
} else { |
| 579 |
depAdded |= addExclusionDependencies(itValueData->getLeftExclusionData(),depCollector); |
| 580 |
} |
| 581 |
} |
| 582 |
|
| 583 |
++it; |
| 584 |
if (it != itEnd) { |
| 585 |
CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 586 |
CDatatypeRealValueData* nextValueData = nextMapData.mUseValue; |
| 587 |
|
| 588 |
depAdded |= addDataIntervalExclusionDependencies(itValueData,nextValueData,depCollector); |
| 589 |
|
| 590 |
if (nextValueData->getValue()->isEqualTo(rightValue)) { |
| 591 |
if (rightValueInclusive) { |
| 592 |
depAdded |= addDataValueExclusionDependencies(nextValueData,depCollector); |
| 593 |
} |
| 594 |
break; |
| 595 |
} else if (nextValueData->getValue()->isGreaterThan(rightValue)) { |
| 596 |
depAdded |= addExclusionDependencies(itValueData->getRightExclusionData(),depCollector); |
| 597 |
break; |
| 598 |
} |
| 599 |
|
| 600 |
depAdded |= addDataValueExclusionDependencies(nextValueData,depCollector); |
| 601 |
} |
| 602 |
} |
| 603 |
|
| 604 |
return depAdded; |
| 605 |
|
| 606 |
} |
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
bool CDatatypeRealValueSpaceMap::addValueExclusionDependencies(CDataLiteralRealValue* value, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 613 |
if (mAbsoluteMinimumExclusionValue) { |
| 614 |
if (value->isLessThan(mAbsoluteMinimumExclusionValue->getValue())) { |
| 615 |
return false; |
| 616 |
} |
| 617 |
} |
| 618 |
if (mAbsoluteMaximumExclusionValue) { |
| 619 |
if (value->isGreaterThan(mAbsoluteMaximumExclusionValue->getValue())) { |
| 620 |
return false; |
| 621 |
} |
| 622 |
} |
| 623 |
|
| 624 |
|
| 625 |
bool depAdded = false; |
| 626 |
|
| 627 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(value); |
| 628 |
CDatatypeRealValueSpaceMap::iterator itBegin = CDatatypeRealValueSpaceMap::begin(), itLB = CDatatypeRealValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeRealValueSpaceMap::end(); |
| 629 |
CDatatypeRealValueSpaceMap::iterator it = itLB; |
| 630 |
|
| 631 |
|
| 632 |
if (it != itEnd) { |
| 633 |
CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 634 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 635 |
|
| 636 |
if (value->isEqualTo(itValueData->getValue())) { |
| 637 |
depAdded |= addDataValueExclusionDependencies(itValueData,depCollector); |
| 638 |
} else if (value->isGreaterThan(itValueData->getValue())) { |
| 639 |
depAdded |= addExclusionDependencies(itValueData->getRightExclusionData(),depCollector); |
| 640 |
} else { |
| 641 |
depAdded |= addExclusionDependencies(itValueData->getLeftExclusionData(),depCollector); |
| 642 |
} |
| 643 |
} |
| 644 |
|
| 645 |
return depAdded; |
| 646 |
} |
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
bool CDatatypeRealValueSpaceMap::countAllValues(CDatatypeValueSpaceValuesCounter* counter) { |
| 653 |
if (mAbsoluteMaximumExclusionValue && mAbsoluteMinimumExclusionValue) { |
| 654 |
return countIntervalValues(mAbsoluteMinimumExclusionValue->getValue(),true,mAbsoluteMaximumExclusionValue->getValue(),true,counter); |
| 655 |
} |
| 656 |
return false; |
| 657 |
} |
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
bool CDatatypeRealValueSpaceMap::countIntervalValues(CDataLiteralRealValue* leftValue, bool leftValueInclusive, CDataLiteralRealValue* rightValue, bool rightValueInclusive, CDatatypeValueSpaceValuesCounter* counter) { |
| 662 |
bool counted = false; |
| 663 |
|
| 664 |
if (mAbsoluteMinimumExclusionValue) { |
| 665 |
if (leftValue->isLessThan(mAbsoluteMinimumExclusionValue->getValue())) { |
| 666 |
leftValue = mAbsoluteMinimumExclusionValue->getValue(); |
| 667 |
} |
| 668 |
} |
| 669 |
if (mAbsoluteMaximumExclusionValue) { |
| 670 |
if (rightValue->isGreaterThan(mAbsoluteMaximumExclusionValue->getValue())) { |
| 671 |
rightValue = mAbsoluteMaximumExclusionValue->getValue(); |
| 672 |
} |
| 673 |
} |
| 674 |
|
| 675 |
if (leftValue->isGreaterThan(rightValue)) { |
| 676 |
return false; |
| 677 |
} else if (leftValue->isEqualTo(rightValue)) { |
| 678 |
if (!leftValueInclusive && !rightValueInclusive) { |
| 679 |
return false; |
| 680 |
} |
| 681 |
} |
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(leftValue); |
| 686 |
CDatatypeRealValueSpaceMap::iterator itBegin = CDatatypeRealValueSpaceMap::begin(), itLB = CDatatypeRealValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeRealValueSpaceMap::end(); |
| 687 |
CDatatypeRealValueSpaceMap::iterator it = itLB; |
| 688 |
|
| 689 |
|
| 690 |
while (it != itEnd) { |
| 691 |
CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 692 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 693 |
|
| 694 |
if (it == itLB) { |
| 695 |
if (leftValue->isEqualTo(itValueData->getValue())) { |
| 696 |
if (leftValueInclusive) { |
| 697 |
if (!isDataValueExcluded(itValueData,nullptr)) { |
| 698 |
counted |= countDataValue(itValueData,counter); |
| 699 |
} |
| 700 |
} |
| 701 |
} else { |
| 702 |
if (leftValueInclusive) { |
| 703 |
if (!isDataValueExcluded(leftValue,nullptr)) { |
| 704 |
counted |= countDataValue(leftValue,itValueData->getLeftExclusionData(),counter); |
| 705 |
} |
| 706 |
} |
| 707 |
if (!isDataIntervalExcluded(leftValue,itValueData,nullptr)) { |
| 708 |
counted |= countDataIntervalValues(leftValue,itValueData,counter); |
| 709 |
} |
| 710 |
} |
| 711 |
} |
| 712 |
|
| 713 |
++it; |
| 714 |
if (it != itEnd) { |
| 715 |
CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 716 |
CDatatypeRealValueData* nextValueData = nextMapData.mUseValue; |
| 717 |
|
| 718 |
if (!isDataIntervalExcluded(itValueData,nextValueData,nullptr)) { |
| 719 |
counted |= countDataIntervalValues(itValueData,nextValueData,counter); |
| 720 |
} |
| 721 |
|
| 722 |
if (nextValueData->getValue()->isEqualTo(rightValue)) { |
| 723 |
if (rightValueInclusive) { |
| 724 |
if (!isDataValueExcluded(nextValueData,nullptr)) { |
| 725 |
counted |= countDataValue(nextValueData,counter); |
| 726 |
} |
| 727 |
} |
| 728 |
break; |
| 729 |
} else if (nextValueData->getValue()->isGreaterThan(rightValue)) { |
| 730 |
if (rightValueInclusive) { |
| 731 |
if (!isDataValueExcluded(rightValue,nullptr)) { |
| 732 |
counted |= countDataValue(rightValue,nextValueData->getLeftExclusionData(),counter); |
| 733 |
} |
| 734 |
} |
| 735 |
if (!isDataIntervalExcluded(nextValueData,rightValue,nullptr)) { |
| 736 |
counted |= countDataIntervalValues(nextValueData,rightValue,counter); |
| 737 |
} |
| 738 |
break; |
| 739 |
} |
| 740 |
|
| 741 |
if (!isDataValueExcluded(nextValueData,nullptr)) { |
| 742 |
counted |= countDataValue(nextValueData,counter); |
| 743 |
} |
| 744 |
} |
| 745 |
} |
| 746 |
|
| 747 |
return counted; |
| 748 |
} |
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
bool CDatatypeRealValueSpaceMap::excludeData(CDatatypeRealValueDataExclusion* exlcusionData, CDependencyTrackPoint* depTrackPoint, CDatatypeRealValueExclusionType* exclusionType, bool force) { |
| 761 |
if (!exclusionType) { |
| 762 |
if (force || !exlcusionData->isExcluded()) { |
| 763 |
exlcusionData->setExcluded(true); |
| 764 |
exlcusionData->setExcludedDependencyTrackPoint(depTrackPoint); |
| 765 |
return true; |
| 766 |
} |
| 767 |
} else { |
| 768 |
if (force || !exlcusionData->isExcluded(exclusionType)) { |
| 769 |
exlcusionData->setExclusion(exclusionType,depTrackPoint); |
| 770 |
return true; |
| 771 |
} |
| 772 |
} |
| 773 |
return false; |
| 774 |
} |
| 775 |
|
| 776 |
|
| 777 |
bool CDatatypeRealValueSpaceMap::excludeDataValue(CDatatypeRealValueData* dataValue, CDependencyTrackPoint* depTrackPoint, CDatatypeRealValueExclusionType* exclusionType, bool force) { |
| 778 |
return excludeData(dataValue->getValueExclusionData(),depTrackPoint,exclusionType,force); |
| 779 |
} |
| 780 |
|
| 781 |
bool CDatatypeRealValueSpaceMap::excludeLeftDataInterval(CDatatypeRealValueData* dataValue, CDependencyTrackPoint* depTrackPoint, CDatatypeRealValueExclusionType* exclusionType, bool force) { |
| 782 |
return excludeData(dataValue->getLeftExclusionData(),depTrackPoint,exclusionType,force); |
| 783 |
} |
| 784 |
|
| 785 |
bool CDatatypeRealValueSpaceMap::excludeRightDataInterval(CDatatypeRealValueData* dataValue, CDependencyTrackPoint* depTrackPoint, CDatatypeRealValueExclusionType* exclusionType, bool force) { |
| 786 |
return excludeData(dataValue->getRightExclusionData(),depTrackPoint,exclusionType,force); |
| 787 |
} |
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
bool CDatatypeRealValueSpaceMap::restrictToIntegerValues(CDependencyTrackPoint* depTrackPoint) { |
| 793 |
CDatatypeRealValueExclusionType exclusionType(CDatatypeRealValueExclusionType::RVET_INTEGER,true); |
| 794 |
return excludeAll(depTrackPoint,&exclusionType); |
| 795 |
} |
| 796 |
|
| 797 |
|
| 798 |
bool CDatatypeRealValueSpaceMap::restrictToNonIntegerValues(CDependencyTrackPoint* depTrackPoint) { |
| 799 |
CDatatypeRealValueExclusionType exclusionType(CDatatypeRealValueExclusionType::RVET_INTEGER,false); |
| 800 |
return excludeAll(depTrackPoint,&exclusionType); |
| 801 |
} |
| 802 |
|
| 803 |
|
| 804 |
bool CDatatypeRealValueSpaceMap::restrictToDecimalValues(CDependencyTrackPoint* depTrackPoint) { |
| 805 |
CDatatypeRealValueExclusionType exclusionType(CDatatypeRealValueExclusionType::RVET_DECIMAL,true); |
| 806 |
return excludeAll(depTrackPoint,&exclusionType); |
| 807 |
} |
| 808 |
|
| 809 |
|
| 810 |
bool CDatatypeRealValueSpaceMap::restrictToNonDecimalValues(CDependencyTrackPoint* depTrackPoint) { |
| 811 |
CDatatypeRealValueExclusionType exclusionType(CDatatypeRealValueExclusionType::RVET_DECIMAL,false); |
| 812 |
return excludeAll(depTrackPoint,&exclusionType); |
| 813 |
} |
| 814 |
|
| 815 |
|
| 816 |
bool CDatatypeRealValueSpaceMap::restrictToRationalValues(CDependencyTrackPoint* depTrackPoint) { |
| 817 |
CDatatypeRealValueExclusionType exclusionType(CDatatypeRealValueExclusionType::RVET_RATIONAL,true); |
| 818 |
return excludeAll(depTrackPoint,&exclusionType); |
| 819 |
} |
| 820 |
|
| 821 |
|
| 822 |
bool CDatatypeRealValueSpaceMap::restrictToNonRationalValues(CDependencyTrackPoint* depTrackPoint) { |
| 823 |
CDatatypeRealValueExclusionType exclusionType(CDatatypeRealValueExclusionType::RVET_RATIONAL,false); |
| 824 |
return excludeAll(depTrackPoint,&exclusionType); |
| 825 |
} |
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
bool CDatatypeRealValueSpaceMap::isRestrictedToIntegerValues() { |
| 830 |
CDatatypeRealValueExclusionType restictionType(CDatatypeRealValueExclusionType::RVET_INTEGER, true); |
| 831 |
return areAllValuesRestricted(&restictionType); |
| 832 |
} |
| 833 |
|
| 834 |
bool CDatatypeRealValueSpaceMap::isRestrictedToNonIntegerValues() { |
| 835 |
CDatatypeRealValueExclusionType restictionType(CDatatypeRealValueExclusionType::RVET_INTEGER, false); |
| 836 |
return areAllValuesRestricted(&restictionType); |
| 837 |
} |
| 838 |
|
| 839 |
|
| 840 |
bool CDatatypeRealValueSpaceMap::isRestrictedToDecimalValues() { |
| 841 |
CDatatypeRealValueExclusionType restictionType(CDatatypeRealValueExclusionType::RVET_DECIMAL, true); |
| 842 |
return areAllValuesRestricted(&restictionType); |
| 843 |
} |
| 844 |
|
| 845 |
bool CDatatypeRealValueSpaceMap::isRestrictedToNonDecimalValues() { |
| 846 |
CDatatypeRealValueExclusionType restictionType(CDatatypeRealValueExclusionType::RVET_DECIMAL, false); |
| 847 |
return areAllValuesRestricted(&restictionType); |
| 848 |
} |
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
bool CDatatypeRealValueSpaceMap::isRestrictedToRationalValues() { |
| 853 |
CDatatypeRealValueExclusionType restictionType(CDatatypeRealValueExclusionType::RVET_RATIONAL, true); |
| 854 |
return areAllValuesRestricted(&restictionType); |
| 855 |
} |
| 856 |
|
| 857 |
|
| 858 |
bool CDatatypeRealValueSpaceMap::isRestrictedToNonRationalValues() { |
| 859 |
CDatatypeRealValueExclusionType restictionType(CDatatypeRealValueExclusionType::RVET_RATIONAL, false); |
| 860 |
return areAllValuesRestricted(&restictionType); |
| 861 |
} |
| 862 |
|
| 863 |
|
| 864 |
bool CDatatypeRealValueSpaceMap::testValueSpaceReturnClashed() { |
| 865 |
|
| 866 |
CDatatypeRealValueSpaceMap::const_iterator itBegin = CDatatypeRealValueSpaceMap::constBegin(), itEnd = CDatatypeRealValueSpaceMap::constEnd(); |
| 867 |
CDatatypeRealValueSpaceMap::const_iterator it = itBegin; |
| 868 |
|
| 869 |
// test whether value space is empty |
| 870 |
CDatatypeRealValueData* firstValueData = nullptr; |
| 871 |
|
| 872 |
while (it != itEnd) { |
| 873 |
|
| 874 |
const CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 875 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 876 |
if (!firstValueData) { |
| 877 |
firstValueData = itValueData; |
| 878 |
if (!isLeftDataIntervalExcluded(firstValueData,nullptr)) { |
| 879 |
return false; |
| 880 |
} |
| 881 |
} |
| 882 |
if (!isDataValueExcluded(itValueData,nullptr)) { |
| 883 |
return false; |
| 884 |
} |
| 885 |
++it; |
| 886 |
|
| 887 |
if (it != itEnd) { |
| 888 |
const CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 889 |
CDatatypeRealValueData* nextValueData = nextMapData.mUseValue; |
| 890 |
if (!isDataIntervalExcluded(itValueData,nextValueData,nullptr)) { |
| 891 |
return false; |
| 892 |
} |
| 893 |
} else { |
| 894 |
if (!isRightDataIntervalExcluded(itValueData,nullptr)) { |
| 895 |
return false; |
| 896 |
} |
| 897 |
} |
| 898 |
} |
| 899 |
return true; |
| 900 |
} |
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
bool CDatatypeRealValueSpaceMap::addValueSpaceDependencies(CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 906 |
|
| 907 |
CDatatypeRealValueSpaceMap::const_iterator itBegin = CDatatypeRealValueSpaceMap::constBegin(), itEnd = CDatatypeRealValueSpaceMap::constEnd(); |
| 908 |
CDatatypeRealValueSpaceMap::const_iterator it = itBegin; |
| 909 |
|
| 910 |
it = itBegin; |
| 911 |
while (it != itEnd) { |
| 912 |
const CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 913 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 914 |
addDataValueExclusionDependencies(itValueData,depCollector); |
| 915 |
|
| 916 |
if (it == itBegin) { |
| 917 |
addLeftIntervalExclusionDependencies(itValueData,depCollector); |
| 918 |
} |
| 919 |
|
| 920 |
++it; |
| 921 |
if (it == itEnd) { |
| 922 |
addRightIntervalExclusionDependencies(itValueData,depCollector); |
| 923 |
} else { |
| 924 |
const CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 925 |
CDatatypeRealValueData* nextValueData = nextMapData.mUseValue; |
| 926 |
|
| 927 |
addDataIntervalExclusionDependencies(itValueData,nextValueData,depCollector); |
| 928 |
|
| 929 |
} |
| 930 |
} |
| 931 |
return true; |
| 932 |
|
| 933 |
} |
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
bool CDatatypeRealValueSpaceMap::addValueSpaceDependencies(CDatatypeValueSpaceDependencyCollector* depCollector, CDatatypeRealValueExclusionType* exclusionType) { |
| 939 |
|
| 940 |
CDatatypeRealValueSpaceMap::const_iterator itBegin = CDatatypeRealValueSpaceMap::constBegin(), itEnd = CDatatypeRealValueSpaceMap::constEnd(); |
| 941 |
CDatatypeRealValueSpaceMap::const_iterator it = itBegin; |
| 942 |
|
| 943 |
it = itBegin; |
| 944 |
while (it != itEnd) { |
| 945 |
const CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 946 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 947 |
if (isDataValueExcluded(itValueData, exclusionType)) { |
| 948 |
addDataValueExclusionDependencies(itValueData, depCollector); |
| 949 |
} |
| 950 |
|
| 951 |
if (it == itBegin) { |
| 952 |
if (isLeftDataIntervalExcluded(itValueData, exclusionType)) { |
| 953 |
addLeftIntervalExclusionDependencies(itValueData, depCollector); |
| 954 |
} |
| 955 |
} |
| 956 |
|
| 957 |
++it; |
| 958 |
if (it == itEnd) { |
| 959 |
if (isRightDataIntervalExcluded(itValueData, exclusionType)) { |
| 960 |
addRightIntervalExclusionDependencies(itValueData, depCollector); |
| 961 |
} |
| 962 |
} |
| 963 |
else { |
| 964 |
const CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 965 |
CDatatypeRealValueData* nextValueData = nextMapData.mUseValue; |
| 966 |
|
| 967 |
if (isDataIntervalExcluded(itValueData, nextValueData, exclusionType)) { |
| 968 |
addDataIntervalExclusionDependencies(itValueData, nextValueData, depCollector); |
| 969 |
} |
| 970 |
|
| 971 |
} |
| 972 |
} |
| 973 |
return true; |
| 974 |
|
| 975 |
} |
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
bool CDatatypeRealValueSpaceMap::restrictToValue(CDataLiteralRealValue* value, CDependencyTrackPoint* depTrackPoint) { |
| 981 |
bool newValuesPotentiallyExcluded = false; |
| 982 |
newValuesPotentiallyExcluded |= excludeMinimum(value,false,depTrackPoint); |
| 983 |
newValuesPotentiallyExcluded |= excludeMaximum(value,false,depTrackPoint); |
| 984 |
return newValuesPotentiallyExcluded; |
| 985 |
} |
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
bool CDatatypeRealValueSpaceMap::excludeValue(CDataLiteralRealValue* value, CDependencyTrackPoint* depTrackPoint, CDatatypeRealValueExclusionType* exclusionType) { |
| 990 |
bool newValuesPotentiallyExcluded = false; |
| 991 |
if (mAbsoluteMinimumExclusionValue) { |
| 992 |
if (mAbsoluteMinimumExclusionValue->getValue()->isGreaterThan(value)) { |
| 993 |
return false; |
| 994 |
} |
| 995 |
if (mAbsoluteMinimumExclusionValue->getValue()->isEqualTo(value)) { |
| 996 |
if (isDataValueExcluded(mAbsoluteMinimumExclusionValue,exclusionType)) { |
| 997 |
return false; |
| 998 |
} |
| 999 |
} |
| 1000 |
} |
| 1001 |
if (mAbsoluteMaximumExclusionValue) { |
| 1002 |
if (mAbsoluteMaximumExclusionValue->getValue()->isGreaterThan(value)) { |
| 1003 |
return false; |
| 1004 |
} |
| 1005 |
if (mAbsoluteMaximumExclusionValue->getValue()->isEqualTo(value)) { |
| 1006 |
if (isDataValueExcluded(mAbsoluteMaximumExclusionValue,exclusionType)) { |
| 1007 |
return false; |
| 1008 |
} |
| 1009 |
} |
| 1010 |
} |
| 1011 |
|
| 1012 |
|
| 1013 |
CDatatypeRealValueData* valueData = getDatatypeRealValueData(value,true); |
| 1014 |
if (!isDataValueExcluded(valueData,exclusionType)) { |
| 1015 |
newValuesPotentiallyExcluded |= excludeDataValue(valueData,depTrackPoint,exclusionType,false); |
| 1016 |
} |
| 1017 |
|
| 1018 |
|
| 1019 |
return newValuesPotentiallyExcluded; |
| 1020 |
} |
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
bool CDatatypeRealValueSpaceMap::addDataValueExclusionDependencies(CDatatypeRealValueData* dataValue, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 1029 |
CDatatypeRealValueDataExclusion* exclusionData = dataValue->getValueExclusionData(); |
| 1030 |
return addExclusionDependencies(exclusionData,depCollector); |
| 1031 |
} |
| 1032 |
|
| 1033 |
bool CDatatypeRealValueSpaceMap::addDataIntervalExclusionDependencies(CDatatypeRealValueData* leftValueExcluded, CDatatypeRealValueData* rightValueExcluded, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 1034 |
CDatatypeRealValueDataExclusion* exclusionData = leftValueExcluded->getRightExclusionData(); |
| 1035 |
return addExclusionDependencies(exclusionData,depCollector); |
| 1036 |
} |
| 1037 |
|
| 1038 |
bool CDatatypeRealValueSpaceMap::addLeftIntervalExclusionDependencies(CDatatypeRealValueData* valueData, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 1039 |
CDatatypeRealValueDataExclusion* exclusionData = valueData->getLeftExclusionData(); |
| 1040 |
return addExclusionDependencies(exclusionData,depCollector); |
| 1041 |
} |
| 1042 |
|
| 1043 |
bool CDatatypeRealValueSpaceMap::addRightIntervalExclusionDependencies(CDatatypeRealValueData* valueData, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 1044 |
CDatatypeRealValueDataExclusion* exclusionData = valueData->getRightExclusionData(); |
| 1045 |
return addExclusionDependencies(exclusionData,depCollector); |
| 1046 |
} |
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
|
| 1051 |
bool CDatatypeRealValueSpaceMap::addExclusionDependencies(CDatatypeRealValueDataExclusion* exclusionData, CDatatypeValueSpaceDependencyCollector* depCollector) { |
| 1052 |
bool dependenciesAdded = false; |
| 1053 |
CDependencyTrackPoint* depTrackPoint = nullptr; |
| 1054 |
if (depCollector) { |
| 1055 |
if (exclusionData->isExcluded()) { |
| 1056 |
depTrackPoint = exclusionData->getExcludedDependencyTrackPoint(); |
| 1057 |
if (depTrackPoint) { |
| 1058 |
dependenciesAdded |= depCollector->addDependency(depTrackPoint); |
| 1059 |
} |
| 1060 |
} else { |
| 1061 |
depTrackPoint = exclusionData->getPositiveExclusionDependencyTrackPoint(); |
| 1062 |
if (depTrackPoint) { |
| 1063 |
dependenciesAdded |= depCollector->addDependency(depTrackPoint); |
| 1064 |
} |
| 1065 |
depTrackPoint = exclusionData->getNegativeExclusionDependencyTrackPoint(); |
| 1066 |
if (depTrackPoint) { |
| 1067 |
dependenciesAdded |= depCollector->addDependency(depTrackPoint); |
| 1068 |
} |
| 1069 |
} |
| 1070 |
} |
| 1071 |
return dependenciesAdded; |
| 1072 |
} |
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
bool CDatatypeRealValueSpaceMap::isLeftDataIntervalExcluded(CDatatypeRealValueData* dataValue, CDatatypeRealValueExclusionType* exclusionType) { |
| 1086 |
CDatatypeRealValueDataExclusion* exclusionData = dataValue->getLeftExclusionData(); |
| 1087 |
if (exclusionData->isEverythingExcluded()) { |
| 1088 |
return true; |
| 1089 |
} |
| 1090 |
if (exclusionType) { |
| 1091 |
if (exclusionData->isExcluded(exclusionType)) { |
| 1092 |
return true; |
| 1093 |
} |
| 1094 |
} |
| 1095 |
return false; |
| 1096 |
} |
| 1097 |
|
| 1098 |
|
| 1099 |
bool CDatatypeRealValueSpaceMap::isRightDataIntervalExcluded(CDatatypeRealValueData* dataValue, CDatatypeRealValueExclusionType* exclusionType) { |
| 1100 |
CDatatypeRealValueDataExclusion* exclusionData = dataValue->getRightExclusionData(); |
| 1101 |
if (exclusionData->isEverythingExcluded()) { |
| 1102 |
return true; |
| 1103 |
} |
| 1104 |
if (exclusionType) { |
| 1105 |
if (exclusionData->isExcluded(exclusionType)) { |
| 1106 |
return true; |
| 1107 |
} |
| 1108 |
} |
| 1109 |
return false; |
| 1110 |
} |
| 1111 |
|
| 1112 |
|
| 1113 |
bool CDatatypeRealValueSpaceMap::isDataIntervalExcluded(CDataLiteralRealValue* leftValueExcluded, CDatatypeRealValueData* rightValueExcluded, CDatatypeRealValueExclusionType* exclusionType) { |
| 1114 |
CDatatypeRealValueDataExclusion* exclusionData = rightValueExcluded->getLeftExclusionData(); |
| 1115 |
if (exclusionData->isEverythingExcluded()) { |
| 1116 |
return true; |
| 1117 |
} |
| 1118 |
if (exclusionData->areOnlyIntegerValuesAllowed()) { |
| 1119 |
if (!containsIntervalIntegers(leftValueExcluded,rightValueExcluded->getValue())) { |
| 1120 |
return true; |
| 1121 |
} |
| 1122 |
} |
| 1123 |
if (exclusionType) { |
| 1124 |
if (exclusionData->isExcluded(exclusionType)) { |
| 1125 |
return true; |
| 1126 |
} |
| 1127 |
} |
| 1128 |
return false; |
| 1129 |
} |
| 1130 |
|
| 1131 |
|
| 1132 |
bool CDatatypeRealValueSpaceMap::isDataIntervalExcluded(CDatatypeRealValueData* leftValueExcluded, CDataLiteralRealValue* rightValueExcluded, CDatatypeRealValueExclusionType* exclusionType) { |
| 1133 |
CDatatypeRealValueDataExclusion* exclusionData = leftValueExcluded->getRightExclusionData(); |
| 1134 |
if (exclusionData->isEverythingExcluded()) { |
| 1135 |
return true; |
| 1136 |
} |
| 1137 |
if (exclusionData->areOnlyIntegerValuesAllowed()) { |
| 1138 |
if (!containsIntervalIntegers(leftValueExcluded->getValue(),rightValueExcluded)) { |
| 1139 |
return true; |
| 1140 |
} |
| 1141 |
} |
| 1142 |
if (exclusionType) { |
| 1143 |
if (exclusionData->isExcluded(exclusionType)) { |
| 1144 |
return true; |
| 1145 |
} |
| 1146 |
} |
| 1147 |
return false; |
| 1148 |
} |
| 1149 |
|
| 1150 |
|
| 1151 |
bool CDatatypeRealValueSpaceMap::isDataIntervalExcluded(CDatatypeRealValueData* leftValueExcluded, CDatatypeRealValueData* rightValueExcluded, CDatatypeRealValueExclusionType* exclusionType) { |
| 1152 |
return isDataIntervalExcluded(leftValueExcluded,rightValueExcluded->getValue(),exclusionType); |
| 1153 |
} |
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
bool CDatatypeRealValueSpaceMap::containsIntervalIntegers(CDataLiteralRealValue* leftValueExcluded, CDataLiteralRealValue* rightValueExcluded, cint64 requiredIntegerCount) { |
| 1158 |
if (leftValueExcluded->isInfiniteBigNumber() || rightValueExcluded->isInfiniteBigNumber()) { |
| 1159 |
return true; |
| 1160 |
} else if (rightValueExcluded->hasFlag(CDataLiteralRealValue::DLRV_INTEGER_FLAG)) { |
| 1161 |
return leftValueExcluded->getPosNegInteger()+requiredIntegerCount < rightValueExcluded->getPosNegInteger(); |
| 1162 |
} else { |
| 1163 |
return leftValueExcluded->getPosNegInteger()+requiredIntegerCount <= rightValueExcluded->getPosNegInteger(); |
| 1164 |
} |
| 1165 |
} |
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
bool CDatatypeRealValueSpaceMap::isDataValueExcluded(CDatatypeRealValueData* valueData, CDatatypeRealValueExclusionType* exclusionType) { |
| 1170 |
CDatatypeRealValueDataExclusion* exclusionData = valueData->getValueExclusionData(); |
| 1171 |
if (exclusionData->isEverythingExcluded()) { |
| 1172 |
return true; |
| 1173 |
} |
| 1174 |
CDataLiteralRealValue* value = valueData->getValue(); |
| 1175 |
if (value->hasFlag(CDataLiteralRealValue::DLRV_INTEGER_FLAG)) { |
| 1176 |
if (exclusionData->areIntegerValuesExcluded()) { |
| 1177 |
return true; |
| 1178 |
} |
| 1179 |
} else if (value->hasFlag(CDataLiteralRealValue::DLRV_DECIMAL_FLAG)) { |
| 1180 |
if (exclusionData->areDecimalValuesExcluded()) { |
| 1181 |
return true; |
| 1182 |
} |
| 1183 |
} else if (value->hasFlag(CDataLiteralRealValue::DLRV_RATIONAL_FLAG)) { |
| 1184 |
if (exclusionData->areRationalValuesExcluded()) { |
| 1185 |
return true; |
| 1186 |
} |
| 1187 |
} |
| 1188 |
if (exclusionType) { |
| 1189 |
if (exclusionData->isExcluded(exclusionType)) { |
| 1190 |
return true; |
| 1191 |
} |
| 1192 |
} |
| 1193 |
return false; |
| 1194 |
} |
| 1195 |
|
| 1196 |
|
| 1197 |
bool CDatatypeRealValueSpaceMap::isDataValueExcluded(CDataLiteralRealValue* value, CDatatypeRealValueExclusionType* exclusionType) { |
| 1198 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(value); |
| 1199 |
CDatatypeRealValueSpaceMap::const_iterator itBegin = CDatatypeRealValueSpaceMap::constBegin(), itLB = CDatatypeRealValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeRealValueSpaceMap::constEnd(); |
| 1200 |
|
| 1201 |
if (itBegin == itEnd) { |
| 1202 |
return false; |
| 1203 |
} |
| 1204 |
if (itLB == itEnd) { |
| 1205 |
return true; |
| 1206 |
} |
| 1207 |
const CDatatypeRealValueSpaceMapData& mapData = itLB.value(); |
| 1208 |
CDatatypeRealValueData* valueData = mapData.mUseValue; |
| 1209 |
CDatatypeRealValueDataExclusion* exclusionData = nullptr; |
| 1210 |
if (valueData->getValue()->isEqualTo(value)) { |
| 1211 |
exclusionData = valueData->getValueExclusionData(); |
| 1212 |
} else if (valueData->getValue()->isLessThan(value)) { |
| 1213 |
exclusionData = valueData->getLeftExclusionData(); |
| 1214 |
} else { |
| 1215 |
exclusionData = valueData->getRightExclusionData(); |
| 1216 |
} |
| 1217 |
|
| 1218 |
if (exclusionData) { |
| 1219 |
CDatatypeRealValueDataExclusion* exclusionData = valueData->getValueExclusionData(); |
| 1220 |
if (exclusionData->isEverythingExcluded()) { |
| 1221 |
return true; |
| 1222 |
} |
| 1223 |
CDataLiteralRealValue* value = valueData->getValue(); |
| 1224 |
if (value->hasFlag(CDataLiteralRealValue::DLRV_INTEGER_FLAG)) { |
| 1225 |
if (exclusionData->areIntegerValuesExcluded()) { |
| 1226 |
return true; |
| 1227 |
} |
| 1228 |
} else if (value->hasFlag(CDataLiteralRealValue::DLRV_DECIMAL_FLAG)) { |
| 1229 |
if (exclusionData->areDecimalValuesExcluded()) { |
| 1230 |
return true; |
| 1231 |
} |
| 1232 |
} else if (value->hasFlag(CDataLiteralRealValue::DLRV_RATIONAL_FLAG)) { |
| 1233 |
if (exclusionData->areRationalValuesExcluded()) { |
| 1234 |
return true; |
| 1235 |
} |
| 1236 |
} |
| 1237 |
} |
| 1238 |
if (exclusionType) { |
| 1239 |
if (exclusionData->isExcluded(exclusionType)) { |
| 1240 |
return true; |
| 1241 |
} |
| 1242 |
} |
| 1243 |
return false; |
| 1244 |
} |
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
bool CDatatypeRealValueSpaceMap::adaptNewRealValueDataToNeighbours(CDatatypeRealValueData* valueData) { |
| 1249 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(valueData->getValue()); |
| 1250 |
CDatatypeRealValueSpaceMap::const_iterator itBegin = CDatatypeRealValueSpaceMap::constBegin(), itLB = CDatatypeRealValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeRealValueSpaceMap::constEnd(); |
| 1251 |
CDatatypeRealValueSpaceMap::const_iterator itAdapt = itLB; |
| 1252 |
bool rightNeighbour = true; |
| 1253 |
++itAdapt; |
| 1254 |
if (itAdapt == itEnd) { |
| 1255 |
itAdapt = itLB; |
| 1256 |
--itAdapt; |
| 1257 |
rightNeighbour = false; |
| 1258 |
} |
| 1259 |
if (itAdapt != itEnd) { |
| 1260 |
const CDatatypeRealValueSpaceMapData& adaptMapData = itAdapt.value(); |
| 1261 |
CDatatypeRealValueData* adaptValueData = adaptMapData.mUseValue; |
| 1262 |
CDatatypeRealValueDataExclusion* exclusionData = nullptr; |
| 1263 |
if (rightNeighbour) { |
| 1264 |
exclusionData = adaptValueData->getLeftExclusionData(); |
| 1265 |
} else { |
| 1266 |
exclusionData = adaptValueData->getRightExclusionData(); |
| 1267 |
} |
| 1268 |
valueData->getValueExclusionData()->initDataExclusion(exclusionData); |
| 1269 |
valueData->getLeftExclusionData()->initDataExclusion(exclusionData); |
| 1270 |
valueData->getRightExclusionData()->initDataExclusion(exclusionData); |
| 1271 |
return true; |
| 1272 |
} |
| 1273 |
return false; |
| 1274 |
} |
| 1275 |
|
| 1276 |
|
| 1277 |
CDatatypeRealValueData* CDatatypeRealValueSpaceMap::getDatatypeRealValueData(CDataLiteralRealValue* value, CDatatypeRealValueSpaceMapData& valueMapData, bool createOrLocalize, bool* newValueInsertion) { |
| 1278 |
if (newValueInsertion) { |
| 1279 |
*newValueInsertion = false; |
| 1280 |
} |
| 1281 |
CDatatypeRealValueData* realValueData = nullptr; |
| 1282 |
if (!valueMapData.mLocValue) { |
| 1283 |
bool newlyCreated = false; |
| 1284 |
CMemoryAllocationManager* taskMemMan = mProcessContext->getUsedMemoryAllocationManager(); |
| 1285 |
realValueData = CObjectParameterizingAllocator< CDatatypeRealValueData,CProcessContext* >::allocateAndConstructAndParameterize(taskMemMan,mProcessContext); |
| 1286 |
realValueData->initRealValueData(valueMapData.mUseValue,value); |
| 1287 |
if (!valueMapData.mUseValue) { |
| 1288 |
newlyCreated = true; |
| 1289 |
} |
| 1290 |
valueMapData.mUseValue = valueMapData.mLocValue = realValueData; |
| 1291 |
if (newlyCreated) { |
| 1292 |
adaptNewRealValueDataToNeighbours(realValueData); |
| 1293 |
} |
| 1294 |
if (newlyCreated && newValueInsertion) { |
| 1295 |
*newValueInsertion = true; |
| 1296 |
} |
| 1297 |
} else { |
| 1298 |
realValueData = valueMapData.mUseValue; |
| 1299 |
} |
| 1300 |
return realValueData; |
| 1301 |
} |
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
CDatatypeRealValueData* CDatatypeRealValueSpaceMap::getDatatypeRealValueData(CDataLiteralRealValue* value, bool createOrLocalize, bool* newValueInsertion) { |
| 1306 |
if (newValueInsertion) { |
| 1307 |
*newValueInsertion = false; |
| 1308 |
} |
| 1309 |
CDatatypeRealValueData* realValueData = nullptr; |
| 1310 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(value); |
| 1311 |
if (createOrLocalize) { |
| 1312 |
CDatatypeRealValueSpaceMapData& data = CPROCESSMAP<CDatatypeRealValueSpaceMapArranger,CDatatypeRealValueSpaceMapData>::operator[](mapValueArranger); |
| 1313 |
realValueData = getDatatypeRealValueData(value,data,createOrLocalize,newValueInsertion); |
| 1314 |
} else { |
| 1315 |
CDatatypeRealValueSpaceMapData data = CPROCESSMAP<CDatatypeRealValueSpaceMapArranger,CDatatypeRealValueSpaceMapData>::value(mapValueArranger); |
| 1316 |
realValueData = data.mUseValue; |
| 1317 |
} |
| 1318 |
return realValueData; |
| 1319 |
} |
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
bool CDatatypeRealValueSpaceMap::areAllValuesRestricted(CDatatypeRealValueExclusionType* exclusionType) { |
| 1326 |
CDatatypeRealValueSpaceMap::const_iterator itBegin = CDatatypeRealValueSpaceMap::constBegin(), itEnd = CDatatypeRealValueSpaceMap::constEnd(); |
| 1327 |
CDatatypeRealValueSpaceMap::const_iterator it = itBegin; |
| 1328 |
if (it == itEnd) { |
| 1329 |
return true; |
| 1330 |
} |
| 1331 |
while (it != itEnd) { |
| 1332 |
const CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 1333 |
CDatatypeRealValueData* realValueData = mapData.mUseValue; |
| 1334 |
if (!isDataValueExcluded(realValueData, exclusionType)) { |
| 1335 |
return false; |
| 1336 |
} |
| 1337 |
|
| 1338 |
if (it == itBegin) { |
| 1339 |
if (!isLeftDataIntervalExcluded(realValueData, exclusionType)) { |
| 1340 |
return false; |
| 1341 |
} |
| 1342 |
} |
| 1343 |
++it; |
| 1344 |
|
| 1345 |
if (it == itEnd) { |
| 1346 |
if (!isRightDataIntervalExcluded(realValueData, exclusionType)) { |
| 1347 |
return false; |
| 1348 |
} |
| 1349 |
} |
| 1350 |
else { |
| 1351 |
const CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 1352 |
CDatatypeRealValueData* nextRealValueData = nextMapData.mUseValue; |
| 1353 |
if (!isDataIntervalExcluded(realValueData, nextRealValueData, exclusionType)) { |
| 1354 |
return false; |
| 1355 |
} |
| 1356 |
} |
| 1357 |
} |
| 1358 |
return true; |
| 1359 |
} |
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
bool CDatatypeRealValueSpaceMap::hasExcludedMinimum(CDataLiteralRealValue* value, bool valueInclusively, CDatatypeRealValueExclusionType* exclusionType) { |
| 1365 |
|
| 1366 |
if (mAbsoluteMinimumExclusionValue) { |
| 1367 |
if (mAbsoluteMinimumExclusionValue->getValue()->isGreaterThan(value)) { |
| 1368 |
return true; |
| 1369 |
} |
| 1370 |
if (mAbsoluteMinimumExclusionValue->getValue()->isEqualTo(value)) { |
| 1371 |
if (isDataValueExcluded(mAbsoluteMinimumExclusionValue,exclusionType)) { |
| 1372 |
return true; |
| 1373 |
} |
| 1374 |
if (!valueInclusively) { |
| 1375 |
return true; |
| 1376 |
} |
| 1377 |
} |
| 1378 |
} |
| 1379 |
|
| 1380 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(value); |
| 1381 |
CDatatypeRealValueSpaceMap::const_iterator itLB = CDatatypeRealValueSpaceMap::lowerBound(mapValueArranger), it = CDatatypeRealValueSpaceMap::constBegin(), itEnd = CDatatypeRealValueSpaceMap::constEnd(); |
| 1382 |
if (it == itEnd) { |
| 1383 |
// no restrictions in value map |
| 1384 |
return false; |
| 1385 |
} |
| 1386 |
if (it == itLB) { |
| 1387 |
const CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 1388 |
CDatatypeRealValueData* realValueData = mapData.mUseValue; |
| 1389 |
if (!valueInclusively) { |
| 1390 |
// value is before first value --> excluded |
| 1391 |
return isLeftDataIntervalExcluded(realValueData,exclusionType); |
| 1392 |
} else { |
| 1393 |
if (!isDataValueExcluded(realValueData,exclusionType)) { |
| 1394 |
return false; |
| 1395 |
} |
| 1396 |
return true; |
| 1397 |
} |
| 1398 |
} |
| 1399 |
if (itLB == itEnd) { |
| 1400 |
// value is after last value --> not excluded assuming value space is not clashed |
| 1401 |
return false; |
| 1402 |
} |
| 1403 |
while (it != itEnd && it != itLB) { |
| 1404 |
// try to find valid values before tested minimum value limit |
| 1405 |
const CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 1406 |
CDatatypeRealValueData* realValueData = mapData.mUseValue; |
| 1407 |
if (!isDataValueExcluded(realValueData,exclusionType)) { |
| 1408 |
return false; |
| 1409 |
} |
| 1410 |
++it; |
| 1411 |
|
| 1412 |
if (it != itEnd) { |
| 1413 |
const CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 1414 |
CDatatypeRealValueData* nextRealValueData = nextMapData.mUseValue; |
| 1415 |
if (it != itLB) { |
| 1416 |
if (!isDataIntervalExcluded(realValueData,nextRealValueData,exclusionType)) { |
| 1417 |
return false; |
| 1418 |
} |
| 1419 |
} else { |
| 1420 |
if (nextRealValueData->getValue()->isEqualTo(value)) { |
| 1421 |
// value is in the value space map |
| 1422 |
if (!isDataIntervalExcluded(realValueData,nextRealValueData,exclusionType)) { |
| 1423 |
return false; |
| 1424 |
} |
| 1425 |
if (valueInclusively && !isDataValueExcluded(nextRealValueData,exclusionType)) { |
| 1426 |
return false; |
| 1427 |
} |
| 1428 |
} else { |
| 1429 |
// test only to the tested minimum value limit |
| 1430 |
if (!isDataIntervalExcluded(realValueData,value,exclusionType)) { |
| 1431 |
return false; |
| 1432 |
} |
| 1433 |
if (valueInclusively && !isDataValueExcluded(value,exclusionType)) { |
| 1434 |
return false; |
| 1435 |
} |
| 1436 |
} |
| 1437 |
} |
| 1438 |
} |
| 1439 |
} |
| 1440 |
return true; |
| 1441 |
} |
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
bool CDatatypeRealValueSpaceMap::hasExcludedMaximum(CDataLiteralRealValue* value, bool valueInclusively, CDatatypeRealValueExclusionType* exclusionType) { |
| 1446 |
|
| 1447 |
if (mAbsoluteMaximumExclusionValue) { |
| 1448 |
if (mAbsoluteMaximumExclusionValue->getValue()->isLessThan(value)) { |
| 1449 |
return true; |
| 1450 |
} |
| 1451 |
if (mAbsoluteMaximumExclusionValue->getValue()->isEqualTo(value)) { |
| 1452 |
if (isDataValueExcluded(mAbsoluteMaximumExclusionValue,exclusionType)) { |
| 1453 |
return true; |
| 1454 |
} |
| 1455 |
if (!valueInclusively) { |
| 1456 |
return true; |
| 1457 |
} |
| 1458 |
} |
| 1459 |
} |
| 1460 |
|
| 1461 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(value); |
| 1462 |
CDatatypeRealValueSpaceMap::const_iterator itLB = CDatatypeRealValueSpaceMap::lowerBound(mapValueArranger), it = CDatatypeRealValueSpaceMap::constBegin(), itEnd = CDatatypeRealValueSpaceMap::constEnd(); |
| 1463 |
if (it == itEnd) { |
| 1464 |
// no restrictions in value map |
| 1465 |
return false; |
| 1466 |
} |
| 1467 |
if (itLB == itEnd) { |
| 1468 |
// value is after last value --> excluded |
| 1469 |
return true; |
| 1470 |
} |
| 1471 |
it = itLB; |
| 1472 |
while (it != itEnd) { |
| 1473 |
const CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 1474 |
CDatatypeRealValueData* realValueData = mapData.mUseValue; |
| 1475 |
if (it == itLB) { |
| 1476 |
if (realValueData->getValue()->isEqualTo(value)) { |
| 1477 |
if (valueInclusively && !isDataValueExcluded(realValueData,exclusionType)) { |
| 1478 |
return false; |
| 1479 |
} |
| 1480 |
} else { |
| 1481 |
if (!isDataIntervalExcluded(value,realValueData,exclusionType)) { |
| 1482 |
return false; |
| 1483 |
} |
| 1484 |
if (!isDataValueExcluded(realValueData,exclusionType)) { |
| 1485 |
return false; |
| 1486 |
} |
| 1487 |
if (valueInclusively && !isDataValueExcluded(value,exclusionType)) { |
| 1488 |
return false; |
| 1489 |
} |
| 1490 |
} |
| 1491 |
} |
| 1492 |
++it; |
| 1493 |
if (it != itEnd) { |
| 1494 |
const CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 1495 |
CDatatypeRealValueData* nextRealValueData = nextMapData.mUseValue; |
| 1496 |
|
| 1497 |
if (!isDataValueExcluded(nextRealValueData,exclusionType)) { |
| 1498 |
return false; |
| 1499 |
} |
| 1500 |
if (!isDataIntervalExcluded(realValueData,nextRealValueData,exclusionType)) { |
| 1501 |
return false; |
| 1502 |
} |
| 1503 |
} else { |
| 1504 |
if (!isRightDataIntervalExcluded(realValueData,exclusionType)) { |
| 1505 |
return false; |
| 1506 |
} |
| 1507 |
} |
| 1508 |
} |
| 1509 |
return true; |
| 1510 |
} |
| 1511 |
|
| 1512 |
|
| 1513 |
bool CDatatypeRealValueSpaceMap::isValueExcluded(CDataLiteralRealValue* value, CDatatypeRealValueExclusionType* exclusionType) { |
| 1514 |
if (isDataValueExcluded(value,exclusionType)) { |
| 1515 |
return true; |
| 1516 |
} |
| 1517 |
return false; |
| 1518 |
} |
| 1519 |
|
| 1520 |
|
| 1521 |
|
| 1522 |
bool CDatatypeRealValueSpaceMap::getNextPossibleDataValue(CDataLiteralRealValue* nextValue, CDataLiteralRealValue* lastValue) { |
| 1523 |
|
| 1524 |
if (!lastValue) { |
| 1525 |
if (!mAbsoluteMinimumExclusionValue) { |
| 1526 |
return false; |
| 1527 |
} |
| 1528 |
lastValue = mAbsoluteMinimumExclusionValue->getValue(); |
| 1529 |
if (!isDataValueExcluded(mAbsoluteMinimumExclusionValue,nullptr)) { |
| 1530 |
if (lastValue->hasFlag(CDataLiteralRealValue::DLRV_INTEGER_FLAG)) { |
| 1531 |
if (lastValue->isInfinite()) { |
| 1532 |
return false; |
| 1533 |
} else { |
| 1534 |
nextValue->initValue(lastValue); |
| 1535 |
return true; |
| 1536 |
} |
| 1537 |
} |
| 1538 |
} |
| 1539 |
} |
| 1540 |
|
| 1541 |
|
| 1542 |
CDatatypeRealValueSpaceMapArranger mapValueArranger(lastValue); |
| 1543 |
CDatatypeRealValueSpaceMap::iterator itBegin = CDatatypeRealValueSpaceMap::begin(), itLB = CDatatypeRealValueSpaceMap::lowerBound(mapValueArranger), itEnd = CDatatypeRealValueSpaceMap::end(); |
| 1544 |
CDatatypeRealValueSpaceMap::iterator it = itLB; |
| 1545 |
while (it != itEnd) { |
| 1546 |
|
| 1547 |
if (it == itLB) { |
| 1548 |
CDatatypeRealValueData* itValueData = it.value().mUseValue; |
| 1549 |
while (lastValue->isLessThan(itValueData->getValue())) { |
| 1550 |
CDatatypeRealValueSpaceMap::iterator itLast = it; |
| 1551 |
--itLast; |
| 1552 |
if (itLast != itEnd) { |
| 1553 |
--it; |
| 1554 |
} else { |
| 1555 |
if (!isLeftDataIntervalExcluded(itValueData,nullptr)) { |
| 1556 |
if (!itValueData->getLeftExclusionData()->areOnlyIntegerValuesAllowed()) { |
| 1557 |
return false; |
| 1558 |
} |
| 1559 |
nextValue->initRationalValueFromNextIntegerValue(lastValue); |
| 1560 |
if (nextValue->isLessThan(itValueData->getValue())) { |
| 1561 |
return true; |
| 1562 |
} else if (nextValue->isEqualTo(itValueData->getValue())) { |
| 1563 |
if (!isDataValueExcluded(itValueData,nullptr)) { |
| 1564 |
return true; |
| 1565 |
} |
| 1566 |
} |
| 1567 |
} |
| 1568 |
break; |
| 1569 |
} |
| 1570 |
} |
| 1571 |
} |
| 1572 |
CDatatypeRealValueSpaceMapData& mapData = it.value(); |
| 1573 |
CDatatypeRealValueData* itValueData = mapData.mUseValue; |
| 1574 |
|
| 1575 |
if (itValueData->getValue()->isGreaterThan(lastValue)) { |
| 1576 |
lastValue = itValueData->getValue(); |
| 1577 |
} |
| 1578 |
|
| 1579 |
++it; |
| 1580 |
if (it != itEnd) { |
| 1581 |
CDatatypeRealValueSpaceMapData& nextMapData = it.value(); |
| 1582 |
CDatatypeRealValueData* nextValueData = nextMapData.mUseValue; |
| 1583 |
|
| 1584 |
if (!isDataIntervalExcluded(itValueData,nextValueData,nullptr)) { |
| 1585 |
if (!itValueData->getRightExclusionData()->areOnlyIntegerValuesAllowed()) { |
| 1586 |
return false; |
| 1587 |
} |
| 1588 |
CDataLiteralRealValue* value = itValueData->getValue(); |
| 1589 |
nextValue->initRationalValueFromNextIntegerValue(lastValue); |
| 1590 |
if (nextValue->isLessThan(nextValueData->getValue())) { |
| 1591 |
return true; |
| 1592 |
} else if (nextValue->isEqualTo(nextValueData->getValue())) { |
| 1593 |
if (!isDataValueExcluded(nextValueData,nullptr)) { |
| 1594 |
return true; |
| 1595 |
} |
| 1596 |
} |
| 1597 |
} else if (!isDataValueExcluded(nextValueData,nullptr)) { |
| 1598 |
nextValue->initRationalValueFromNextIntegerValue(lastValue); |
| 1599 |
if (nextValue->isEqualTo(nextValueData->getValue())) { |
| 1600 |
return true; |
| 1601 |
} |
| 1602 |
} |
| 1603 |
} else { |
| 1604 |
if (!isRightDataIntervalExcluded(itValueData,nullptr) || !itValueData->getRightExclusionData()->areOnlyIntegerValuesAllowed()) { |
| 1605 |
return false; |
| 1606 |
} else { |
| 1607 |
nextValue->initRationalValueFromNextIntegerValue(lastValue); |
| 1608 |
return true; |
| 1609 |
} |
| 1610 |
} |
| 1611 |
|
| 1612 |
} |
| 1613 |
return false; |
| 1614 |
} |
| 1615 |
|
| 1616 |
|
| 1617 |
|
| 1618 |
}; // end namespace Process |
| 1619 |
|
| 1620 |
}; // end namespace Kernel |
| 1621 |
|
| 1622 |
}; // end namespace Reasoner |
| 1623 |
|
| 1624 |
}; // end namespace Konclude |