public Snapshot GetSnapshot(bool resetReservoir = false) { var size = Math.Min((int)this.count.GetValue(), this.values.Length); if (size == 0) { return(new UniformSnapshot(0, Enumerable.Empty <long>())); } var snapshotValues = new UserValueWrapper[size]; Array.Copy(this.values, snapshotValues, size); if (resetReservoir) { Array.Clear(this.values, 0, snapshotValues.Length); this.count.SetValue(0L); } Array.Sort(snapshotValues, UserValueWrapper.Comparer); var minValue = snapshotValues[0].UserValue; var maxValue = snapshotValues[size - 1].UserValue; return(new UniformSnapshot(this.count.GetValue(), snapshotValues.Select(v => v.Value), valuesAreSorted: true, minUserValue: minValue, maxUserValue: maxValue)); }
public Snapshot GetSnapshot(bool resetReservoir = false) { var size = this.Size; if (size == 0) { return(new UniformSnapshot(0, Enumerable.Empty <long>())); } UserValueWrapper[] values = new UserValueWrapper[size]; Array.Copy(this.values, values, size); if (resetReservoir) { count.SetValue(0L); } Array.Sort(values, UserValueWrapper.Comparer); var minValue = values[0].UserValue; var maxValue = values[size - 1].UserValue; return(new UniformSnapshot(this.count.Value, values.Select(v => v.Value), valuesAreSorted: true, minUserValue: minValue, maxUserValue: maxValue)); }