Changeset 2129 for trunk/autoquest-core-tasktrees/src/main/java/de/ugoe
- Timestamp:
- 08/24/16 10:03:54 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskSymbolBucketedMap.java
r1853 r2129 78 78 /** 79 79 * <p> 80 * the id of the default event bucket 81 * </p> 82 */ 83 private static final int DEFAULT_EVENT_BUCKET_ID = 4; 84 85 /** 86 * <p> 87 * the id of the default sequence bucket 88 * </p> 89 */ 90 private static final int DEFAULT_SEQUENCE_BUCKET_ID = 0; 91 92 /** 93 * <p> 94 * the id of the default selection bucket 95 * </p> 96 */ 97 private static final int DEFAULT_SELECTION_BUCKET_ID = 1; 98 99 /** 100 * <p> 101 * the id of the default iteration bucket 102 * </p> 103 */ 104 private static final int DEFAULT_ITERATION_BUCKET_ID = 2; 105 106 /** 107 * <p> 108 * the id of the default optional bucket 109 * </p> 110 */ 111 private static final int DEFAULT_OPTIONAL_BUCKET_ID = 3; 112 113 /** 114 * <p> 115 * the default bucket search order for events 116 * </p> 117 */ 118 private static final int[] DEFAULT_EVENT_BUCKET_SEARCH_ORDER = new int[] 119 { DEFAULT_EVENT_BUCKET_ID, DEFAULT_ITERATION_BUCKET_ID, DEFAULT_OPTIONAL_BUCKET_ID, 120 DEFAULT_SELECTION_BUCKET_ID }; 121 122 /** 123 * <p> 124 * the default bucket search order for sequences 125 * </p> 126 */ 127 private static final int[] DEFAULT_SEQUENCE_BUCKET_SEARCH_ORDER = new int[] 128 { DEFAULT_SEQUENCE_BUCKET_ID, DEFAULT_ITERATION_BUCKET_ID, DEFAULT_OPTIONAL_BUCKET_ID, 129 DEFAULT_SELECTION_BUCKET_ID }; 130 131 /** 132 * <p> 133 * the default bucket search order for selection 134 * </p> 135 */ 136 private static final int[] DEFAULT_SELECTION_BUCKET_SEARCH_ORDER = new int[] 137 { DEFAULT_SELECTION_BUCKET_ID, DEFAULT_EVENT_BUCKET_ID, DEFAULT_ITERATION_BUCKET_ID, 138 DEFAULT_OPTIONAL_BUCKET_ID, DEFAULT_SEQUENCE_BUCKET_ID }; 139 140 /** 141 * <p> 142 * the default bucket search order for iterations 143 * </p> 144 */ 145 private static final int[] DEFAULT_ITERATION_BUCKET_SEARCH_ORDER = new int[] 146 { DEFAULT_ITERATION_BUCKET_ID, DEFAULT_OPTIONAL_BUCKET_ID, DEFAULT_SELECTION_BUCKET_ID, 147 DEFAULT_EVENT_BUCKET_ID, DEFAULT_SEQUENCE_BUCKET_ID }; 148 149 /** 150 * <p> 151 * the default bucket search order for optional 152 * </p> 153 */ 154 private static final int[] DEFAULT_OPTIONAL_BUCKET_SEARCH_ORDER = new int[] 155 { DEFAULT_OPTIONAL_BUCKET_ID, DEFAULT_EVENT_BUCKET_ID, DEFAULT_ITERATION_BUCKET_ID, 156 DEFAULT_SELECTION_BUCKET_ID, DEFAULT_SEQUENCE_BUCKET_ID }; 157 158 /** 159 * <p> 80 160 * Comparator to be used for comparing the task instances with each other 81 161 * </p> … … 106 186 */ 107 187 private int defaultBucket = 0; 188 189 /** 190 * <p> 191 * the adjustable bucket search order for events. This array is initialized for reuse as 192 * otherwise for any lookup of a bucket search order for an individual event, this array would 193 * be recreated. 194 * </p> 195 */ 196 private final int[] ADJUSTABLE_EVENT_SPECIFIC_BUCKET_SEARCH_ORDER = new int[] 197 { 0, 0, DEFAULT_ITERATION_BUCKET_ID, DEFAULT_OPTIONAL_BUCKET_ID, DEFAULT_EVENT_BUCKET_ID, 198 DEFAULT_SELECTION_BUCKET_ID }; 108 199 109 200 /** … … 408 499 // selections, and finally the rest. 409 500 410 if (task.getInstances().iterator().hasNext()) { 411 Event event = 412 ((IEventTaskInstance) ((IEventTask) task).getInstances().iterator().next()).getEvent(); 501 Collection<ITaskInstance> instances = task.getInstances(); 502 503 if (instances.size() > 0) { 504 Event event = ((IEventTaskInstance) instances.iterator().next()).getEvent(); 413 505 414 return new int[] { event.getTarget().hashCode() + event.getType().getName().hashCode(), 415 event.getType().getName().hashCode(), 2, 3, 4, 1 }; 506 ADJUSTABLE_EVENT_SPECIFIC_BUCKET_SEARCH_ORDER[0] = 507 event.getTarget().hashCode() + event.getType().getName().hashCode(); 508 ADJUSTABLE_EVENT_SPECIFIC_BUCKET_SEARCH_ORDER[1] = 509 event.getType().getName().hashCode(); 510 511 return ADJUSTABLE_EVENT_SPECIFIC_BUCKET_SEARCH_ORDER; 416 512 } 417 513 else { 418 return new int[] { 4, 2, 3, 1 };514 return DEFAULT_EVENT_BUCKET_SEARCH_ORDER; 419 515 } 420 516 } 421 517 else if (task instanceof ISequence) { 422 return new int[] { 0, 2, 3, 1 };518 return DEFAULT_SEQUENCE_BUCKET_SEARCH_ORDER; 423 519 } 424 520 else if (task instanceof ISelection) { 425 return new int[] { 1, 4, 2, 3 };521 return DEFAULT_SELECTION_BUCKET_SEARCH_ORDER; 426 522 } 427 523 else if (task instanceof IIteration) { 428 return new int[] { 2, 1, 4 };524 return DEFAULT_ITERATION_BUCKET_SEARCH_ORDER; 429 525 } 430 526 else if (task instanceof IOptional) { 431 return new int[] { 3, 4, 2, 1, 0 };527 return DEFAULT_OPTIONAL_BUCKET_SEARCH_ORDER; 432 528 } 433 529 … … 509 605 } 510 606 511 // try to search the other buckets 607 // try to search the other buckets (may be required, if bucket separation given by 608 // bucket ids is different from logical bucket separation of comparator 512 609 if (entry == null) { 513 Arrays.sort(bucketSearchOrder); 610 // create a copy of the search order to be able to sort and afterwards binary 611 // search it. The original version MUST NOT BE SORTED. 612 int[] bucketSearchOrderCopy = 613 Arrays.copyOf(bucketSearchOrder, bucketSearchOrder.length); 614 615 Arrays.sort(bucketSearchOrderCopy); 514 616 for (Map.Entry<Integer, List<Map.Entry<ITask, V>>> bucket : symbolBuckets.entrySet()) { 515 if (Arrays.binarySearch(bucketSearchOrder , bucket.getKey()) < 0) {617 if (Arrays.binarySearch(bucketSearchOrderCopy, bucket.getKey()) < 0) { 516 618 List<Map.Entry<ITask, V>> list = bucket.getValue(); 517 619 if (list != null) {
Note: See TracChangeset
for help on using the changeset viewer.