Changeset 1254
- Timestamp:
- 07/15/13 11:39:17 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/HTMLLogCompressor.java
r1234 r1254 253 253 EventEntry newEvent = new EventEntry(type, parameters, timestamp); 254 254 255 boolean added = false; 256 for (int i = 0; i < sortedEvents.size(); i++) { 257 if (sortedEvents.get(i).timestamp > newEvent.timestamp) { 258 sortedEvents.add(i, newEvent); 259 added = true; 255 int start = 0; 256 int end = sortedEvents.size(); 257 int center = 0; 258 long centerTimestamp; 259 260 while (start != end) { 261 center = start + ((end - start) / 2); 262 263 if ((center != start) || (center != end)) { 264 centerTimestamp = sortedEvents.get(center).timestamp; 265 266 if (centerTimestamp < newEvent.timestamp) { 267 start = Math.max(center, start + 1); 268 } 269 else if (centerTimestamp > newEvent.timestamp) { 270 end = Math.min(center, end - 1); 271 } 272 else { 273 // add the event directly where the center is, as the timestamps of the center 274 // and the new event are equal 275 start = end = center; 276 break; 277 } 278 } 279 else { 280 // add the event to the position denoted by the add index 260 281 break; 261 282 } 262 283 } 263 284 264 if (!added) { 265 sortedEvents.add(newEvent); 266 } 285 sortedEvents.add(start, newEvent); 267 286 268 287 return true;
Note: See TracChangeset
for help on using the changeset viewer.