本文整理汇总了C#中Histogram.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Histogram.Clear方法的具体用法?C# Histogram.Clear怎么用?C# Histogram.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Histogram
的用法示例。
在下文中一共展示了Histogram.Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HistogramOperations
public void HistogramOperations()
{
Histogram h = new Histogram(new double[] { 1.0, 3.0, 5.0, 7.0 });
Assert.IsTrue(h.Bins.Count == 3);
Assert.IsTrue(h.Range == Interval.FromEndpoints(1.0, 7.0));
Assert.IsTrue(h.BelowRangeBin.Range == Interval.FromEndpoints(Double.NegativeInfinity, 1.0));
Assert.IsTrue(h.Bins[0].Range == Interval.FromEndpoints(1.0, 3.0));
Assert.IsTrue(h.Bins[1].Range == Interval.FromEndpoints(3.0, 5.0));
Assert.IsTrue(h.Bins[2].Range == Interval.FromEndpoints(5.0, 7.0));
Assert.IsTrue(h.AboveRangeBin.Range == Interval.FromEndpoints(7.0, Double.PositiveInfinity));
AssertBinCounts(h, new int[] { 0, 0, 0, 0, 0 });
h.Add(-1.0);
AssertBinCounts(h, new int[] { 1, 0, 0, 0, 0 });
h.Add(0.0);
AssertBinCounts(h, new int[] { 2, 0, 0, 0, 0 });
h.Add(1.0);
AssertBinCounts(h, new int[] { 2, 1, 0, 0, 0 });
h.Add(2.0);
AssertBinCounts(h, new int[] { 2, 2, 0, 0, 0 });
h.Add(3.0);
AssertBinCounts(h, new int[] { 2, 2, 1, 0, 0 });
h.Add(4.0);
AssertBinCounts(h, new int[] { 2, 2, 2, 0, 0 });
h.Add(5.0);
AssertBinCounts(h, new int[] { 2, 2, 2, 1, 0 });
h.Add(6.0);
AssertBinCounts(h, new int[] { 2, 2, 2, 2, 0 });
h.Add(7.0);
AssertBinCounts(h, new int[] { 2, 2, 2, 2, 1 });
h.Add(8.0);
AssertBinCounts(h, new int[] { 2, 2, 2, 2, 2 });
Assert.IsTrue(h.TotalCounts == 10);
//Assert.IsTrue(h.OutOfRangeCounts == 4);
h.Clear();
AssertBinCounts(h, new int[] { 0, 0, 0, 0, 0 });
Assert.IsTrue(h.TotalCounts == 0);
foreach (HistogramBin bin in h.Bins) {
bin.Increment();
}
AssertBinCounts(h, new int[] { 0, 1, 1, 1, 0 });
foreach (HistogramBin bin in h.Bins) {
bin.Deincrement();
}
AssertBinCounts(h, new int[] { 0, 0, 0, 0, 0 });
//Assert.IsTrue(h.OutOfRangeCounts == 0);
}