Example #1
0
        /// <summary>
        /// A helper function to calculate black interval results or white interval
        /// results.
        /// </summary>
        ///
        /// <param name="list"></param>
        /// <param name="timeStamp">The time stamp as milliseconds since Jan 1, 1970 UTC.</param>
        /// <param name="positiveResult">The positive result which is updated.</param>
        /// <param name="negativeResult">The negative result which is updated.</param>
        private static void calculateIntervalResult(SortedSet list, double timeStamp,
                                                    Interval positiveResult, Interval negativeResult)
        {
            for (IIterator i = new ILOG.J2CsMapping.Collections.IteratorAdapter(list.GetEnumerator()); i.HasNext();)
            {
                RepetitiveInterval element = (RepetitiveInterval)i.Next();

                RepetitiveInterval.Result result = element.getInterval(timeStamp);
                Interval tempInterval            = result.interval;
                if (result.isPositive == true)
                {
                    try {
                        positiveResult.unionWith(tempInterval);
                    } catch (Interval.Error ex) {
                        // We don't expect to get this error.
                        throw new Exception("Error in Interval.unionWith: "
                                            + ex.Message);
                    }
                }
                else
                {
                    if (!negativeResult.isValid())
                    {
                        negativeResult.set(tempInterval);
                    }
                    else
                    {
                        negativeResult.intersectWith(tempInterval);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// A helper function to calculate black interval results or white interval
        /// results.
        /// </summary>
        ///
        /// <param name="list"></param>
        /// <param name="timeStamp">The time stamp as milliseconds since Jan 1, 1970 UTC.</param>
        /// <param name="positiveResult">The positive result which is updated.</param>
        /// <param name="negativeResult">The negative result which is updated.</param>
        private static void calculateIntervalResult(
            HashedSet <RepetitiveInterval> list, double timeStamp,
            Interval positiveResult, Interval negativeResult)
        {
            Object[] array = ILOG.J2CsMapping.Collections.Collections.ToArray(list);
            System.Array.Sort(array);
            /* foreach */
            foreach (Object elementObj  in  array)
            {
                RepetitiveInterval element = (RepetitiveInterval)elementObj;

                RepetitiveInterval.Result result = element.getInterval(timeStamp);
                Interval tempInterval            = result.interval;
                if (result.isPositive == true)
                {
                    try {
                        positiveResult.unionWith(tempInterval);
                    } catch (Interval.Error ex) {
                        // We don't expect to get this error.
                        throw new Exception("Error in Interval.unionWith: "
                                            + ex.Message);
                    }
                }
                else
                {
                    if (!negativeResult.isValid())
                    {
                        negativeResult.set(tempInterval);
                    }
                    else
                    {
                        negativeResult.intersectWith(tempInterval);
                    }
                }
            }
        }