Fix SortedSet using compare for equals (#4479)
Fix SortedSet using compare for equals
This commit is contained in:
@@ -27,6 +27,7 @@ import javax.annotation.Nonnull;
|
|||||||
|
|
||||||
import appeng.api.config.AccessRestriction;
|
import appeng.api.config.AccessRestriction;
|
||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
|
import appeng.api.networking.IGrid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to access information about AE's various power accepting blocks for
|
* Used to access information about AE's various power accepting blocks for
|
||||||
@@ -78,6 +79,10 @@ public interface IAEPowerStorage extends IEnergySource {
|
|||||||
* A higher value means it is more likely to be extracted from first, and less
|
* A higher value means it is more likely to be extracted from first, and less
|
||||||
* likely to be inserted into first.
|
* likely to be inserted into first.
|
||||||
*
|
*
|
||||||
|
* The value needs to be constant once added to a {@link IGrid}. Should it ever
|
||||||
|
* need to be changed, it has to be removed from the grid, then update the
|
||||||
|
* value, and finally added back to the grid.
|
||||||
|
*
|
||||||
* This should never use {@link Integer#MIN_VALUE} or {@link Integer#MAX_VALUE}.
|
* This should never use {@link Integer#MIN_VALUE} or {@link Integer#MAX_VALUE}.
|
||||||
*
|
*
|
||||||
* @return the priority for this storage
|
* @return the priority for this storage
|
||||||
|
|||||||
+7
-4
@@ -74,10 +74,13 @@ public class EnergyGridCache implements IEnergyGrid {
|
|||||||
return Double.compare(percent1, percent2);
|
return Double.compare(percent1, percent2);
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final Comparator<IAEPowerStorage> COMPARATOR_HIGHEST_PRIORITY_FIRST = (o1, o2) -> Integer
|
private static final Comparator<IAEPowerStorage> COMPARATOR_HIGHEST_PRIORITY_FIRST = (o1, o2) -> {
|
||||||
.compare(o2.getPriority(), o1.getPriority());
|
final int cmp = Integer.compare(o2.getPriority(), o1.getPriority());
|
||||||
private static final Comparator<IAEPowerStorage> COMPARATOR_LOWEST_PRIORITY_FIRST = (o1, o2) -> Integer
|
return cmp != 0 ? cmp : Integer.compare(System.identityHashCode(o2), System.identityHashCode(o1));
|
||||||
.compare(o1.getPriority(), o2.getPriority());
|
};
|
||||||
|
|
||||||
|
private static final Comparator<IAEPowerStorage> COMPARATOR_LOWEST_PRIORITY_FIRST = (o1,
|
||||||
|
o2) -> -COMPARATOR_HIGHEST_PRIORITY_FIRST.compare(o1, o2);
|
||||||
|
|
||||||
private final NavigableSet<EnergyThreshold> interests = Sets.newTreeSet();
|
private final NavigableSet<EnergyThreshold> interests = Sets.newTreeSet();
|
||||||
private final double averageLength = 40.0;
|
private final double averageLength = 40.0;
|
||||||
|
|||||||
Reference in New Issue
Block a user