Exemple #1
0
        public IValueSet Union(IValueSet other)
        {
            SortedRangeSet OtherRangeSet = this.CheckCompatibility(other);

            return(new Builder(this.Type)
                   .AddAll(this.GetOrderedRanges())
                   .AddAll(OtherRangeSet.GetOrderedRanges())
                   .Build());
        }
Exemple #2
0
        public IValueSet Intersect(IValueSet other)
        {
            SortedRangeSet OtherRangeSet = this.CheckCompatibility(other);

            Builder Builder = new Builder(this.Type);

            IEnumerator <Range> Iterator1 = this.GetOrderedRanges().GetEnumerator();
            IEnumerator <Range> Iterator2 = OtherRangeSet.GetOrderedRanges().GetEnumerator();

            if (Iterator1.MoveNext() && Iterator2.MoveNext())
            {
                Range Range1 = Iterator1.Current;
                Range Range2 = Iterator2.Current;

                while (true)
                {
                    if (Range1.Overlaps(Range2))
                    {
                        Builder.Add(Range1.Intersect(Range2));
                    }

                    if (Range1.High.CompareTo(Range2.High) <= 0)
                    {
                        if (!Iterator1.MoveNext())
                        {
                            break;
                        }

                        Range1 = Iterator1.Current;
                    }
                    else
                    {
                        if (!Iterator2.MoveNext())
                        {
                            break;
                        }

                        Range2 = Iterator2.Current;
                    }
                }
            }

            return(Builder.Build());
        }
 public IValueSet Of(IType type, object first, params object[] rest)
 {
     return(SortedRangeSet.Of(type, first, rest));
 }
Exemple #4
0
 public static IValueSet CopyOfRanges(IType type, IEnumerable <Range> ranges)
 {
     return(SortedRangeSet.CopyOf(type, ranges));
 }
Exemple #5
0
 public static IValueSet OfRanges(Range first, params Range[] rest)
 {
     return(SortedRangeSet.CopyOf(first.Type, rest));
 }
Exemple #6
0
 public static IValueSet CopyOf(IType type, IEnumerable <object> values)
 {
     return(SortedRangeSet.CopyOf(type, values.Select(x => Range.Equal(type, x))));
 }