Package gov.nasa.worldwind.util
Class VecBufferBlocks
- java.lang.Object
-
- gov.nasa.worldwind.util.CompoundVecBuffer
-
- gov.nasa.worldwind.util.VecBufferBlocks
-
public class VecBufferBlocks extends CompoundVecBuffer
VecBufferBlocks provides storage and retrieval of a set of potentially random VecBuffer blocks in a single backing ByteBuffer. Its is assumeed that the backing ByteBuffer already contains the necessary data, and the caller defines which regions in the ByteBuffer define each individual VecBuffer. VecBuffers are defined by callingaddBlock(int, int)
, where the positions define the byte range containing a VecBuffer's data.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class gov.nasa.worldwind.util.CompoundVecBuffer
CompoundVecBuffer.CompoundIterator<T>, CompoundVecBuffer.CoordIterable, CompoundVecBuffer.EmptyCompoundVecBuffer, CompoundVecBuffer.LocationIterable, CompoundVecBuffer.PositionIterable, CompoundVecBuffer.ReverseCompoundIterator<T>, CompoundVecBuffer.SubBufferIterable<T>, CompoundVecBuffer.VectorIterable
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.ByteBuffer
buffer
protected int
coordsPerVec
protected java.lang.String
dataType
-
Fields inherited from class gov.nasa.worldwind.util.CompoundVecBuffer
ALLOCATE_DIRECT_BUFFERS, capacity, count, DEFAULT_INITIAL_CAPACITY, lengths, offsets
-
-
Constructor Summary
Constructors Modifier Constructor Description VecBufferBlocks(int coordsPerVec, java.lang.String dataType, java.nio.ByteBuffer buffer)
Constructs a VecBufferBlocks with the specified number of coordinates per logical vector, primitive data type, and backing ByteBuffer.VecBufferBlocks(int coordsPerVec, java.lang.String dataType, java.nio.ByteBuffer buffer, int capacity)
Constructs a VecBufferBlocks with the specified number of coordinates per logical vector, primitive data type, backing ByteBuffer and the specified initial capacity.protected
VecBufferBlocks(VecBufferBlocks that, int[] indices, int offset, int length)
protected
VecBufferBlocks(VecBufferBlocks that, int beginIndex, int endIndex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addBlock(int beginPos, int endPos)
Adds a range of bytes that define a new sub-buffer within this VecBufferBlocks.protected CompoundVecBuffer
createSlice(int[] indices, int offset, int length)
protected CompoundVecBuffer
createSlice(int beginIndex, int endIndex)
protected VecBuffer
createSubBuffer(int offsetInBytes, int lengthInBytes)
java.nio.ByteBuffer
getBuffer()
Returns the ByteBuffer that stores this VecBufferBlocks' sub-buffers.int
getCoordsPerVec()
Returns the number of coordinates per logical vector element.java.lang.String
getDataType()
Returns the primitive data type used to interpret the elements of this VecBufferBlocks' backing ByteBuffer.int
subBufferSize(int index)
Returns the size in logical vectors of the VecBuffer with the specified index.-
Methods inherited from class gov.nasa.worldwind.util.CompoundVecBuffer
addSubBuffer, clear, emptyCompoundVecBuffer, expandCapacity, getCoords, getCoords, getLocations, getPositions, getReverseCoords, getReverseLocations, getReversePositions, getReverseVectors, getVectors, size, slice, slice, slice, subBuffer
-
-
-
-
Constructor Detail
-
VecBufferBlocks
public VecBufferBlocks(int coordsPerVec, java.lang.String dataType, java.nio.ByteBuffer buffer, int capacity)
Constructs a VecBufferBlocks with the specified number of coordinates per logical vector, primitive data type, backing ByteBuffer and the specified initial capacity. This interprets the ByteBuffer according to the specified primitive data type and number of coordinates per logical vector, and does not modify the ByteBuffer in any way. This assumes the buffer's position and limit are not changed by the caller for the lifetime of this instance.- Parameters:
coordsPerVec
- the number of coordinates per logical vector.dataType
- the primitive data type.buffer
- the backing ByteBuffer.capacity
- the PackedCompoundVecBuffer's initial capacity, in number of sub-buffers.- Throws:
java.lang.IllegalArgumentException
- if the coordsPerVec is less than 1, if the dataType is null, if the buffer is null, or if the capacity is less than 1.
-
VecBufferBlocks
public VecBufferBlocks(int coordsPerVec, java.lang.String dataType, java.nio.ByteBuffer buffer)
Constructs a VecBufferBlocks with the specified number of coordinates per logical vector, primitive data type, and backing ByteBuffer. This interprets the ByteBuffer according to the specified primitive data type and number of coordinates per logical vector, and does not modify the ByteBuffer in any way. This assumes the buffer's position and limit are not changed by the caller for the lifetime of this instance.- Parameters:
coordsPerVec
- the number of coordinates per logical vector.dataType
- the primitive data type.buffer
- the backing ByteBuffer.- Throws:
java.lang.IllegalArgumentException
- if the coordsPerVec is less than 1, if the dataType is null, or if the buffer is null.
-
VecBufferBlocks
protected VecBufferBlocks(VecBufferBlocks that, int beginIndex, int endIndex)
-
VecBufferBlocks
protected VecBufferBlocks(VecBufferBlocks that, int[] indices, int offset, int length)
-
-
Method Detail
-
subBufferSize
public int subBufferSize(int index)
Returns the size in logical vectors of the VecBuffer with the specified index.- Specified by:
subBufferSize
in classCompoundVecBuffer
- Parameters:
index
- the index for the VecBuffer who's size is returned.- Returns:
- the size of the specified VecBuffer.
-
getCoordsPerVec
public int getCoordsPerVec()
Returns the number of coordinates per logical vector element.- Specified by:
getCoordsPerVec
in classCompoundVecBuffer
- Returns:
- the cardinality of a logical vector element.
-
getDataType
public java.lang.String getDataType()
Returns the primitive data type used to interpret the elements of this VecBufferBlocks' backing ByteBuffer.- Returns:
- this VecBufferBlocks' primitive data type.
-
getBuffer
public java.nio.ByteBuffer getBuffer()
Returns the ByteBuffer that stores this VecBufferBlocks' sub-buffers.- Returns:
- this VecBufferBlocks' backing ByteBuffer.
-
addBlock
public int addBlock(int beginPos, int endPos)
Adds a range of bytes that define a new sub-buffer within this VecBufferBlocks. This contents of this buffer's backing ByteBuffer is not changed, nor are its position and limit. The specified range must define a sequence of bytes representing logical vector elements according to this buffer's number of coordinates per logical vector, and this buffer's primitive data type.- Parameters:
beginPos
- the byte range's beginning position.endPos
- the byte range's ending position (inclusive).- Returns:
- the sub-buffer's index.
- Throws:
java.lang.IllegalArgumentException
- if either the position are less than zero, if either position is greater than the backing buffer's capacity, or if the begin position is greater than the end position.
-
createSubBuffer
protected VecBuffer createSubBuffer(int offsetInBytes, int lengthInBytes)
- Specified by:
createSubBuffer
in classCompoundVecBuffer
-
createSlice
protected CompoundVecBuffer createSlice(int[] indices, int offset, int length)
- Specified by:
createSlice
in classCompoundVecBuffer
-
createSlice
protected CompoundVecBuffer createSlice(int beginIndex, int endIndex)
- Specified by:
createSlice
in classCompoundVecBuffer
-
-