Java Code Examples for java.util.Comparator#comparingDouble()
The following examples show how to use
java.util.Comparator#comparingDouble() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EuropeanAIPlayer.java From freecol with GNU General Public License v2.0 | 6 votes |
/** * Gets the best goods wish for a carrier unit. * * @param aiUnit The carrier {@code AIUnit}. * @param goodsType The {@code GoodsType} to wish for. * @return The best {@code GoodsWish} for the unit. */ public GoodsWish getBestGoodsWish(AIUnit aiUnit, GoodsType goodsType) { final Unit carrier = aiUnit.getUnit(); final ToDoubleFunction<GoodsWish> wishValue = cacheDouble(gw -> { int turns = carrier.getTurnsToReach(carrier.getLocation(), gw.getDestination()); return (turns >= Unit.MANY_TURNS) ? -1.0 : (double)gw.getValue() / turns; }); final Comparator<GoodsWish> comp = Comparator.comparingDouble(wishValue); List<GoodsWish> wishes = goodsWishes.get(goodsType); return (wishes == null) ? null : maximize(wishes, gw -> wishValue.applyAsDouble(gw) > 0.0, comp); }
Example 2
Source File: TunnellerHack.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
@Override public void run() { KeyBindingUtils.setPressed(mc.gameSettings.keyBindSneak, true); WMinecraft.getPlayer().motionX = 0; WMinecraft.getPlayer().motionZ = 0; Vec3d eyes = RotationUtils.getEyesPos().addVector(-0.5, -0.5, -0.5); Comparator<BlockPos> comparator = Comparator.<BlockPos> comparingDouble( p -> eyes.squareDistanceTo(new Vec3d(p))); BlockPos pos = blocks.stream().max(comparator).get(); if(!equipSolidBlock(pos)) { ChatUtils.error( "Found a hole in the tunnel's floor but don't have any blocks to fill it with."); setEnabled(false); return; } if(BlockUtils.getMaterial(pos).isReplaceable()) BlockUtils.placeBlockSimple(pos); else { wurst.getHax().autoToolHack.equipBestTool(pos, false, true, false); BlockUtils.breakBlockSimple(pos); } }
Example 3
Source File: BasicTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public void testDoubleComparator() { Thing[] things = new Thing[doubleValues.length]; for (int i=0; i<doubleValues.length; i++) things[i] = new Thing(0, 0L, doubleValues[i], null); Comparator<Thing> comp = Comparator.comparingDouble(new ToDoubleFunction<Thing>() { @Override public double applyAsDouble(Thing thing) { return thing.getDoubleField(); } }); assertComparisons(things, comp, comparisons); }
Example 4
Source File: BasicTest.java From hottub with GNU General Public License v2.0 | 5 votes |
public void testDoubleComparator() { Thing[] things = new Thing[doubleValues.length]; for (int i=0; i<doubleValues.length; i++) things[i] = new Thing(0, 0L, doubleValues[i], null); Comparator<Thing> comp = Comparator.comparingDouble(new ToDoubleFunction<Thing>() { @Override public double applyAsDouble(Thing thing) { return thing.getDoubleField(); } }); assertComparisons(things, comp, comparisons); }
Example 5
Source File: BasicTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void testDoubleComparator() { Thing[] things = new Thing[doubleValues.length]; for (int i=0; i<doubleValues.length; i++) things[i] = new Thing(0, 0L, doubleValues[i], null); Comparator<Thing> comp = Comparator.comparingDouble(new ToDoubleFunction<Thing>() { @Override public double applyAsDouble(Thing thing) { return thing.getDoubleField(); } }); assertComparisons(things, comp, comparisons); }
Example 6
Source File: BasicTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void testDoubleComparator() { Thing[] things = new Thing[doubleValues.length]; for (int i=0; i<doubleValues.length; i++) things[i] = new Thing(0, 0L, doubleValues[i], null); Comparator<Thing> comp = Comparator.comparingDouble(new ToDoubleFunction<Thing>() { @Override public double applyAsDouble(Thing thing) { return thing.getDoubleField(); } }); assertComparisons(things, comp, comparisons); }
Example 7
Source File: BasicTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void testDoubleComparator() { Thing[] things = new Thing[doubleValues.length]; for (int i=0; i<doubleValues.length; i++) things[i] = new Thing(0, 0L, doubleValues[i], null); Comparator<Thing> comp = Comparator.comparingDouble(new ToDoubleFunction<Thing>() { @Override public double applyAsDouble(Thing thing) { return thing.getDoubleField(); } }); assertComparisons(things, comp, comparisons); }
Example 8
Source File: BasicTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void testDoubleComparator() { Thing[] things = new Thing[doubleValues.length]; for (int i=0; i<doubleValues.length; i++) things[i] = new Thing(0, 0L, doubleValues[i], null); Comparator<Thing> comp = Comparator.comparingDouble(new ToDoubleFunction<Thing>() { @Override public double applyAsDouble(Thing thing) { return thing.getDoubleField(); } }); assertComparisons(things, comp, comparisons); }
Example 9
Source File: TunnellerHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Override public void run() { MC.options.keySneak.setPressed(true); Vec3d velocity = MC.player.getVelocity(); MC.player.setVelocity(0, velocity.y, 0); Vec3d eyes = RotationUtils.getEyesPos().add(-0.5, -0.5, -0.5); Comparator<BlockPos> comparator = Comparator.<BlockPos> comparingDouble( p -> eyes.squaredDistanceTo(Vec3d.of(p))); BlockPos pos = blocks.stream().max(comparator).get(); if(!equipSolidBlock(pos)) { ChatUtils.error( "Found a hole in the tunnel's floor but don't have any blocks to fill it with."); setEnabled(false); return; } if(BlockUtils.getState(pos).getMaterial().isReplaceable()) placeBlockSimple(pos); else { WURST.getHax().autoToolHack.equipBestTool(pos, false, true, false); breakBlockSimple(pos); } }
Example 10
Source File: BasicTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public void testDoubleComparator() { Thing[] things = new Thing[doubleValues.length]; for (int i=0; i<doubleValues.length; i++) things[i] = new Thing(0, 0L, doubleValues[i], null); Comparator<Thing> comp = Comparator.comparingDouble(new ToDoubleFunction<Thing>() { @Override public double applyAsDouble(Thing thing) { return thing.getDoubleField(); } }); assertComparisons(things, comp, comparisons); }
Example 11
Source File: BasicTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void testDoubleComparator() { Thing[] things = new Thing[doubleValues.length]; for (int i=0; i<doubleValues.length; i++) things[i] = new Thing(0, 0L, doubleValues[i], null); Comparator<Thing> comp = Comparator.comparingDouble(new ToDoubleFunction<Thing>() { @Override public double applyAsDouble(Thing thing) { return thing.getDoubleField(); } }); assertComparisons(things, comp, comparisons); }
Example 12
Source File: BasicTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void testDoubleComparator() { Thing[] things = new Thing[doubleValues.length]; for (int i=0; i<doubleValues.length; i++) things[i] = new Thing(0, 0L, doubleValues[i], null); Comparator<Thing> comp = Comparator.comparingDouble(new ToDoubleFunction<Thing>() { @Override public double applyAsDouble(Thing thing) { return thing.getDoubleField(); } }); assertComparisons(things, comp, comparisons); }
Example 13
Source File: BasicTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public void testDoubleComparator() { Thing[] things = new Thing[doubleValues.length]; for (int i=0; i<doubleValues.length; i++) things[i] = new Thing(0, 0L, doubleValues[i], null); Comparator<Thing> comp = Comparator.comparingDouble(new ToDoubleFunction<Thing>() { @Override public double applyAsDouble(Thing thing) { return thing.getDoubleField(); } }); assertComparisons(things, comp, comparisons); }
Example 14
Source File: KillauraHack.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
private Priority(String name, ToDoubleFunction<EntityLivingBase> keyExtractor) { this.name = name; comparator = Comparator.comparingDouble(keyExtractor); }
Example 15
Source File: KillauraHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
private Priority(String name, ToDoubleFunction<LivingEntity> keyExtractor) { this.name = name; comparator = Comparator.comparingDouble(keyExtractor); }
Example 16
Source File: ProPurchaseUtils.java From triplea with GNU General Public License v3.0 | 4 votes |
/** Comparator that sorts cheaper units before expensive ones. */ public static Comparator<Unit> getCostComparator(final ProData proData) { return Comparator.comparingDouble((unit) -> ProPurchaseUtils.getCost(proData, unit)); }
Example 17
Source File: KillauraLegitHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
private Priority(String name, ToDoubleFunction<LivingEntity> keyExtractor) { this.name = name; comparator = Comparator.comparingDouble(keyExtractor); }
Example 18
Source File: ComparatorTest.java From j2objc with Apache License 2.0 | 4 votes |
public void testComparingDouble() { Comparator<Item> comparator = Comparator.comparingDouble(Item::getOrderAsDouble); checkComparison(comparator, orderedItems); }
Example 19
Source File: ClickAuraHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
private Priority(String name, ToDoubleFunction<LivingEntity> keyExtractor) { this.name = name; comparator = Comparator.comparingDouble(keyExtractor); }
Example 20
Source File: BowAimbotHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
private Priority(String name, ToDoubleFunction<LivingEntity> keyExtractor) { this.name = name; comparator = Comparator.comparingDouble(keyExtractor); }