java.nio.Buffer#capacity ( )源码实例Demo

下面列出了java.nio.Buffer#capacity ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码2 项目: TencentKona-8   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码3 项目: jmonkeyengine   文件: GLTracer.java
private void printBuffer(Buffer buffer) {
    StringBuilder sb = new StringBuilder();
    sb.append(ANSI_MAGENTA);
    if (buffer instanceof ByteBuffer) {
        sb.append("byte");
    } else if (buffer instanceof ShortBuffer) {
        sb.append("short");
    } else if (buffer instanceof CharBuffer) { 
        sb.append("char");
    } else if (buffer instanceof FloatBuffer) {
        sb.append("float");
    } else if (buffer instanceof IntBuffer) {
        sb.append("int");
    } else if (buffer instanceof LongBuffer) {
        sb.append("long");
    } else if (buffer instanceof DoubleBuffer) {
        sb.append("double");
    } else {
        throw new UnsupportedOperationException();
    }
    sb.append(ANSI_RESET);
    sb.append("[");
    
    if (buffer.position() == 0
            && buffer.limit() == buffer.capacity()) {
        // Common case. Just print buffer size.
        sb.append(buffer.capacity());
    } else {
        sb.append("pos=").append(buffer.position());
        sb.append(" lim=").append(buffer.limit());
        sb.append(" cap=").append(buffer.capacity());
    }
    
    sb.append("]");
    print(sb.toString());
}
 
源代码4 项目: jdk8u60   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码5 项目: aion-germany   文件: VertexBuffer.java
public void updateData(Buffer data) {
	if (id != -1) {
		// request to update data is okay
	}

	// will force renderer to call glBufferData again
	if (this.data.capacity() != data.capacity()) {
		dataSizeChanged = true;
	}
	this.data = data;
	setUpdateNeeded();
}
 
源代码6 项目: sis   文件: ByteWriter.java
/**
 * Creates a new writer for copying bytes from the given source to the given target buffers.
 * Data will be read from the current position of source buffer up to that buffer <em>limit</em>.
 * Data will be written starting at position 0 of target buffer up to that buffer <em>capacity</em>.
 * The position and limit of target buffer are ignored.
 * The position and limit of both buffers may be modified by this method.
 *
 * @param  source  the buffer from which to copy data.
 * @param  target  the buffer where to copy data.
 * @return a writer from given source to target.
 */
public static ByteWriter create(Buffer source, final ByteBuffer target) {
    if (source.limit() != source.capacity()) {
        source = JDK9.slice(source);
    }
    if (source instanceof DoubleBuffer) return new Doubles ((DoubleBuffer) source, target);
    if (source instanceof  FloatBuffer) return new Floats  ( (FloatBuffer) source, target);
    if (source instanceof   LongBuffer) return new Longs   (  (LongBuffer) source, target);
    if (source instanceof    IntBuffer) return new Integers(   (IntBuffer) source, target);
    if (source instanceof  ShortBuffer) return new Shorts  ( (ShortBuffer) source, target);
    if (source instanceof   ByteBuffer) return new Bytes   (  (ByteBuffer) source, target);
    throw new IllegalArgumentException();
}
 
源代码7 项目: openjdk-jdk9   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码8 项目: jdk8u-jdk   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码9 项目: hottub   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码10 项目: openjdk-8-source   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码11 项目: SnowGraph   文件: MboxIterator.java
/**
 * Utility method to log important details about buffers.
 */
public static String bufferDetailsToString(final Buffer buffer) {
    return "Buffer details: " + "\ncapacity:\t" + buffer.capacity() +
            "\nlimit:\t" + buffer.limit() +
            "\nremaining:\t" + buffer.remaining() +
            "\nposition:\t" + buffer.position() +
            "\nbuffer:\t" + buffer.isReadOnly() +
            "\nclass:\t" + buffer.getClass();
}
 
源代码12 项目: openjdk-8   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码13 项目: tapir   文件: Pointer.java
/**
 * Copies the address, position, limit, and capacity of a direct NIO {@link Buffer}.
 * Also keeps a reference to it to prevent its memory from getting deallocated.
 *
 * @param b the Buffer object to reference
 */
