我用我Android代码中的浮控缓冲器已经使用了一段时间了(从一些开阔角度的教义中读取),但我无法确切理解这个构造是什么,为什么需要它。
例如,我在许多民族中看到这种守则(或类似的守则)以及机器人教义:
float[] vertices = ...some array...
ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4);
vbb.order(ByteOrder.nativeOrder()); // use the device hardware s native byte order
FloatBuffer fb = vbb.asFloatBuffer(); // create a floating point buffer from the ByteBuffer
fb.put(vertices); // add the coordinates to the FloatBuffer
fb.position(0); // set the buffer to read the first coordinate
这似乎非常多变和乱七八糟 对于某事,据我所知,这只是一个花哨包装 围绕一系列浮标。
问题:
这种类别(ByteBuffer、Floatbuffer)相对于任何其他种类的集合或简单的浮标阵列而言,其理由何在?
将字节布弗转换成花节布弗之前 创建字节布弗有什么想法?