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


Java IntMath.divide方法代碼示例

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


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

示例1: addToWorldChunks

import com.google.common.math.IntMath; //導入方法依賴的package包/類
public static void addToWorldChunks(Nation nation)
{
	for (Rect r : nation.getRegion().getRects())
	{
		if (!worldChunks.containsKey(r.getWorld()))
		{
			worldChunks.put(r.getWorld(), new Hashtable<Vector2i, ArrayList<Nation>>());
		}
		Hashtable<Vector2i, ArrayList<Nation>> chunks = worldChunks.get(r.getWorld());
		for (int i = IntMath.divide(r.getMinX(), 16, RoundingMode.FLOOR); i < IntMath.divide(r.getMaxX(), 16, RoundingMode.FLOOR) + 1; i++)
		{
			for (int j = IntMath.divide(r.getMinY(), 16, RoundingMode.FLOOR); j < IntMath.divide(r.getMaxY(), 16, RoundingMode.FLOOR) + 1; j++)
			{
				Vector2i vect = new Vector2i(i, j);
				if (!chunks.containsKey(vect))
				{
					chunks.put(vect, new ArrayList<Nation>());
				}
				if (!chunks.get(vect).contains(nation))
				{
					chunks.get(vect).add(nation);
				}
			}
		}
	}
}
 
開發者ID:Arckenver,項目名稱:Nations,代碼行數:27,代碼來源:DataHandler.java

示例2: splitToNChunks

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/**
 * If there are fewer files than chunks, fewer than numChunks will be returned.
 */
private static Iterable<List<Map.Entry<Symbol, File>>> splitToNChunks(
    final ImmutableMap<Symbol, File> inputMap, int numChunks) {
  checkArgument(numChunks > 0);
  final List<Map.Entry<Symbol, File>> emptyChunk = ImmutableList.of();

  if (inputMap.isEmpty()) {
    return Collections.nCopies(numChunks, emptyChunk);
  }

  final int chunkSize = IntMath.divide(inputMap.size(), numChunks, RoundingMode.UP);
  final ImmutableList<List<Map.Entry<Symbol, File>>> chunks =
      ImmutableList.copyOf(splitToChunksOfFixedSize(inputMap, chunkSize));
  if (chunks.size() == numChunks) {
    return chunks;
  } else {
    // there weren't enough elements to make the desired number of chunks, so we need to
    // pad with empty chunks
    final int shortage = numChunks - chunks.size();
    final List<List<Map.Entry<Symbol, File>>> padding = Collections.nCopies(shortage, emptyChunk);
    return Iterables.concat(chunks, padding);
  }
}
 
開發者ID:BBN-E,項目名稱:bue-common-open,代碼行數:26,代碼來源:SplitCorpus.java

示例3: paintComponent

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Override
protected void paintComponent(Graphics g1)
{
	super.paintComponent(g1);
	Graphics2D g = (Graphics2D)g1;
	
	int cellsX = IntMath.divide(getWidth(), tileModel.getAvgTileWidth(), RoundingMode.UP);
	int cellsY = IntMath.divide(getHeight(), tileModel.getTileHeight(), RoundingMode.UP);
	tileModel.setMapWidth(cellsX);
	tileModel.setMapHeight(cellsY);
	
	// cut of partly draw hexagons
	g.clipRect(0, 0, tileModel.getWorldWidth(), tileModel.getWorldHeight());

	drawTiles(g);

	Object oldAAhint = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	drawVectorField(g);
	drawSelection(g);

	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAAhint);

	g1.setClip(null);
}
 
開發者ID:igd-iva,項目名稱:colormap-explorer,代碼行數:27,代碼來源:DecomposedPanel.java

示例4: getTilesInRect

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Override
public List<Tile> getTilesInRect(int worldX0, int worldY0, int worldX1, int worldY1)
{
	int x0 = IntMath.divide(worldX0, tileWidth, RoundingMode.FLOOR);
	int y0 = IntMath.divide(worldY0, tileHeight, RoundingMode.FLOOR);
	int x1 = IntMath.divide(worldX1, tileWidth, RoundingMode.FLOOR);
	int y1 = IntMath.divide(worldY1, tileHeight, RoundingMode.FLOOR);
	
	// Restrict to map bounds
	int minX = Math.max(x0, 0);
	int maxX = Math.min(x1, mapWidth - 1);
	int minY = Math.max(y0, 0);
	int maxY = Math.min(y1, mapHeight - 1);

	List<Tile> result = new ArrayList<Tile>();

	for (int y = minY; y <= maxY; y++)
	{
		for (int x = minX; y <= maxX; x++)
		{
			result.add(getTile(x, y));
		}
	}

	return result;
}
 
開發者ID:igd-iva,項目名稱:colormap-explorer,代碼行數:27,代碼來源:RectTileModel.java

示例5: getNation

