当前位置: 首页>>代码示例>>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;未经允许,请勿转载。