Ejemplo n.º 1
0
 /// <inheritdoc />
 public bool Equals(IIntervalSet <T> other)
 {
     if (other == null)
     {
         return(false);
     }
     return(Minus(other).IsEmpty&& other.Minus(this).IsEmpty);
 }
Ejemplo n.º 2
0
 private static IEnumerable <Boundary <T> > CrossBoundaries(IIntervalSet <T> one, IIntervalSet <T> other)
 {
     foreach (Boundary <T> otherBoundary in other.Boundaries)
     {
         BoundaryKind cross = one.Cross(otherBoundary.Location)?.Cross(otherBoundary.Kind);
         if (cross != null)
         {
             yield return(new Boundary <T>(otherBoundary.Location, cross));
         }
     }
 }
Ejemplo n.º 3
0
 private static IEnumerable <Boundary <T> > PlusBoundaries(IIntervalSet <T> one, IIntervalSet <T> other)
 {
     foreach (Boundary <T> otherBoundary in other.Boundaries)
     {
         BoundaryKind cross = one.Cross(otherBoundary.Location);
         if (cross == null)
         {
             yield return(otherBoundary);
         }
         else
         {
             BoundaryKind plusKind = cross.Plus(otherBoundary.Kind);
             yield return(new Boundary <T>(otherBoundary.Location, plusKind));
         }
     }
 }
Ejemplo n.º 4
0
 /// <inheritdoc />
 public bool Intersects(IIntervalSet <T> other)
 {
     return(!other.Cross(this).IsEmpty);
 }
Ejemplo n.º 5
0
 IIntervalSet <T> IIntervalSet <T> .Cross(IIntervalSet <T> other)
 {
     return(Cross(other));
 }
Ejemplo n.º 6
0
 IIntervalSet <T> IIntervalSet <T> .Plus(IIntervalSet <T> other)
 {
     return(Plus(other));
 }
Ejemplo n.º 7
0
 IIntervalSet <T> IIntervalSet <T> .Minus(IIntervalSet <T> other)
 {
     return(Minus(other));
 }
Ejemplo n.º 8
0
        /// <inheritdoc />
        public TSet Cross(IIntervalSet <T> other)
        {
            List <Boundary <T> > crossBoundaries = CrossBoundaries(this, other).Concat(CrossBoundaries(other, this)).ToList();

            return(Builder.MakeSet(Builder.Build(crossBoundaries, ContainsNegativeInfinity() && other.ContainsNegativeInfinity()).ToList()));
        }
Ejemplo n.º 9
0
        /// <inheritdoc />
        public TSet Plus(IIntervalSet <T> other)
        {
            List <Boundary <T> > plusBoundaries = PlusBoundaries(this, other).Concat(PlusBoundaries(other, this)).ToList();

            return(Builder.MakeSet(Builder.Build(plusBoundaries, ContainsNegativeInfinity() || other.ContainsNegativeInfinity()).ToList()));
        }
Ejemplo n.º 10
0
 /// <inheritdoc />
 public TSet Minus(IIntervalSet <T> other)
 {
     return(Cross(other.Complement()));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new <see cref="MultipleIntervalSet{TSet,TBuilder,TInterval,T}"/> based on a given <see cref="IIntervalSet{T}"/>
 /// </summary>
 /// <param name="set"></param>
 protected MultipleIntervalSet(IIntervalSet <T> set) : this()
 {
     _intervalList = Builder.Build(set.Boundaries.ToList(), set.ContainsNegativeInfinity()).ToList();
 }
Ejemplo n.º 12
0
 /// <inheritdoc />
 protected NonEmptyIntervalSet(IIntervalSet <T> set) : base(set)
 {
     CheckNonEmpty();
 }
 /// <summary>
 /// Initializes a new <see cref="DefaultNonEmptyIntervalSet{TSet,TBuilder,T}"/> based on a given <see cref="IIntervalSet{T}"/>
 /// </summary>
 /// <param name="set"></param>
 public DefaultNonEmptyIntervalSet(IIntervalSet <T> set) : base(set)
 {
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new <see cref="BoundedPeriodSet"/> based on a given <see cref="IIntervalSet{T}"/> of <see cref="DateTime"/>
 /// </summary>
 /// <param name="set"></param>
 public BoundedPeriodSet(IIntervalSet <DateTime> set) : base(set)
 {
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Initializes a new <see cref="OpenPeriodSet"/> based on a given <see cref="IIntervalSet{T}"/> of <see cref="DateTime"/>
 /// </summary>
 /// <param name="set"></param>
 public OpenPeriodSet(IIntervalSet <DateTime> set) : base(set)
 {
 }