当前位置: 首页>>代码示例>>Java>>正文


Java IntBuffer.limit方法代码示例

本文整理汇总了Java中java.nio.IntBuffer.limit方法的典型用法代码示例。如果您正苦于以下问题:Java IntBuffer.limit方法的具体用法?Java IntBuffer.limit怎么用?Java IntBuffer.limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.IntBuffer的用法示例。


在下文中一共展示了IntBuffer.limit方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateData

import java.nio.IntBuffer; //导入方法依赖的package包/类
public VBO updateData(IntBuffer buffer, long offset)
{
	if (this.type != GL11.GL_UNSIGNED_INT)
	{
		throw new IllegalArgumentException("Cannot store mismatching type in buffer!");
	}

	if (offset + buffer.limit() > this.length)
	{
		int usage = GL15.glGetBufferParameteri(this.target, GL15.GL_BUFFER_USAGE);
		this.putData(buffer, this.normalized, usage);
	}

	GL15.glBindBuffer(this.target, this.handle);
	GL15.glBufferSubData(this.target, offset, buffer);

	return this;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:19,代码来源:VBO.java

示例2: testIntGet

import java.nio.IntBuffer; //导入方法依赖的package包/类
@Test(dataProvider = "intViewProvider")
public void testIntGet(String desc, IntFunction<ByteBuffer> fbb,
                       Function<ByteBuffer, IntBuffer> fbi) {
    ByteBuffer bb = allocate(fbb);
    IntBuffer vb = fbi.apply(bb);
    int o = bb.position();

    for (int i = 0; i < vb.limit(); i++) {
        int fromBytes = getIntFromBytes(bb, o + i * 4);
        int fromMethodView = bb.getInt(o + i * 4);
        assertValues(i, fromBytes, fromMethodView, bb);

        int fromBufferView = vb.get(i);
        assertValues(i, fromMethodView, fromBufferView, bb, vb);
    }

    for (int i = 0; i < vb.limit(); i++) {
        int v = getIntFromBytes(bb, o + i * 4);
        int a = bb.getInt();
        assertValues(i, v, a, bb);

        int b = vb.get();
        assertValues(i, a, b, bb, vb);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ByteBufferViews.java

示例3: ensureLargeEnough

import java.nio.IntBuffer; //导入方法依赖的package包/类
public static IntBuffer ensureLargeEnough(IntBuffer buffer, int required) {
    if (buffer != null) {
        buffer.limit(buffer.capacity());
    }
    if (buffer == null || (buffer.remaining() < required)) {
        int position = (buffer != null ? buffer.position() : 0);
        IntBuffer newVerts = createIntBuffer(position + required);
        if (buffer != null) {
            buffer.flip();
            newVerts.put(buffer);
            newVerts.position(position);
        }
        buffer = newVerts;
    }
    return buffer;
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:17,代码来源:BufferUtils.java

示例4: printIntBuffer

import java.nio.IntBuffer; //导入方法依赖的package包/类
public static void printIntBuffer(String title, IntBuffer buf)
{
    StringBuilder stringbuilder = new StringBuilder(128);
    stringbuilder.append(title).append(" [pos ").append(buf.position()).append(" lim ").append(buf.limit()).append(" cap ").append(buf.capacity()).append(" :");
    int i = buf.limit();

    for (int j = 0; j < i; ++j)
    {
        stringbuilder.append(" ").append(buf.get(j));
    }

    stringbuilder.append("]");
    SMCLog.info(stringbuilder.toString());
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:15,代码来源:Shaders.java

示例5: fillIntBufferZero

import java.nio.IntBuffer; //导入方法依赖的package包/类
private static IntBuffer fillIntBufferZero(IntBuffer buf)
{
    int i = buf.limit();

    for (int j = buf.position(); j < i; ++j)
    {
        buf.put(j, 0);
    }

    return buf;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:12,代码来源:Shaders.java

示例6: deleteTextures

import java.nio.IntBuffer; //导入方法依赖的package包/类
public static void deleteTextures(IntBuffer p_deleteTextures_0_)
{
    p_deleteTextures_0_.rewind();

    while (p_deleteTextures_0_.position() < p_deleteTextures_0_.limit())
    {
        int i = p_deleteTextures_0_.get();
        deleteTexture(i);
    }

    p_deleteTextures_0_.rewind();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:13,代码来源:GlStateManager.java

示例7: putData

import java.nio.IntBuffer; //导入方法依赖的package包/类
public VBO putData(IntBuffer buffer, boolean normalized, int usage)
{
	GL15.glBindBuffer(this.target, this.handle);
	GL15.glBufferData(this.target, buffer, usage);
	this.type = GL11.GL_UNSIGNED_INT;
	this.normalized = normalized;
	this.length = buffer.limit();

	return this;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:11,代码来源:VBO.java

示例8: majorVersionBuffer

import java.nio.IntBuffer; //导入方法依赖的package包/类
/**
 * Return an IntBuffer that accesses the major version number.
 * This is used to create a Monitor object for this value.
 *
 * @return IntBuffer - a ByteBuffer that accesses the major version number
 *                     in the instrumentation buffer header.
 */
public IntBuffer majorVersionBuffer() {
    int[] holder = new int[1];
    holder[0] = getMajorVersion();
    IntBuffer ib = IntBuffer.wrap(holder);
    ib.limit(1);
    return ib;
  }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:AbstractPerfDataBufferPrologue.java

示例9: minorVersionBuffer

import java.nio.IntBuffer; //导入方法依赖的package包/类
/**
 * Return an IntBuffer that accesses the minor version number.
 * This is used to create a Monitor object for this value.
 *
 * @return IntBuffer - a ByteBuffer that accesses the minor version number
 *                     in the instrumentation buffer header.
 */
public IntBuffer minorVersionBuffer() {
    int[] holder = new int[1];
    holder[0] = getMinorVersion();
    IntBuffer ib = IntBuffer.wrap(holder);
    ib.limit(1);
    return ib;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:AbstractPerfDataBufferPrologue.java

示例10: getIntArray

import java.nio.IntBuffer; //导入方法依赖的package包/类
/**
 * Create a new int[] array and populate it with the given IntBuffer's
 * contents.
 * 
 * @param buff
 *            the IntBuffer to read from
 * @return a new int array populated from the IntBuffer
 */
public static int[] getIntArray(IntBuffer buff) {
    if (buff == null) {
        return null;
    }
    buff.clear();
    int[] inds = new int[buff.limit()];
    for (int x = 0; x < inds.length; x++) {
        inds[x] = buff.get();
    }
    return inds;
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:20,代码来源:BufferUtils.java

示例11: shortenPathComponent

import java.nio.IntBuffer; //导入方法依赖的package包/类
/**
 * Shortens an individual file/directory name, removing the necessary number of code points
 * from the middle of the string such that the utf-8 encoding of the string is at least
 * bytesToRemove bytes shorter than the original.
 *
 * The removed codePoints in the middle of the string will be replaced with a # character.
 */
@Nonnull
static String shortenPathComponent(@Nonnull String pathComponent, int bytesToRemove) {
    // We replace the removed part with a #, so we need to remove 1 extra char
    bytesToRemove++;

    int[] codePoints;
    try {
        IntBuffer intBuffer = ByteBuffer.wrap(pathComponent.getBytes("UTF-32BE")).asIntBuffer();
        codePoints = new int[intBuffer.limit()];
        intBuffer.get(codePoints);
    } catch (UnsupportedEncodingException ex) {
        throw new RuntimeException(ex);
    }

    int midPoint = codePoints.length/2;

    int firstEnd = midPoint; // exclusive
    int secondStart = midPoint+1; // inclusive
    int bytesRemoved = utf8Length(codePoints[midPoint]);

    // if we have an even number of codepoints, start by removing both middle characters,
    // unless just removing the first already removes enough bytes
    if (((codePoints.length % 2) == 0) && bytesRemoved < bytesToRemove) {
        bytesRemoved += utf8Length(codePoints[secondStart]);
        secondStart++;
    }

    while ((bytesRemoved < bytesToRemove) &&
            (firstEnd > 0 || secondStart < codePoints.length)) {
        if (firstEnd > 0) {
            firstEnd--;
            bytesRemoved += utf8Length(codePoints[firstEnd]);
        }

        if (bytesRemoved < bytesToRemove && secondStart < codePoints.length) {
            bytesRemoved += utf8Length(codePoints[secondStart]);
            secondStart++;
        }
    }

    StringBuilder sb = new StringBuilder();
    for (int i=0; i<firstEnd; i++) {
        sb.appendCodePoint(codePoints[i]);
    }
    sb.append('#');
    for (int i=secondStart; i<codePoints.length; i++) {
        sb.appendCodePoint(codePoints[i]);
    }

    return sb.toString();
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:59,代码来源:ClassFileNameHandler.java

示例12: createIntBuffer

import java.nio.IntBuffer; //导入方法依赖的package包/类
/**
 * Create a new IntBuffer of an appropriate size to hold the specified
 * number of ints only if the given buffer if not already the right size.
 * 
 * @param buf
 *            the buffer to first check and rewind
 * @param size
 *            number of ints that need to be held by the newly created
 *            buffer
 * @return the requested new IntBuffer
 */
public static IntBuffer createIntBuffer(IntBuffer buf, int size) {
    if (buf != null && buf.limit() == size) {
        buf.rewind();
        return buf;
    }

    buf = createIntBuffer(size);
    return buf;
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:21,代码来源:BufferUtils.java


注:本文中的java.nio.IntBuffer.limit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。