zoukankan      html  css  js  c++  java
  • 演示缓冲区的操作流程

    import java.nio.IntBuffer;

    public class IntBufferDemo01 {
        public static void main(String[] args) {
            IntBuffer buf = IntBuffer.allocate(10);
            System.out.print("The position,limit and capacity before input data:");
            System.out.println("position=" + buf.position() + ",limit="
                    + buf.limit() + ",capacity=" + buf.capacity());
            int temp[] = { 3, 4, 5 };
            buf.put(3);
            buf.put(temp);
            System.out.print("The position,limit and capacity after input data:");
            System.out.println("position=" + buf.position() + ",limit="
                    + buf.limit() + ",capacity=" + buf.capacity());
            buf.flip();
            System.out.print("The position,limit and capacity when outputing:");
            System.out.println("positon=" + buf.position() + ",limt=" + buf.limit()
                    + ",capacity=" + buf.capacity());
            System.out.print("The content in buffer:");
            while (buf.hasRemaining()) {
                int x = buf.get();
                System.out.print(x + ",");
            }
        }
    }

    The output:

    The position,limit and capacity before input data:position=0,limit=10,capacity=10
    The position,limit and capacity after input data:position=4,limit=10,capacity=10
    The position,limit and capacity when outputing:positon=0,limt=4,capacity=10
    The content in buffer:3,3,4,5,

  • 相关阅读:
    预编译命令 #if DEBUG
    conda常用命令
    tensorflow 安装指南
    LocNET和池化理解
    同时安装cuda8和cuda9
    np.transpose
    python中List的slice用法
    书单
    训练工程
    linux 查看进程
  • 原文地址:https://www.cnblogs.com/vonk/p/3961440.html
Copyright © 2011-2022 走看看