public IntervalCollection GetMetaCollection(IntervalCollection.CostDelegate cost_del)
        {
            IntervalCollection intervalCollection = new IntervalCollection();

            this.Normalize();
            this.Optimize(0, this.Count - 1, intervalCollection, cost_del);
            intervalCollection.intervals.Sort();
            return(intervalCollection);
        }
        private void Optimize(int begin, int end, IntervalCollection meta, IntervalCollection.CostDelegate cost_del)
        {
            Interval i;

            i.contiguous = false;
            int    num  = -1;
            int    num2 = -1;
            double num3 = 0.0;

            for (int j = begin; j <= end; j++)
            {
                i.low = this[j].low;
                double num4 = 0.0;
                for (int k = j; k <= end; k++)
                {
                    i.high = this[k].high;
                    num4  += cost_del(this[k]);
                    double num5 = cost_del(i);
                    if (num5 < num4 && num4 > num3)
                    {
                        num  = j;
                        num2 = k;
                        num3 = num4;
                    }
                }
            }
            if (num < 0)
            {
                for (int l = begin; l <= end; l++)
                {
                    meta.Add(this[l]);
                }
            }
            else
            {
                i.low  = this[num].low;
                i.high = this[num2].high;
                meta.Add(i);
                if (num > begin)
                {
                    this.Optimize(begin, num - 1, meta, cost_del);
                }
                if (num2 < end)
                {
                    this.Optimize(num2 + 1, end, meta, cost_del);
                }
            }
        }