Пример #1
0
 /// <summary>
 /// Calculate the nearest other entry of the same type in memory. Count
 /// how many entries of the same type are within a defined range.
 /// </summary>
 /// <param name="offset"></param>
 /// <param name="offsets"></param>
 /// <param name="pi"></param>
 /// <param name="delta"></param>
 private void FindProximityDistances(long offset, List <long> offsets, ProcessedInformation pi, int delta)
 {
     pi.MinMemoryDistance = long.MaxValue;
     pi.MemProximityCount = 0;
     if (offsets.Count == 0)
     {
         // Everything was suspect ...
         return;
     }
     for (int n = 0; n < offsets.Count; n++)
     {
         if (offsets[n] == offset)
         {
             // Skip self.
             continue;
         }
         long diff;
         if (offsets[n] < offset)
         {
             diff = offset - offsets[n];
         }
         else
         {
             diff = offsets[n] - offset;
         }
         if (diff < pi.MinMemoryDistance)
         {
             pi.MinMemoryDistance = diff;
         }
         if (diff <= delta)
         {
             pi.MemProximityCount++;
         }
         else if (offsets[n] > offset)
         {
             return;
         }
     }
 }
Пример #2
0
 private void FindTimestamptDistances(DateTime timestamp, List <DateTime> timestamps, ProcessedInformation pi)
 {
     for (int n = 0; n < timestamps.Count; n++)
     {
         if (timestamps[n] == timestamp)
         {
             double diff = int.MaxValue;
             if (n > 0)
             {
                 TimeSpan ts = timestamp - timestamps[n - 1];
                 diff = ts.TotalDays;
             }
             if (n < (timestamps.Count - 1))
             {
                 TimeSpan ts = timestamps[n + 1] - timestamp;
                 double   d  = ts.TotalDays;
                 if (d < diff)
                 {
                     diff = d;
                 }
             }
             pi.MinDayDistance = diff;
             int proximityCount = 0;
             for (int i = n - 1; i > 0; i--)
             {
                 if (timestamps[i].AddDays(ProcessedInformation.DISTANCE_DAYS) >= timestamp)
                 {
                     proximityCount++;
                 }
                 else
                 {
                     break;
                 }
             }
             for (int i = n + 1; i < timestamps.Count; i++)
             {
                 if (timestamps[i] <= timestamp.AddDays(ProcessedInformation.DISTANCE_DAYS))
                 {
                     proximityCount++;
                 }
                 else
                 {
                     break;
                 }
             }
             pi.DayProximityCount = proximityCount;
             break;
         }
     }
 }
Пример #3
0
 private void FindTimestamptDistances(DateTime timestamp, List<DateTime> timestamps, ProcessedInformation pi)
 {
     for (int n = 0; n < timestamps.Count; n++) {
         if (timestamps[n] == timestamp) {
             double diff = int.MaxValue;
             if (n > 0) {
                 TimeSpan ts = timestamp - timestamps[n - 1];
                 diff = ts.TotalDays;
             }
             if (n < (timestamps.Count - 1)) {
                 TimeSpan ts = timestamps[n + 1] - timestamp;
                 double d = ts.TotalDays;
                 if (d < diff) diff = d;
             }
             pi.MinDayDistance = diff;
             int proximityCount = 0;
             for (int i = n - 1; i > 0; i--) {
                 if (timestamps[i].AddDays(ProcessedInformation.DISTANCE_DAYS) >= timestamp) {
                     proximityCount++;
                 } else {
                     break;
                 }
             }
             for (int i = n + 1; i < timestamps.Count; i++) {
                 if (timestamps[i] <= timestamp.AddDays(ProcessedInformation.DISTANCE_DAYS)) {
                     proximityCount++;
                 } else {
                     break;
                 }
             }
             pi.DayProximityCount = proximityCount;
             break;
         }
     }
 }
Пример #4
0
 /// <summary>
 /// Calculate the nearest other entry of the same type in memory. Count
 /// how many entries of the same type are within a defined range.
 /// </summary>
 /// <param name="offset"></param>
 /// <param name="offsets"></param>
 /// <param name="pi"></param>
 /// <param name="delta"></param>
 private void FindProximityDistances(long offset, List<long> offsets, ProcessedInformation pi, int delta)
 {
     pi.MinMemoryDistance = long.MaxValue;
     pi.MemProximityCount = 0;
     if (offsets.Count == 0) {
         // Everything was suspect ...
         return;
     }
     for (int n = 0; n < offsets.Count; n++) {
         if (offsets[n] == offset) {
             // Skip self.
             continue;
         }
         long diff;
         if (offsets[n] < offset) {
             diff = offset - offsets[n];
         } else {
             diff = offsets[n] - offset;
         }
         if (diff < pi.MinMemoryDistance) pi.MinMemoryDistance = diff;
         if (diff <= delta) {
             pi.MemProximityCount++;
         } else if (offsets[n] > offset) {
             return;
         }
     }
 }