本文整理汇总了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();
}
示例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;
}
示例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()));
}
示例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;
}
示例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);
}