Package cz.mendelu.xotradov
Class SimpleQueueComparator
java.lang.Object
cz.mendelu.xotradov.SimpleQueueComparator
- All Implemented Interfaces:
Comparator<Queue.BuildableItem>
The comparator backs up the SimpleQueueSorter.
It stores all current desires - acts of will concerning order of build items.
- Author:
- Jaroslav Otradovec
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDesire
(long longA, long longB) Add desire of order relationship between two items.int
compare
(Queue.BuildableItem buildableItem1, Queue.BuildableItem buildableItem2) static SimpleQueueComparator
boolean
hasDesiresFor
(long key) void
removeDesireOfKey
(long id) void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
SimpleQueueComparator
public SimpleQueueComparator()
-
-
Method Details
-
getInstance
-
hasDesiresFor
public boolean hasDesiresFor(long key) -
compare
- Specified by:
compare
in interfaceComparator<Queue.BuildableItem>
- Returns:
- -1 when first is more important, 1 when second is more important, default 0
-
addDesire
public void addDesire(long longA, long longB) Add desire of order relationship between two items. If is present vice versa relation, it is deleted.- Parameters:
longA
- Id of desired more important itemlongB
- Id of less important Queue.Item
-
removeDesireOfKey
public void removeDesireOfKey(long id) -
resetDesires
public void resetDesires()
-