mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-26 18:16:45 +00:00
avoid casting to int when comparing longs
This commit is contained in:
parent
401d3b8bfb
commit
67c76c3b28
2 changed files with 2 additions and 2 deletions
|
@ -34,7 +34,7 @@ public class BnBUtxoSelector implements UtxoSelector {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
utxoPool.sort((a, b) -> (int)(b.getEffectiveValue() - a.getEffectiveValue()));
|
utxoPool.sort((a, b) -> Long.compare(b.getEffectiveValue(), a.getEffectiveValue()));
|
||||||
|
|
||||||
long currentWasteValue = 0;
|
long currentWasteValue = 0;
|
||||||
ArrayDeque<Boolean> bestSelection = null;
|
ArrayDeque<Boolean> bestSelection = null;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class KnapsackUtxoSelector implements UtxoSelector {
|
||||||
//We now have a list of UTXOs that are all smaller than the target + MIN_CHANGE, but together sum to greater than actualTargetValue
|
//We now have a list of UTXOs that are all smaller than the target + MIN_CHANGE, but together sum to greater than actualTargetValue
|
||||||
// Solve subset sum by stochastic approximation
|
// Solve subset sum by stochastic approximation
|
||||||
|
|
||||||
applicableGroups.sort((a, b) -> (int)(b.getEffectiveValue() - a.getEffectiveValue()));
|
applicableGroups.sort((a, b) -> Long.compare(b.getEffectiveValue(), a.getEffectiveValue()));
|
||||||
boolean[] bestSelection = new boolean[applicableGroups.size()];
|
boolean[] bestSelection = new boolean[applicableGroups.size()];
|
||||||
|
|
||||||
long bestValue = findApproximateBestSubset(applicableGroups, totalLower, actualTargetValue, bestSelection);
|
long bestValue = findApproximateBestSubset(applicableGroups, totalLower, actualTargetValue, bestSelection);
|
||||||
|
|
Loading…
Reference in a new issue