diff options
Diffstat (limited to 'subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/statespace/internal/ObjectivePriorityQueueImpl.java')
-rw-r--r-- | subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/statespace/internal/ObjectivePriorityQueueImpl.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/statespace/internal/ObjectivePriorityQueueImpl.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/statespace/internal/ObjectivePriorityQueueImpl.java index c88a411f..2f3e142a 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/statespace/internal/ObjectivePriorityQueueImpl.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/statespace/internal/ObjectivePriorityQueueImpl.java | |||
@@ -9,7 +9,6 @@ import tools.refinery.store.dse.transition.ObjectiveValues; | |||
9 | import tools.refinery.store.dse.transition.VersionWithObjectiveValue; | 9 | import tools.refinery.store.dse.transition.VersionWithObjectiveValue; |
10 | import tools.refinery.store.dse.transition.objectives.Objective; | 10 | import tools.refinery.store.dse.transition.objectives.Objective; |
11 | import tools.refinery.store.dse.transition.statespace.ObjectivePriorityQueue; | 11 | import tools.refinery.store.dse.transition.statespace.ObjectivePriorityQueue; |
12 | import tools.refinery.store.map.Version; | ||
13 | 12 | ||
14 | import java.util.Comparator; | 13 | import java.util.Comparator; |
15 | import java.util.List; | 14 | import java.util.List; |
@@ -37,27 +36,27 @@ public class ObjectivePriorityQueueImpl implements ObjectivePriorityQueue { | |||
37 | } | 36 | } |
38 | 37 | ||
39 | @Override | 38 | @Override |
40 | public void submit(VersionWithObjectiveValue versionWithObjectiveValue) { | 39 | public synchronized void submit(VersionWithObjectiveValue versionWithObjectiveValue) { |
41 | priorityQueue.add(versionWithObjectiveValue); | 40 | priorityQueue.add(versionWithObjectiveValue); |
42 | } | 41 | } |
43 | 42 | ||
44 | @Override | 43 | @Override |
45 | public void remove(VersionWithObjectiveValue versionWithObjectiveValue) { | 44 | public synchronized void remove(VersionWithObjectiveValue versionWithObjectiveValue) { |
46 | priorityQueue.remove(versionWithObjectiveValue); | 45 | priorityQueue.remove(versionWithObjectiveValue); |
47 | } | 46 | } |
48 | 47 | ||
49 | @Override | 48 | @Override |
50 | public int getSize() { | 49 | public synchronized int getSize() { |
51 | return priorityQueue.size(); | 50 | return priorityQueue.size(); |
52 | } | 51 | } |
53 | 52 | ||
54 | @Override | 53 | @Override |
55 | public VersionWithObjectiveValue getBest() { | 54 | public synchronized VersionWithObjectiveValue getBest() { |
56 | return priorityQueue.peek(); | 55 | return priorityQueue.peek(); |
57 | } | 56 | } |
58 | 57 | ||
59 | @Override | 58 | @Override |
60 | public VersionWithObjectiveValue getRandom(Random random) { | 59 | public synchronized VersionWithObjectiveValue getRandom(Random random) { |
61 | int randomPosition = random.nextInt(getSize()); | 60 | int randomPosition = random.nextInt(getSize()); |
62 | for (VersionWithObjectiveValue entry : this.priorityQueue) { | 61 | for (VersionWithObjectiveValue entry : this.priorityQueue) { |
63 | if (randomPosition-- == 0) { | 62 | if (randomPosition-- == 0) { |