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


Java IntMath.mod方法代碼示例

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


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

示例1: next

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Override
public TorchOrientation next(final int i) {
    final TorchOrientation temp = values()[IntMath.mod((this.ordinal() + i), 5)];
    if (temp != null) {
        return temp;
    }
    throw new NullPointerException();
}
 
開發者ID:ssauermann,項目名稱:BlockAPI,代碼行數:9,代碼來源:Torch.java

示例2: mod

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

示例3: mod

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Override
public IInteger mod(final IInteger that) {
	if (that instanceof IntegerSym) {
		return new IntegerSym(IntMath.mod(fIntValue, ((IntegerSym) that).fIntValue));
	}
	return valueOf(toBigNumerator().mod(that.toBigNumerator()));
}
 
開發者ID:axkr,項目名稱:symja_android_library,代碼行數:8,代碼來源:IntegerSym.java

示例4: updateNovel

import com.google.common.math.IntMath; //導入方法依賴的package包/類
public int updateNovel(Long novelId) throws IOException, InterruptedException
{
	CrawlerTask crawlerTask = crawlerTaskMapper.selectByPrimaryKey(novelId);
	if (crawlerTask == null) {
		logger.error("when update novel,select novelid = {} null,exit ",novelId);
		return -1;
	}
	
	String novelName = crawlerTask.getBookname();
	short crawledChapter = crawlerTask.getCrawledChapter();
	String crawlerUrl = crawlerTask.getSourceUrl();
	
	String sHtml = HttpClientUtils.getContent(crawlerUrl);
	if (sHtml == null) {
		logger.error("getContent {} error, quit crawle {}",crawlerUrl,novelName);
		return -2;
	}
	String charset =  RexxarPageUtils.getCharSetByBody(sHtml);		
	String cleanHtml = RexxarPageUtils.changeCharset(sHtml, "ISO-8859-1", charset);
	
	Document novelHtml = Jsoup.parse(cleanHtml); 
	
	String novelStatus = bqgNovelExtract.getStatus(novelHtml);
	String newChapterName = bqgNovelExtract.getLatestChapterName(novelHtml);
	short newDirCount = bqgNovelExtract.getDirectoryCount(novelHtml);
	if (newDirCount > crawledChapter) {  // 有最新章節更新
		logger.info("crawler novel {} find new chapter number {} ,new chapter name {}", novelName, newDirCount,newChapterName);	
		int crawledNum = 0;					
		
		Pair<String[], String[]> dirsAndUrls = bqgNovelExtract.getDirsAndUrls(novelHtml, crawlerUrl);
		final String[] allChapterNames = dirsAndUrls.getLeft();
		final String[] allChapterUrls = dirsAndUrls.getRight();
		
		int stepCount = (newDirCount - crawledChapter) / crawleChapterStep;
		if (stepCount > 0) {//對最新更新章節數前crawleChapterStep整數倍的章節, 采用如下方案更新
			int batchChapterNum = crawledChapter + stepCount * crawleChapterStep;
			
			for (int i = crawledChapter; i < batchChapterNum; i++) {
				//step 1 : create novel chapter file
				if (createNovelChapterFile(novelId,allChapterNames[i],allChapterUrls[i])) {
					//每讀取crawleChapterStep才更新數據庫
					crawledNum++;
					if (IntMath.mod(crawledNum, crawleChapterStep) == 0) {
						UpdateCrawlAndNovelDb(0,novelId,allChapterNames,novelStatus,newDirCount,newChapterName,(short) i);
					}
				} else{
					logger.error("createNovelChapterFile {} [{}]error! quit crawl {}:{}",
							allChapterNames[i],allChapterUrls[i],novelId,novelName);
					return -3;
				}
					
				Thread.sleep(crawleChapterIntervalTime);
			}
			
			crawledChapter = (short) batchChapterNum;  //update crawledChapter to batched new chapter
		}
		
		//對剩下不足crawleChapterStep整數倍的章節,每更新一章就寫文件和寫數據庫
		if(IntMath.mod(newDirCount - crawledChapter, crawleChapterStep) != 0){		
			for (int i = crawledChapter; i < newDirCount; i++) {	
				if(createNovelChapterFile(novelId,allChapterNames[i],allChapterUrls[i]))
				{
					UpdateCrawlAndNovelDb(1,novelId,allChapterNames,novelStatus,newDirCount,newChapterName,(short) i);
				}else{
					logger.error("createNovelChapterFile {} [{}]error! quit crawl {}:{}",
							allChapterNames[i],allChapterUrls[i],novelId,novelName);
					return -3;
				}
				Thread.sleep(crawleChapterIntervalTime);
			}
		}
	}else {
		logger.info("crawler novel {} find no update",novelName);
		return 2;
	}
	
	return 0;
}
 
開發者ID:phoenix2014,項目名稱:rexxar,代碼行數:79,代碼來源:UpdateNovelCrawler.java

示例5: mod

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/**
 * 保證結果為正數的取模.
 * 
 * 如果(v = x/m) <0,v+=m.
 */
public static int mod(int x, int m) {
	return IntMath.mod(x, m);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:9,代碼來源:MathUtil.java


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