예제 #1
0
        public void Union(char[] expected, char from1, char to1, char from2, char to2)
        {
            var range1 = Range <char> .Create(from1, to1);

            RangeSet <char> set1   = range1;
            var             range2 = Range <char> .Create(from2, to2);

            RangeSet <char> set2 = range2;

            Assert.Equal(expected, RangeOperations <char> .Union(set1, set2).Expand());
            Assert.Equal(expected, new RangeSet <char>((IEnumerable <Range <char> >)(new[] { range1, range2 })).Expand());
            Assert.Equal(expected, (set1 | set2).Expand());
            Assert.Equal(expected, (range1 | range2).Expand());
            Assert.Equal(expected, (set1 | range2).Expand());
            Assert.Equal(expected, (range1 | set2).Expand());
        }
예제 #2
0
 public static RangeSet <T> operator |(RangeSet <T> left, Range <T> right)
 {
     return(RangeOperations <T> .Union(left, new RangeSet <T>(right)));
 }
예제 #3
0
 public static RangeSet <T> operator |(RangeSet <T> left, T right)
 {
     return(left.Contains(right) ? left : RangeOperations <T> .Union(left, new RangeSet <T>(right)));
 }
예제 #4
0
 public static RangeSet <T> operator |(T left, RangeSet <T> right)
 {
     return(right.Contains(left) ? right : RangeOperations <T> .Union(new RangeSet <T>(left), right));
 }