java.lang.Double.min()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(231)

本文整理了Java中java.lang.Double.min()方法的一些代码示例,展示了Double.min()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Double.min()方法的具体详情如下:
包路径:java.lang.Double
类名称:Double
方法名:min

Double.min介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

public static PlanNodeStatsEstimate computeSemiJoin(PlanNodeStatsEstimate sourceStats, PlanNodeStatsEstimate filteringSourceStats, Symbol sourceJoinSymbol, Symbol filteringSourceJoinSymbol)
{
  return compute(sourceStats, filteringSourceStats, sourceJoinSymbol, filteringSourceJoinSymbol,
      (sourceJoinSymbolStats, filteringSourceJoinSymbolStats) ->
          min(filteringSourceJoinSymbolStats.getDistinctValuesCount(), sourceJoinSymbolStats.getDistinctValuesCount()));
}

代码示例来源:origin: apache/hive

factor = Double.min(factor, 1.0d);
if (!allColsFilteredByStats) {
 factor = Double.max(factor, HiveConf.getFloatVar(aspCtx.getConf(), HiveConf.ConfVars.HIVE_STATS_IN_MIN_RATIO));

代码示例来源:origin: prestodb/presto

result.setOutputRowCount(min(inEstimate.getOutputRowCount(), notNullValuesBeforeIn));
      .mapDistinctValuesCount(newDistinctValuesCount -> min(newDistinctValuesCount, valueStats.getDistinctValuesCount()));
  result.addSymbolStatistics(valueSymbol, newSymbolStats);

代码示例来源:origin: prestodb/presto

public static PlanNodeStatsEstimate capStats(PlanNodeStatsEstimate stats, PlanNodeStatsEstimate cap)
{
  if (stats.isOutputRowCountUnknown() || cap.isOutputRowCountUnknown()) {
    return PlanNodeStatsEstimate.unknown();
  }
  PlanNodeStatsEstimate.Builder result = PlanNodeStatsEstimate.builder();
  double cappedRowCount = min(stats.getOutputRowCount(), cap.getOutputRowCount());
  result.setOutputRowCount(cappedRowCount);
  stats.getSymbolsWithKnownStatistics().forEach(symbol -> {
    SymbolStatsEstimate symbolStats = stats.getSymbolStatistics(symbol);
    SymbolStatsEstimate capSymbolStats = cap.getSymbolStatistics(symbol);
    SymbolStatsEstimate.Builder newSymbolStats = SymbolStatsEstimate.builder();
    // for simplicity keep the average row size the same as in the input
    // in most cases the average row size doesn't change after applying filters
    newSymbolStats.setAverageRowSize(symbolStats.getAverageRowSize());
    newSymbolStats.setDistinctValuesCount(min(symbolStats.getDistinctValuesCount(), capSymbolStats.getDistinctValuesCount()));
    newSymbolStats.setLowValue(max(symbolStats.getLowValue(), capSymbolStats.getLowValue()));
    newSymbolStats.setHighValue(min(symbolStats.getHighValue(), capSymbolStats.getHighValue()));
    double numberOfNulls = stats.getOutputRowCount() * symbolStats.getNullsFraction();
    double capNumberOfNulls = cap.getOutputRowCount() * capSymbolStats.getNullsFraction();
    double cappedNumberOfNulls = min(numberOfNulls, capNumberOfNulls);
    double cappedNullsFraction = cappedRowCount == 0 ? 1 : cappedNumberOfNulls / cappedRowCount;
    newSymbolStats.setNullsFraction(cappedNullsFraction);
    result.addSymbolStatistics(symbol, newSymbolStats.build());
  });
  return result.build();
}

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Creates a new region bounded by the two opposing locations.
 * @param from The first bounding corner.
 * @param to The second bounding corner.
 */
public RectangularRegion(Location from, Location to) {
  Preconditions.checkArgument(
      from.getWorld() == to.getWorld(),
      "The given locations do not have matching worlds."
  );
  this.lowCorner = new Location(
      from.getWorld(),
      Double.min(from.getX(), to.getX()),
      Double.min(from.getY(), to.getY()),
      Double.min(from.getZ(), to.getZ())
  );
  this.highCorner = new Location(
      from.getWorld(),
      Double.max(from.getX(), to.getX()),
      Double.max(from.getY(), to.getY()),
      Double.max(from.getZ(), to.getZ())
  );
  this.widthX = highCorner.getBlockX() - lowCorner.getBlockX();
  this.widthY = highCorner.getBlockY() - lowCorner.getBlockY();
  this.widthZ = highCorner.getBlockZ() - lowCorner.getBlockZ();
}

代码示例来源:origin: prestodb/presto

double subsetNullsCount = subsetSymbolStats.getNullsFraction() * subsetRowCount;
double newNullsCount = max(supersetNullsCount - subsetNullsCount, 0);
newSymbolStats.setNullsFraction(min(newNullsCount, outputRowCount) / outputRowCount);

代码示例来源:origin: io.virtdata/virtdata-lib-basics

@Override
  public double applyAsDouble(double operand) {
    return Double.min(min,operand);
  }
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

@Override
  public double applyAsDouble(double operand) {
    return Double.min(min,operand);
  }
}

