本文整理匯總了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);
}