/// <inheritdoc cref="IReservoir" /> public IReservoirSnapshot GetSnapshot(bool resetReservoir) { var size = Math.Min((int)_count.GetValue(), _values.Length); if (size == 0) { return(new UniformSnapshot(0, 0.0, Enumerable.Empty <long>())); } var snapshotValues = new UserValueWrapper[size]; Array.Copy(_values, snapshotValues, size); Array.Sort(snapshotValues, UserValueWrapper.Comparer); var minValue = snapshotValues[0].UserValue; var maxValue = snapshotValues[size - 1].UserValue; var result = new UniformSnapshot( _count.GetValue(), _sum.GetValue(), snapshotValues.Select(v => v.Value), true, minValue, maxValue); if (resetReservoir) { Array.Clear(_values, 0, snapshotValues.Length); _count.SetValue(0L); _sum.SetValue(0.0); } return(result); }
// ReSharper restore MemberCanBePrivate.Global /// <inheritdoc cref="IReservoir" /> public IReservoirSnapshot GetSnapshot(bool resetReservoir) { var size = Size; if (size == 0) { return(new UniformSnapshot(0, 0.0, Enumerable.Empty <long>())); } var snapshotValues = new UserValueWrapper[size]; Array.Copy(_values, snapshotValues, size); if (resetReservoir) { _count.SetValue(0L); _sum.SetValue(0.0); } Array.Sort(snapshotValues, UserValueWrapper.Comparer); var minValue = snapshotValues[0].UserValue; var maxValue = snapshotValues[size - 1].UserValue; return(new UniformSnapshot( _count.GetValue(), _sum.GetValue(), snapshotValues.Select(v => v.Value), valuesAreSorted: true, minUserValue: minValue, maxUserValue: maxValue)); }
public void Can_be_assigned() { _num.SetValue(10.0); var y = _num; y.GetValue().Should().Be(10.0); }
/// <inheritdoc /> public void Reset() { _gauge.SetValue(0.0); }