代码示例来源:origin: io.virtdata/metagen-lib-basics

@Override
  public double applyAsDouble(double operand) {
    return Double.min(min,operand);
  }
}

代码示例来源:origin: io.virtdata/virtdata-lib-basics

@Override
  public double applyAsDouble(double operand) {
    return Double.min(max,Double.max(min,operand));
  }
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

@Override
  public double applyAsDouble(double operand) {
    return Double.min(max,Double.max(min,operand));
  }
}

代码示例来源:origin: vmware/xenon

void min(double newValue) {
    while (true) {
      long oldBits = this.number.get();
      double oldValue = Double.longBitsToDouble(oldBits);
      long newBits = Double.doubleToLongBits(Double.min(oldValue, newValue));
      if (this.number.compareAndSet(oldBits, newBits)) {
        return;
      }
    }
  }
}

代码示例来源:origin: com.vmware.xenon/xenon-common

void min(double newValue) {
    while (true) {
      long oldBits = this.number.get();
      double oldValue = Double.longBitsToDouble(oldBits);
      long newBits = Double.doubleToLongBits(Double.min(oldValue, newValue));
      if (this.number.compareAndSet(oldBits, newBits)) {
        return;
      }
    }
  }
}

代码示例来源:origin: io.prestosql/presto-main

public static PlanNodeStatsEstimate computeSemiJoin(PlanNodeStatsEstimate sourceStats, PlanNodeStatsEstimate filteringSourceStats, Symbol sourceJoinSymbol, Symbol filteringSourceJoinSymbol)
{
  return compute(sourceStats, filteringSourceStats, sourceJoinSymbol, filteringSourceJoinSymbol,
      (sourceJoinSymbolStats, filteringSourceJoinSymbolStats) ->
          min(filteringSourceJoinSymbolStats.getDistinctValuesCount(), sourceJoinSymbolStats.getDistinctValuesCount()));
}

代码示例来源:origin: tec.uom/uom-se

/**
 * Creates a BinaryOperator to calculate the minimum Quantity
 * 
 * @return the min BinaryOperator, not null.
 */
public static <Q extends Quantity<Q>> BinaryOperator<Quantity<Q>> min() {
   return (q1, q2) -> {
     double d1 = q1.getValue().doubleValue();
     double d2 = q2.to(q1.getUnit()).getValue().doubleValue();
     double min = Double.min(d1, d2);
     if (min == d1) {
       return q1;
     }
     return q2;
   };
 }

代码示例来源:origin: prestosql/presto

public static PlanNodeStatsEstimate computeSemiJoin(PlanNodeStatsEstimate sourceStats, PlanNodeStatsEstimate filteringSourceStats, Symbol sourceJoinSymbol, Symbol filteringSourceJoinSymbol)
{
  return compute(sourceStats, filteringSourceStats, sourceJoinSymbol, filteringSourceJoinSymbol,
      (sourceJoinSymbolStats, filteringSourceJoinSymbolStats) ->
          min(filteringSourceJoinSymbolStats.getDistinctValuesCount(), sourceJoinSymbolStats.getDistinctValuesCount()));
}

代码示例来源:origin: tec.units/indriya

/**
 * Creates a BinaryOperator to calculate the minimum Quantity
 * 
 * @return the min BinaryOperator, not null.
 */
public static <Q extends Quantity<Q>> BinaryOperator<Quantity<Q>> min() {
   return (q1, q2) -> {
     double d1 = q1.getValue().doubleValue();
     double d2 = q2.to(q1.getUnit()).getValue().doubleValue();
     double min = Double.min(d1, d2);
     if (min == d1) {
       return q1;
     }
     return q2;
   };
 }

