HdrHistogram.HistogramBase.Add C# (CSharp) Méthode

Add() public méthode

Add the contents of another histogram to this one.
if values in fromHistogram's are higher than highestTrackableValue.
public Add ( HistogramBase fromHistogram ) : void
fromHistogram HistogramBase The other histogram.
Résultat void
        public virtual void Add(HistogramBase fromHistogram)
        {
            if (HighestTrackableValue < fromHistogram.HighestTrackableValue)
            {
                throw new ArgumentOutOfRangeException(nameof(fromHistogram), $"The other histogram covers a wider range ({fromHistogram.HighestTrackableValue} than this one ({HighestTrackableValue}).");
            }
            if ((BucketCount == fromHistogram.BucketCount) &&
                    (SubBucketCount == fromHistogram.SubBucketCount) &&
                    (_unitMagnitude == fromHistogram._unitMagnitude))
            {
                // Counts arrays are of the same length and meaning, so we can just iterate and add directly:
                for (var i = 0; i < fromHistogram.CountsArrayLength; i++)
                {
                    AddToCountAtIndex(i, fromHistogram.GetCountAtIndex(i));
                }
            }
            else
            {
                // Arrays are not a direct match, so we can't just stream through and add them.
                // Instead, go through the array and add each non-zero value found at it's proper value:
                for (var i = 0; i < fromHistogram.CountsArrayLength; i++)
                {
                    var count = fromHistogram.GetCountAtIndex(i);
                    RecordValueWithCount(fromHistogram.ValueFromIndex(i), count);
                }
            }
        }
        

Usage Example

Exemple #1
0
 /// <summary>
 /// Copy this histogram into the target histogram, overwriting it's contents.
 /// </summary>
 /// <param name="source">The source histogram</param>
 /// <param name="targetHistogram">the histogram to copy into</param>
 public static void CopyInto(this HistogramBase source, HistogramBase targetHistogram)
 {
     targetHistogram.Reset();
     targetHistogram.Add(source);
     targetHistogram.StartTimeStamp = source.StartTimeStamp;
     targetHistogram.EndTimeStamp   = source.EndTimeStamp;
 }
All Usage Examples Of HdrHistogram.HistogramBase::Add