示例#1
0
        public void EnumerateDifferenceAt(int offsetLength, int timeIndex, NaiadList <Weighted <S> > toFill)
        {
            if (toFill.Count == 0)
            {
                var temp = new OffsetLength(offsetLength);


                var accum = new CollectionTraceWithAggregationIncrement <S>();

                var handle = increments.Dereference(temp);
                for (int i = 0; i < handle.Length && !handle.Array[handle.Offset + i].IsEmpty(isZero); i++)
                {
                    if (handle.Array[handle.Offset + i].TimeIndex == timeIndex)
                    {
                        accum.Add(handle.Array[handle.Offset + i], axpy);
                    }
                }

                if (!accum.IsEmpty(isZero))
                {
                    toFill.Add(new Weighted <S>(accum.Value, 1));
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
示例#2
0
        // no caching at the moment; should do, but need to figure out how...
        CollectionTraceWithAggregationIncrement <S> UpdateAccumulation(ref OffsetLength ol, int timeIndex)
        {
#if true
            if (ol.IsEmpty)
            {
                return(new CollectionTraceWithAggregationIncrement <S>(timeIndex));
            }

            var handle = increments.Dereference(ol);

            // special-case single element accumulations to avoid unprocessed accumulation dropping processed accumulation
            if (handle.Length == 1)
            {
                if (TimeLessThan(handle.Array[handle.Offset].TimeIndex, timeIndex))
                {
                    return(handle.Array[handle.Offset]);
                }
                else
                {
                    return(new CollectionTraceWithAggregationIncrement <S>(timeIndex));
                }
            }

            else
#else
            var handle = increments.Dereference(ol);
#endif
            {
                // if we have a hit on the cache ...
                if (ol.offsetLength == cachedIncrementOffset.offsetLength)
                {
                    for (int i = 0; i < handle.Length && !handle.Array[handle.Offset + i].IsEmpty(isZero); i++)
                    {
                        if (!handle.Array[handle.Offset + i].IsEmpty(isZero))
                        {
                            var inNew = TimeLessThan(handle.Array[handle.Offset + i].TimeIndex, timeIndex);
                            var inOld = TimeLessThan(handle.Array[handle.Offset + i].TimeIndex, cacheContents.TimeIndex);

                            if (inOld != inNew)
                            {
                                cacheContents.Add(handle.Array[handle.Offset + i], axpy, inOld ? -1 : +1);
                            }
                        }
                    }

                    cacheContents.TimeIndex = timeIndex;
                }
                else
                {
                    ReleaseCache(); // blow cache away and start over

                    for (int i = 0; i < handle.Length && !handle.Array[handle.Offset + i].IsEmpty(isZero); i++)
                    {
                        if (TimeLessThan(handle.Array[handle.Offset + i].TimeIndex, timeIndex))
                        {
                            cacheContents.Add(handle.Array[handle.Offset + i], axpy);
                        }
                    }

                    cachedIncrementOffset   = ol;
                    cacheContents.TimeIndex = timeIndex;
                }

                return(cacheContents);
            }
        }