Package cz.mendelu.xotradov
Class SimpleQueueComparator
- java.lang.Object
-
- cz.mendelu.xotradov.SimpleQueueComparator
-
- All Implemented Interfaces:
Comparator<Queue.BuildableItem>
public class SimpleQueueComparator extends Object implements 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 Constructor Description SimpleQueueComparator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDesire(long longA, long longB)
Add desire of order relationship between two items.int
compare(Queue.BuildableItem buildableItem1, Queue.BuildableItem buildableItem2)
static SimpleQueueComparator
getInstance()
boolean
hasDesiresFor(long key)
void
removeDesireOfKey(long id)
void
resetDesires()
-
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
-
-
-
-
Method Detail
-
getInstance
public static SimpleQueueComparator getInstance()
-
hasDesiresFor
public boolean hasDesiresFor(long key)
-
compare
public int compare(Queue.BuildableItem buildableItem1, Queue.BuildableItem buildableItem2)
- 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()
-
-