import com.google.common.math.IntMath; //導入方法依賴的package包/類
public static Nation getNation(Location<World> loc)
	{
		if (!worldChunks.containsKey(loc.getExtent().getUniqueId()))
		{
			return null;
		}
		Vector2i area = new Vector2i(IntMath.divide(loc.getBlockX(), 16, RoundingMode.FLOOR), IntMath.divide(loc.getBlockZ(), 16, RoundingMode.FLOOR));
		if (!worldChunks.get(loc.getExtent().getUniqueId()).containsKey(area))
		{
			return null;
		}
		for (Nation nation : worldChunks.get(loc.getExtent().getUniqueId()).get(area))
		{
			if (nation.getRegion().isInside(loc))
			{
				return nation;
			}
		}
//		for (Entry<Vector2i, ArrayList<Nation>> e : worldChunks.get(loc.getExtent().getUniqueId()).entrySet())
//		{
//			if (e.getKey().equals(new Vector2i(IntMath.divide(loc.getBlockX(), 16, RoundingMode.FLOOR), IntMath.divide(loc.getBlockZ(), 16, RoundingMode.FLOOR))))
//			{
//				for (Nation nation : e.getValue())
//				{
//					if (nation.getRegion().isInside(loc))
//					{
//						return nation;
//					}
//				}
//				return null;
//			}
//		}
		return null;
	}
 
開發者ID:Arckenver,項目名稱:Nations,代碼行數:35,代碼來源:DataHandler.java

示例6: divide

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

示例7: DefaultPageImpl

import com.google.common.math.IntMath; //導入方法依賴的package包/類
public DefaultPageImpl(List<T> results, int page, int size) {
	this.perPage = size;
	this.page = page;
	this.totalResults = results.size();
	this.totalPages = perPage > 0 ? IntMath.divide(totalResults, perPage, RoundingMode.CEILING) : 0;
	this.results = results;
}
 
開發者ID:RBGKew,項目名稱:powop,代碼行數:8,代碼來源:DefaultPageImpl.java

示例8: Partition

import com.google.common.math.IntMath; //導入方法依賴的package包/類
public Partition(Collection<T> allItems, Comparator<T> comparator, int itemsPerPartition, int currentPartition) {
    this.itemsPerPartition = itemsPerPartition;
    this.numPartitions = IntMath.divide(allItems.size(), itemsPerPartition, RoundingMode.CEILING);
    this.currentPartitionNumber = Math.min(this.numPartitions, Math.max(1, currentPartition));
    this.partitionItems = allItems.stream().sorted(comparator)
                    .skip((currentPartition - 1) * itemsPerPartition).limit(itemsPerPartition).collect(toList());
}
 
開發者ID:FenixEdu,項目名稱:fenixedu-cms,代碼行數:8,代碼來源:SearchUtils.java

示例9: getTileAtWorldPos

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Override
public Optional<Tile> getTileAtWorldPos(int worldX, int worldY)
{
	int x = IntMath.divide(worldX, tileWidth, RoundingMode.FLOOR);
	int y = IntMath.divide(worldY, tileHeight, RoundingMode.FLOOR);
	
	if (x >= 0 && x < mapWidth && y >= 0 && y < mapHeight)
	{
		return Optional.of(getTile(x, y));
	}
	
	return Optional.absent();
}
 
開發者ID:igd-iva,項目名稱:colormap-explorer,代碼行數:14,代碼來源:RectTileModel.java

示例10: AlternativeProvider

import com.google.common.math.IntMath; //導入方法依賴的package包/類
AlternativeProvider(List<MediaType> mediaTypes, List<CharacterEncoding> characterEncodings, List<Language> languages) {
	this.mediaTypes=EntityProvider.of(mediaTypes);
	this.characterEncodings=EntityProvider.of(characterEncodings);
	this.languages=EntityProvider.of(languages);
	this.size=
		this.mediaTypes.consumableEntities()*
		this.characterEncodings.consumableEntities()*
		this.languages.consumableEntities();
	this.position=0;
	this.buckets=IntMath.divide(this.size,MAX_BUCKETS,RoundingMode.CEILING);
}
 
開發者ID:ldp4j,項目名稱:ldp4j,代碼行數:12,代碼來源:AlternativeProvider.java

示例11: size

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Override
public int size() {
  return IntMath.divide(list.size(), size, RoundingMode.CEILING);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:5,代碼來源:Lists.java

示例12: size

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Override public int size() {
  return IntMath.divide(list.size(), size, RoundingMode.CEILING);
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:4,代碼來源:Lists.java

示例13: base64MaxSize

import com.google.common.math.IntMath; //導入方法依賴的package包/類
private static int base64MaxSize(long n) {
  return 4 * IntMath.divide((int) n, 3, CEILING);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:4,代碼來源:RestApiServlet.java

示例14: AbstractTftpReadTransfer

import com.google.common.math.IntMath; //導入方法依賴的package包/類
public AbstractTftpReadTransfer(@Nonnull SocketAddress remoteAddress, @Nonnull TftpData source, @Nonnegative int blockSize) throws IOException {
    super(remoteAddress);
    this.source = source;
    this.blockSize = blockSize;
    this.blockCount = IntMath.divide(source.getSize() + 1, blockSize, RoundingMode.CEILING);
}
 
開發者ID:shevek,項目名稱:tftp4j,代碼行數:7,代碼來源:AbstractTftpReadTransfer.java

示例15: getEncodedLength

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Override
public int getEncodedLength(String in) {
    return IntMath.divide(in.length(), 2, RoundingMode.CEILING);
}
 
開發者ID:shevek,項目名稱:ipmi4j,代碼行數:5,代碼來源:SDRFieldCodec.java


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