Exemple #1
0
        public void RemoveTest()
        {
            int[] weights = new[] { 2, 3, 5, 7 };
            WeightedSelection <int> ws = new WeightedSelection <int>(
                weights.ToList(),
                i => i);

            Assert.AreEqual(17, ws.TotalWeights);
            CollectionAssert.AreEquivalent(weights, ws.Items);
            CollectionAssert.AreEquivalent(new[] { 2, 5, 10, 17 }, ws.WeightCDF);

            ws.Remove(1);
            Assert.AreEqual(14, ws.TotalWeights);
            CollectionAssert.AreEquivalent(new[] { 2, 5, 7 }, ws.Items);
            CollectionAssert.AreEquivalent(new[] { 2, 7, 14 }, ws.WeightCDF);
        }