Пример #1
0
        /// <summary>
        /// Returns the current set without periods in the specified set.
        /// </summary>
        public PeriodSet ExceptWith(PeriodSet other)
        {
            var result = new PeriodSet();

            foreach (Period item in this)
            {
                result.Add(item.From, +1);
                result.Add(item.To, -1);
            }
            foreach (Period item in other)
            {
                result.Add(item.From, -1);
                result.Add(item.To, +1);
            }
            result.Normalize();

            return(result);
        }
Пример #2
0
 /// <summary>
 /// Returns a set with all periods that are present in both the current set and in the specified collection.
 /// </summary>
 public PeriodSet UnionWith(PeriodSet other)
 {
     return(new PeriodSet(this.Concat(other)));
 }
Пример #3
0
 /// <summary>
 /// Returns a set that contains only periods that are present either in the current set or in the specified set, but not both.
 /// </summary>
 public PeriodSet SymmetricExceptWith(PeriodSet other)
 {
     return(ExceptWith(other).UnionWith(other.ExceptWith(this)));
 }
Пример #4
0
 /// <summary>
 /// Returns a set that only contains periods that exist in the current set and the specified set.
 /// </summary>
 public PeriodSet IntersectWith(PeriodSet other)
 {
     return(UnionWith(other).SymmetricExceptWith(SymmetricExceptWith(other)));
 }