Exemplo n.º 1
0
        public static IList<Interval> ProcessList_2(IList<Interval> list)
        {
            IList<Interval> result = new List<Interval>();
            IList<Interval> toBeRemoved = new List<Interval>();

            bool keep = true;
            foreach (Interval interval in list)
            {
                Interval newInterval = new Interval(interval.start, interval.end);
                keep = true;

                foreach (Interval fixInterval in list)
                {
                    if (interval.Equals(fixInterval)) continue;

                    //if the interval is contained, it can be simply removed
                    if (newInterval.start >= fixInterval.start && newInterval.end <= fixInterval.end)
                    {
                        keep = false;
                        break;
                    }

                    //fix the start so it stays out of other intervals
                    if (newInterval.start >= fixInterval.start && newInterval.start <= fixInterval.end)
                    {
                        newInterval.start = fixInterval.end;
                    }

                    //fix the end so it stays out of other intervals
                    if (newInterval.end >= fixInterval.start && newInterval.end <= fixInterval.end)
                    {
                        newInterval.end = fixInterval.start;
                    }
                }

                if (keep)
                {
                    result.Add(newInterval);
                }
            }

            return result;
        }
Exemplo n.º 2
0
 public static void RemoveOverlap(Interval doneInterval, Interval interval)
 {
     //if (interval.start >=  <= doneInterval.start
 }