public void MinimumSegmentTreeTest() { var data = new int[] { 1, 2, 3, 4, 5 }.Select(i => new MinInt(i)).ToArray(); var segmentTree = new SegmentTree <MinInt>(data); Assert.Equal(1, segmentTree.Query(0..5)); Assert.Equal(3, segmentTree.Query(2..5)); segmentTree[4] = new MinInt(0); Assert.Equal(0, segmentTree.Query(0..5)); Assert.Equal(1, segmentTree.Query(0..4)); segmentTree[^ 4] = new MinInt(-5);
public MinInt Merge(MinInt other) => Value < other.Value ? this : other;