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 Details

    • SimpleQueueComparator

      public SimpleQueueComparator()
  • Method Details

    • 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 interface Comparator<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 item
      longB - Id of less important Queue.Item
    • removeDesireOfKey

      public void removeDesireOfKey(long id)
    • resetDesires

      public void resetDesires()