void Introduce(ref OffsetLength offsetLength, S element, Int64 weight, int timeIndex) { if (weight != 0) { var handle = EnsureTime(ref offsetLength, timeIndex); var position = 0; while (handle.Array[handle.Offset + position].TimeIndex != timeIndex) { position++; } handle.Array[handle.Offset + position].Weight += weight; // if the introduction results in an empty region, we need to clean up if (handle.Array[handle.Offset + position].IsEmpty) { // drag everything after it down one for (int i = position + 1; i < handle.Length; i++) { handle.Array[handle.Offset + i - 1] = handle.Array[handle.Offset + i]; } handle.Array[handle.Offset + handle.Length - 1] = new CollectionTraceWithoutHeapIncrement(); // if the root element is empty, the list must be empty if (handle.Array[handle.Offset].IsEmpty) { increments.Release(ref offsetLength); } } } }
public void ReleaseCache() { // only release if tracking a key if (!cachedIncrementOffset.IsEmpty) { records.Release(ref cachedRecordsOffset); cachedIncrementOffset = new OffsetLength(); cachedTimeIndex = 0; } }
void Introduce(ref OffsetLength offsetLength, S element, Int64 weight, int timeIndex) { var handle = EnsureTime(ref offsetLength, timeIndex); var position = 0; while (handle.Array[handle.Offset + position].TimeIndex != timeIndex) { position++; } if (handle.Array[handle.Offset + position].IsEmpty(isZero)) { handle.Array[handle.Offset + position] = new CollectionTraceWithAggregationIncrement <S>(weight, timeIndex, element); } else { var incr = handle.Array[handle.Offset + position]; var result = new CollectionTraceWithAggregationIncrement <S>(incr.Weight + weight, timeIndex, axpy(1, element, incr.Value)); handle.Array[handle.Offset + position] = result; } // if the introduction results in an empty region, we need to clean up if (handle.Array[handle.Offset + position].IsEmpty(isZero)) { // drag everything after it down one for (int i = position + 1; i < handle.Length; i++) { handle.Array[handle.Offset + i - 1] = handle.Array[handle.Offset + i]; } handle.Array[handle.Offset + handle.Length - 1] = new CollectionTraceWithAggregationIncrement <S>(); // if the root element is empty, the list must be empty if (handle.Array[handle.Offset].IsEmpty(isZero)) { increments.Release(ref offsetLength); } } }