protected override bool ReachedIterationLevel()
        {
            long currentIndexCount = SourceHistogram.GetCountAt(CurrentBucketIndex, CurrentSubBucketIndex);

            return((currentIndexCount != 0) &&
                   (
                       (_visitedSubBucketIndex != CurrentSubBucketIndex) ||
                       (_visitedBucketIndex != CurrentBucketIndex
                       )));
        }
Beispiel #2
0
 private void IncrementSubBucket()
 {
     _freshSubBucket = true;
     // Take on the next index:
     CurrentBucketIndex    = _nextBucketIndex;
     CurrentSubBucketIndex = _nextSubBucketIndex;
     _currentValueAtIndex  = _nextValueAtIndex;
     // Figure out the next next index:
     _nextSubBucketIndex++;
     if (_nextSubBucketIndex >= SourceHistogram.SubBucketCount)
     {
         _nextSubBucketIndex = SourceHistogram.SubBucketHalfCount;
         _nextBucketIndex++;
     }
     _nextValueAtIndex = SourceHistogram.ValueFromIndex(_nextBucketIndex, _nextSubBucketIndex);
 }
Beispiel #3
0
 /// <summary>
 /// Returns the next element in the iteration.
 /// </summary>
 /// <returns>the <see cref="HistogramIterationValue"/> associated with the next element in the iteration.</returns>
 private HistogramIterationValue Next()
 {
     // Move through the sub buckets and buckets until we hit the next reporting level:
     while (!ExhaustedSubBuckets())
     {
         CountAtThisValue = SourceHistogram.GetCountAt(CurrentBucketIndex, CurrentSubBucketIndex);
         if (_freshSubBucket)
         {
             // Don't add unless we've incremented since last bucket...
             TotalCountToCurrentIndex  += CountAtThisValue;
             _totalValueToCurrentIndex += CountAtThisValue * SourceHistogram.MedianEquivalentValue(_currentValueAtIndex);
             _freshSubBucket            = false;
         }
         if (ReachedIterationLevel())
         {
             var valueIteratedTo = GetValueIteratedTo();
             _currentIterationValue.Set(
                 valueIteratedTo,
                 _prevValueIteratedTo,
                 CountAtThisValue,
                 (TotalCountToCurrentIndex - _totalCountToPrevIndex),
                 TotalCountToCurrentIndex,
                 _totalValueToCurrentIndex,
                 ((100.0 * TotalCountToCurrentIndex) / ArrayTotalCount),
                 GetPercentileIteratedTo());
             _prevValueIteratedTo   = valueIteratedTo;
             _totalCountToPrevIndex = TotalCountToCurrentIndex;
             // move the next iteration level forward:
             IncrementIterationLevel();
             if (SourceHistogram.TotalCount != _savedHistogramTotalRawCount)
             {
                 throw new InvalidOperationException("Source has been modified during enumeration.");
             }
             return(_currentIterationValue);
         }
         IncrementSubBucket();
     }
     // Should not reach here. But possible for overflowed histograms under certain conditions
     throw new ArgumentOutOfRangeException();
 }
 protected override void IncrementIterationLevel()
 {
     _nextValueReportingLevel *= (long)_logBase;
     _nextValueReportingLevelLowestEquivalent = SourceHistogram.LowestEquivalentValue(_nextValueReportingLevel);
 }
 protected override void IncrementIterationLevel()
 {
     _nextValueReportingLevel += _valueUnitsPerBucket;
     _nextValueReportingLevelLowestEquivalent = SourceHistogram.LowestEquivalentValue(_nextValueReportingLevel);
 }
Beispiel #6
0
 protected virtual long GetValueIteratedTo()
 {
     return(SourceHistogram.HighestEquivalentValue(_currentValueAtIndex));
 }