代码示例来源:origin: io.prestosql/presto-main

public static PlanNodeStatsEstimate capStats(PlanNodeStatsEstimate stats, PlanNodeStatsEstimate cap)
{
  if (stats.isOutputRowCountUnknown() || cap.isOutputRowCountUnknown()) {
    return PlanNodeStatsEstimate.unknown();
  }
  PlanNodeStatsEstimate.Builder result = PlanNodeStatsEstimate.builder();
  double cappedRowCount = min(stats.getOutputRowCount(), cap.getOutputRowCount());
  result.setOutputRowCount(cappedRowCount);
  stats.getSymbolsWithKnownStatistics().forEach(symbol -> {
    SymbolStatsEstimate symbolStats = stats.getSymbolStatistics(symbol);
    SymbolStatsEstimate capSymbolStats = cap.getSymbolStatistics(symbol);
    SymbolStatsEstimate.Builder newSymbolStats = SymbolStatsEstimate.builder();
    // for simplicity keep the average row size the same as in the input
    // in most cases the average row size doesn't change after applying filters
    newSymbolStats.setAverageRowSize(symbolStats.getAverageRowSize());
    newSymbolStats.setDistinctValuesCount(min(symbolStats.getDistinctValuesCount(), capSymbolStats.getDistinctValuesCount()));
    newSymbolStats.setLowValue(max(symbolStats.getLowValue(), capSymbolStats.getLowValue()));
    newSymbolStats.setHighValue(min(symbolStats.getHighValue(), capSymbolStats.getHighValue()));
    double numberOfNulls = stats.getOutputRowCount() * symbolStats.getNullsFraction();
    double capNumberOfNulls = cap.getOutputRowCount() * capSymbolStats.getNullsFraction();
    double cappedNumberOfNulls = min(numberOfNulls, capNumberOfNulls);
    double cappedNullsFraction = cappedRowCount == 0 ? 1 : cappedNumberOfNulls / cappedRowCount;
    newSymbolStats.setNullsFraction(cappedNullsFraction);
    result.addSymbolStatistics(symbol, newSymbolStats.build());
  });
  return result.build();
}

代码示例来源:origin: NyaaCat/RPGItems-reloaded

@Override
public PowerResult<Double> hit(Player player, ItemStack stack, LivingEntity entity, double damage, EntityDamageByEntityEvent event) {
  if (damage < minDamage) return PowerResult.noop();
  if (!checkCooldown(this, player, cooldown, true, true)) return PowerResult.cd();
  if (!getItem().consumeDurability(stack, cost)) return PowerResult.cost();
  if (entity.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE)) {
    PotionEffect e = entity.getPotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
    if (e.getAmplifier() >= 4) return PowerResult.noop();
  }
  Context.instance().putExpiringSeconds(player.getUniqueId(), "realdamage.target", entity, 3);
  double health = entity.getHealth();
  double newHealth = health - realDamage;
  newHealth = max(newHealth, 0.1);//Bug workaround
  newHealth = min(newHealth, entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
  entity.setHealth(newHealth);
  return PowerResult.ok(damage);
}

代码示例来源:origin: NyaaCat/RPGItems-reloaded

@Override
public PowerResult<Void> tick(Player player, ItemStack stack) {
  if (!checkCooldownByString(this, player, "potiontick." + effect.getName(), interval, false, true)) return PowerResult.cd();
  if (!getItem().consumeDurability(stack, cost)) return PowerResult.cost();
  double health = player.getHealth();
  boolean hasEffect = false;
  for (PotionEffect potionEffect : player.getActivePotionEffects()) {
    if (potionEffect.getType().equals(effect)) {
      hasEffect = true;
      if (clear) {
        player.removePotionEffect(effect);
      } else if (potionEffect.getDuration() <= 5 || potionEffect.getAmplifier() < amplifier)
        player.addPotionEffect(new PotionEffect(effect, duration, amplifier, true), true);
      break;
    }
  }
  if (!hasEffect && !clear) {
    player.addPotionEffect(new PotionEffect(effect, duration, amplifier, true), true);
  }
  if (effect.equals(PotionEffectType.HEALTH_BOOST) && health > 0) {
    health = min(health, player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
    player.setHealth(health);
  }
  return PowerResult.ok();
}

相关文章