當前位置: 首頁>>代碼示例>>Java>>正文


Java IntMath.gcd方法代碼示例

本文整理匯總了Java中com.google.common.math.IntMath.gcd方法的典型用法代碼示例。如果您正苦於以下問題:Java IntMath.gcd方法的具體用法?Java IntMath.gcd怎麽用?Java IntMath.gcd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.math.IntMath的用法示例。


在下文中一共展示了IntMath.gcd方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createSlidingUnifier

import com.google.common.math.IntMath; //導入方法依賴的package包/類
public static PTOperator createSlidingUnifier(StreamMeta streamMeta, PhysicalPlan plan, int
    operatorApplicationWindowCount, int slidingWindowCount)
{
  int gcd = IntMath.gcd(operatorApplicationWindowCount, slidingWindowCount);
  OperatorMeta um = streamMeta.getSource()
      .getSlidingUnifier(operatorApplicationWindowCount / gcd, gcd, slidingWindowCount / gcd);
  PTOperator pu = plan.newOperator(um, um.getName());

  Operator unifier = um.getOperator();
  PortMappingDescriptor mergeDesc = new PortMappingDescriptor();
  Operators.describe(unifier, mergeDesc);
  if (mergeDesc.outputPorts.size() != 1) {
    throw new AssertionError("Unifier must have a single output port, instead found : " + mergeDesc.outputPorts);
  }
  pu.unifiedOperatorMeta = streamMeta.getSource().getOperatorMeta();
  pu.outputs.add(new PTOutput(mergeDesc.outputPorts.keySet().iterator().next(), streamMeta, pu));
  plan.newOpers.put(pu, unifier);
  return pu;
}
 
開發者ID:apache,項目名稱:apex-core,代碼行數:20,代碼來源:StreamMapping.java

示例2: RatLitExpr

import com.google.common.math.IntMath; //導入方法依賴的package包/類
RatLitExpr(final int num, final int denom) {
	checkArgument(denom != 0);

	final int gcd = IntMath.gcd(Math.abs(num), Math.abs(denom));
	if (denom >= 0) {
		this.num = num / gcd;
		this.denom = denom / gcd;
	} else {
		this.num = -num / gcd;
		this.denom = -denom / gcd;
	}
}
 
開發者ID:FTSRG,項目名稱:theta,代碼行數:13,代碼來源:RatLitExpr.java

示例3: gCD

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Benchmark int gCD(int reps) {
  int tmp = 0;
  for (int i = 0; i < reps; i++) {
    int j = i & ARRAY_MASK;
    tmp += IntMath.gcd(nonnegative[j], positive[j]);
  }
  return tmp;
}
 
開發者ID:sander120786,項目名稱:guava-libraries,代碼行數:9,代碼來源:IntMathBenchmark.java

示例4: activate

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void activate()
{
  alive = true;
  APPLICATION_WINDOW_COUNT = context.getValue(OperatorContext.APPLICATION_WINDOW_COUNT);
  if (context.getValue(OperatorContext.SLIDE_BY_WINDOW_COUNT) != null) {
    int slidingWindowCount = context.getValue(OperatorContext.SLIDE_BY_WINDOW_COUNT);
    APPLICATION_WINDOW_COUNT = IntMath.gcd(APPLICATION_WINDOW_COUNT, slidingWindowCount);
  }
  DAG_CHECKPOINT_WINDOW_COUNT = context.getValue(Context.DAGContext.CHECKPOINT_WINDOW_COUNT);
  CHECKPOINT_WINDOW_COUNT = context.getValue(OperatorContext.CHECKPOINT_WINDOW_COUNT);
  Collection<StatsListener> statsListeners = context.getValue(OperatorContext.STATS_LISTENERS);

  if (CHECKPOINT_WINDOW_COUNT % APPLICATION_WINDOW_COUNT != 0) {
    logger.warn("{} is not exact multiple of {} for operator {}. This may cause side effects such as processing to begin without beginWindow preceding it in the first window after activation.",
        OperatorContext.CHECKPOINT_WINDOW_COUNT,
        OperatorContext.APPLICATION_WINDOW_COUNT,
        operator);
  }

  PROCESSING_MODE = context.getValue(OperatorContext.PROCESSING_MODE);
  if (PROCESSING_MODE == ProcessingMode.EXACTLY_ONCE && CHECKPOINT_WINDOW_COUNT != 1) {
    logger.warn("Ignoring {} attribute in favor of {} processing mode", OperatorContext.CHECKPOINT_WINDOW_COUNT.getSimpleName(), ProcessingMode.EXACTLY_ONCE.name());
    CHECKPOINT_WINDOW_COUNT = 1;
  }

  activateSinks();
  if (operator instanceof Operator.ActivationListener) {
    ((Operator.ActivationListener<OperatorContext>)operator).activate(context);
  }

  if (statsListeners != null) {
    Iterator<StatsListener> iterator = statsListeners.iterator();
    while (iterator.hasNext()) {
      DATA_TUPLE_AWARE = iterator.next().getClass().isAnnotationPresent(StatsListener.DataQueueSize.class);
      if (DATA_TUPLE_AWARE) {
        break;
      }
    }
  }

  if (!DATA_TUPLE_AWARE && (operator instanceof StatsListener)) {
    DATA_TUPLE_AWARE = operator.getClass().isAnnotationPresent(StatsListener.DataQueueSize.class);
  }
  /*
   * If there were any requests which needed to be executed before the operator started
   * its normal execution, execute those requests now - e.g. Restarting the operator
   * recording for the operators which failed while recording and being replaced.
   */
  handleRequests(currentWindowId);
}
 
開發者ID:apache,項目名稱:apex-core,代碼行數:52,代碼來源:Node.java

示例5: gcdInt

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Override
public int gcdInt(int a, int b) {
  return IntMath.gcd(a, b);
}
 
開發者ID:sander120786,項目名稱:guava-libraries,代碼行數:5,代碼來源:ApacheBenchmark.java

示例6: lcm

import com.google.common.math.IntMath; //導入方法依賴的package包/類
private static int lcm(int a, int b) {
	//Divide before multiplying for overflow resistance.
	return a / IntMath.gcd(a, b) * b;
}
 
開發者ID:jbosboom,項目名稱:streamjit,代碼行數:5,代碼來源:MessageConstraint.java

示例7: gcd

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/**
 * 兩個數的最大公約數,必須均為非負數.
 * 
 * 是公約數,別想太多
 */
public static int gcd(int a, int b) {
	return IntMath.gcd(a, b);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:9,代碼來源:MathUtil.java


注:本文中的com.google.common.math.IntMath.gcd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。