public Pointer(final Buffer b) {
    if (b != null) {
        allocate(b);
    }
    if (!isNull()) {
        position = b.position();
        limit = b.limit();
        capacity = b.capacity();
        deallocator = new Deallocator() { Buffer bb = b; public void deallocate() { bb = null; } };
    }
}
 
源代码14 项目: jdk8u_jdk   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码15 项目: jdk8u-dev-jdk   文件: Basic.java
static String toString(Buffer b) {
    return (b.getClass().getName()
            + "[pos=" + b.position()
            + " lim=" + b.limit()
            + " cap=" + b.capacity()
            + "]");
}
 
源代码16 项目: MikuMikuStudio   文件: BufferUtils.java
public static void printCurrentDirectMemory(StringBuilder store) {
    long totalHeld = 0;
    // make a new set to hold the keys to prevent concurrency issues.
    ArrayList<Buffer> bufs = new ArrayList<Buffer>(trackingHash.keySet());
    int fBufs = 0, bBufs = 0, iBufs = 0, sBufs = 0, dBufs = 0;
    int fBufsM = 0, bBufsM = 0, iBufsM = 0, sBufsM = 0, dBufsM = 0;
    for (Buffer b : bufs) {
        if (b instanceof ByteBuffer) {
            totalHeld += b.capacity();
            bBufsM += b.capacity();
            bBufs++;
        } else if (b instanceof FloatBuffer) {
            totalHeld += b.capacity() * 4;
            fBufsM += b.capacity() * 4;
            fBufs++;
        } else if (b instanceof IntBuffer) {
            totalHeld += b.capacity() * 4;
            iBufsM += b.capacity() * 4;
            iBufs++;
        } else if (b instanceof ShortBuffer) {
            totalHeld += b.capacity() * 2;
            sBufsM += b.capacity() * 2;
            sBufs++;
        } else if (b instanceof DoubleBuffer) {
            totalHeld += b.capacity() * 8;
            dBufsM += b.capacity() * 8;
            dBufs++;
        }
    }
    long heapMem = Runtime.getRuntime().totalMemory()
            - Runtime.getRuntime().freeMemory();

    boolean printStout = store == null;
    if (store == null) {
        store = new StringBuilder();
    }
    store.append("Existing buffers: ").append(bufs.size()).append("\n");
    store.append("(b: ").append(bBufs).append("  f: ").append(fBufs).append("  i: ").append(iBufs).append("  s: ").append(sBufs).append("  d: ").append(dBufs).append(")").append("\n");
    store.append("Total   heap memory held: ").append(heapMem / 1024).append("kb\n");
    store.append("Total direct memory held: ").append(totalHeld / 1024).append("kb\n");
    store.append("(b: ").append(bBufsM / 1024).append("kb  f: ").append(fBufsM / 1024).append("kb  i: ").append(iBufsM / 1024).append("kb  s: ").append(sBufsM / 1024).append("kb  d: ").append(dBufsM / 1024).append("kb)").append("\n");
    if (printStout) {
        System.out.println(store.toString());
    }
}
 
源代码17 项目: codebuff   文件: ReaderInputStream.java
/** Returns the number of elements between the limit and capacity. */

  private static int availableCapacity(Buffer buffer) {
    return buffer.capacity() - buffer.limit();
  }
 
源代码18 项目: codebuff   文件: ReaderInputStream.java
/** Returns the number of elements between the limit and capacity. */

  private static int availableCapacity(Buffer buffer) {
    return buffer.capacity() - buffer.limit();
  }
 
源代码19 项目: FastBootWeixin   文件: ReaderInputStream.java
/**
 * Returns the number of elements between the limit and capacity.
 */
private static int availableCapacity(Buffer buffer) {
    return buffer.capacity() - buffer.limit();
}
 
源代码20 项目: codebuff   文件: ReaderInputStream.java
/** Returns the number of elements between the limit and capacity. */

  private static int availableCapacity(Buffer buffer) {
    return buffer.capacity() - buffer.limit();
  }