| 3284 | */ |
| 3285 | template <class DataType> |
| 3286 | QCPRange QCPDataContainer<DataType>::valueRange(bool &foundRange, QCP::SignDomain signDomain, const QCPRange &inKeyRange) |
| 3287 | { |
| 3288 | if (isEmpty()) |
| 3289 | { |
| 3290 | foundRange = false; |
| 3291 | return QCPRange(); |
| 3292 | } |
| 3293 | QCPRange range; |
| 3294 | const bool restrictKeyRange = inKeyRange != QCPRange(); |
| 3295 | bool haveLower = false; |
| 3296 | bool haveUpper = false; |
| 3297 | QCPRange current; |
| 3298 | QCPDataContainer<DataType>::const_iterator itBegin = constBegin(); |
| 3299 | QCPDataContainer<DataType>::const_iterator itEnd = constEnd(); |
| 3300 | if (DataType::sortKeyIsMainKey() && restrictKeyRange) |
| 3301 | { |
| 3302 | itBegin = findBegin(inKeyRange.lower, false); |
| 3303 | itEnd = findEnd(inKeyRange.upper, false); |
| 3304 | } |
| 3305 | if (signDomain == QCP::sdBoth) // range may be anywhere |
| 3306 | { |
| 3307 | for (QCPDataContainer<DataType>::const_iterator it = itBegin; it != itEnd; ++it) |
| 3308 | { |
| 3309 | if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper)) |
| 3310 | continue; |
| 3311 | current = it->valueRange(); |
| 3312 | if ((current.lower < range.lower || !haveLower) && !qIsNaN(current.lower) && std::isfinite(current.lower)) |
| 3313 | { |
| 3314 | range.lower = current.lower; |
| 3315 | haveLower = true; |
| 3316 | } |
| 3317 | if ((current.upper > range.upper || !haveUpper) && !qIsNaN(current.upper) && std::isfinite(current.upper)) |
| 3318 | { |
| 3319 | range.upper = current.upper; |
| 3320 | haveUpper = true; |
| 3321 | } |
| 3322 | } |
| 3323 | } else if (signDomain == QCP::sdNegative) // range may only be in the negative sign domain |
| 3324 | { |
| 3325 | for (QCPDataContainer<DataType>::const_iterator it = itBegin; it != itEnd; ++it) |
| 3326 | { |
| 3327 | if (restrictKeyRange && (it->mainKey() < inKeyRange.lower || it->mainKey() > inKeyRange.upper)) |
| 3328 | continue; |
| 3329 | current = it->valueRange(); |
| 3330 | if ((current.lower < range.lower || !haveLower) && current.lower < 0 && !qIsNaN(current.lower) && std::isfinite(current.lower)) |
| 3331 | { |
| 3332 | range.lower = current.lower; |
| 3333 | haveLower = true; |
| 3334 | } |
| 3335 | if ((current.upper > range.upper || !haveUpper) && current.upper < 0 && !qIsNaN(current.upper) && std::isfinite(current.upper)) |
| 3336 | { |
| 3337 | range.upper = current.upper; |
| 3338 | haveUpper = true; |
| 3339 | } |
| 3340 | } |
| 3341 | } else if (signDomain == QCP::sdPositive) // range may only be in the positive sign domain |
| 3342 | { |
| 3343 | for (QCPDataContainer<DataType>::const_iterator it = itBegin; it != itEnd; ++it) |
no test coverage detected