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 TypeMethodDescriptionvoidaddDesire(long longA, long longB) Add desire of order relationship between two items.intcompare(Queue.BuildableItem buildableItem1, Queue.BuildableItem buildableItem2) static SimpleQueueComparatorbooleanhasDesiresFor(long key) voidremoveDesireOfKey(long id) voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
comparein 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()
-