/// <inheritdoc /> public bool Equals(IIntervalSet <T> other) { if (other == null) { return(false); } return(Minus(other).IsEmpty&& other.Minus(this).IsEmpty); }
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)); } } }
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)); } } }
/// <inheritdoc /> public bool Intersects(IIntervalSet <T> other) { return(!other.Cross(this).IsEmpty); }
IIntervalSet <T> IIntervalSet <T> .Cross(IIntervalSet <T> other) { return(Cross(other)); }
IIntervalSet <T> IIntervalSet <T> .Plus(IIntervalSet <T> other) { return(Plus(other)); }
IIntervalSet <T> IIntervalSet <T> .Minus(IIntervalSet <T> other) { return(Minus(other)); }
/// <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())); }
/// <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())); }
/// <inheritdoc /> public TSet Minus(IIntervalSet <T> other) { return(Cross(other.Complement())); }
/// <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(); }
/// <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) { }
/// <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) { }
/// <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) { }