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


Java IntBuffer.capacity方法代碼示例

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


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

示例1: densePlusSparse

import java.nio.IntBuffer; //導入方法依賴的package包/類
private void densePlusSparse(IntBuffer keys, IntBuffer values) {
  int length = keys.capacity();
  int ov, value, key;
  for (int i = 0; i < length; i++) {
    key = keys.get(i);
    ov = denseRep.get(key);
    value = ov + values.get(i);
    if (ov != 0 && value == 0)
      nnz--;
    denseRep.put(key, value);
  }

  int size = (int)(endCol - startCol);
  if (nnz < threshold * size)
    denseToSparse();
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:17,代碼來源:ServerArbitraryIntRow.java

示例2: readFrom

import java.nio.IntBuffer; //導入方法依賴的package包/類
static ImageHeader readFrom(IntBuffer buffer) {
    Objects.requireNonNull(buffer);

    if (buffer.capacity() != HEADER_SLOTS) {
        throw new InternalError(
            "jimage header not the correct size: " + buffer.capacity());
    }

    int magic = buffer.get(0);
    int version = buffer.get(1);
    int majorVersion = version >>> 16;
    int minorVersion = version & 0xFFFF;
    int flags = buffer.get(2);
    int resourceCount = buffer.get(3);
    int tableLength = buffer.get(4);
    int locationsSize = buffer.get(5);
    int stringsSize = buffer.get(6);

    return new ImageHeader(magic, majorVersion, minorVersion, flags,
        resourceCount, tableLength, locationsSize, stringsSize);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:ImageHeader.java

示例3: loadInMemoryStorage

import java.nio.IntBuffer; //導入方法依賴的package包/類
@Override
public void loadInMemoryStorage( final ColumnBinary columnBinary , final IMemoryAllocator allocator ) throws IOException{
  for( ColumnBinary childColumnBinary : columnBinary.columnBinaryList ){
    IColumnBinaryMaker maker = FindColumnBinaryMaker.get( childColumnBinary.makerClassName );
    IMemoryAllocator childMemoryAllocator = allocator.getArrayChild( childColumnBinary.rowCount , childColumnBinary.columnType );
    maker.loadInMemoryStorage( childColumnBinary , childMemoryAllocator );
  }

  ICompressor compressor = FindCompressor.get( columnBinary.compressorClassName );
  byte[] decompressBuffer = compressor.decompress( columnBinary.binary , columnBinary.binaryStart , columnBinary.binaryLength );

  IntBuffer buffer = ByteBuffer.wrap( decompressBuffer ).asIntBuffer();
  int length = buffer.capacity();
  int currentIndex = 0;
  for( int i = 0 ; i < length ; i++ ){
    int arrayLength = buffer.get();
    if( arrayLength == 0 ){
      allocator.setNull(i);
    }
    else{
      int start = currentIndex;
      allocator.setArrayIndex( i , start , arrayLength );
      currentIndex += arrayLength;
    }
  }
  allocator.setValueCount( length );
}
 
開發者ID:yahoojapan,項目名稱:multiple-dimension-spread,代碼行數:28,代碼來源:DumpArrayColumnBinaryMaker.java

示例4: ArrayCellManager

import java.nio.IntBuffer; //導入方法依賴的package包/類
public ArrayCellManager( final Spread spread , final IntBuffer buffer ){
  int length = buffer.capacity();
  cellArray = new ICell[length];
  int currentIndex = 0;
  for( int i = 0 ; i < length ; i++ ){
    int arrayLength = buffer.get();
    if( arrayLength != 0 ){
      int start = currentIndex;
      int end = start + arrayLength;
      cellArray[i] = new ArrayCell( new SpreadArrayLink( spread , i , start , end ) );
      currentIndex += arrayLength;
    }
  }
}
 
開發者ID:yahoojapan,項目名稱:multiple-dimension-spread,代碼行數:15,代碼來源:DumpArrayColumnBinaryMaker.java

示例5: densePlusDense

import java.nio.IntBuffer; //導入方法依賴的package包/類
private void densePlusDense(IntBuffer buf) {
  int length = buf.capacity();
  nnz = 0;
  int value;
  for (int i = 0; i < length; i++) {
    value = denseRep.get(i) + buf.get(i);
    if (value != 0) {
      denseRep.put(i, denseRep.get(i) + buf.get(i));
      nnz++;
    }
  }

  if (nnz < threshold)
    denseToSparse();
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:16,代碼來源:ServerArbitraryIntRow.java

示例6: bufToIntegerString

import java.nio.IntBuffer; //導入方法依賴的package包/類
protected String bufToIntegerString(IntBuffer buf) {
	String str = "";
	for (int i = 0; i < buf.capacity(); i++) {
		str += buf.get(i);
	}

	return str.replaceFirst("[^1-9]*", "");
}
 
開發者ID:Jim00000,項目名稱:Big-Number-Calculation,代碼行數:9,代碼來源:Add.java

示例7: getInt

import java.nio.IntBuffer; //導入方法依賴的package包/類
public int[] getInt(Attribute attrib) {
	int pname = getAttrib(attrib);
	IntBuffer buf = ByteBuffer.allocateDirect(16).order(ByteOrder.nativeOrder()).asIntBuffer();
	gl.glGetIntegerv(pname, buf);

	int[] result = new int[buf.capacity()];
	for(int i = 0; i < result.length; i++)
		result[i] = buf.get();

	return result;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:12,代碼來源:JOGLOpenGL.java

示例8: AddVertices

import java.nio.IntBuffer; //導入方法依賴的package包/類
public void AddVertices(FloatBuffer vertices, IntBuffer indices)
{
	shader = new Shader("forward-ambient2");
	material = new Material(new Texture("bricks.jpg"), 1, 8,
			new Texture("bricks_normal.jpg"), new Texture("bricks_disp.png"), 0.03f, -0.5f);
	
	resource = new MeshResource(indices.capacity());
	
	glBindBuffer(GL_ARRAY_BUFFER, resource.GetVbo());
	glBufferData(GL_ARRAY_BUFFER, vertices, GL_STATIC_DRAW);
	
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, resource.GetIbo());
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices, GL_STATIC_DRAW);
}
 
開發者ID:RagnarrIvarssen,項目名稱:Assimp-Tutorial-LWJGL-3,代碼行數:15,代碼來源:AnimatedComponent.java

示例9: BufferDirectDictionaryLinkCellManager

import java.nio.IntBuffer; //導入方法依賴的package包/類
public BufferDirectDictionaryLinkCellManager( final ColumnType columnType , final IDicManager dicManager , final IntBuffer dicIndexIntBuffer ){
  this.columnType = columnType;
  this.dicManager = dicManager;
  this.dicIndexIntBuffer = dicIndexIntBuffer;
  indexSize = dicIndexIntBuffer.capacity();
}
 
開發者ID:yahoojapan,項目名稱:multiple-dimension-spread,代碼行數:7,代碼來源:BufferDirectDictionaryLinkCellManager.java


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