NASA World Wind

gov.nasa.worldwind.util
Class VecBufferBlocks

java.lang.Object
  extended by gov.nasa.worldwind.util.CompoundVecBuffer
      extended by 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 calling addBlock(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
protected  ByteBuffer buffer
           
protected  int coordsPerVec
           
protected  String dataType
           
 
Fields inherited from class gov.nasa.worldwind.util.CompoundVecBuffer
ALLOCATE_DIRECT_BUFFERS, capacity, count, DEFAULT_INITIAL_CAPACITY, lengths, offsets
 
Constructor Summary
  VecBufferBlocks(int coordsPerVec, String dataType, ByteBuffer buffer)
          Constructs a VecBufferBlocks with the specified number of coordinates per logical vector, primitive data type, and backing ByteBuffer.
  VecBufferBlocks(int coordsPerVec, String dataType, 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
 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)
           
 ByteBuffer getBuffer()
          Returns the ByteBuffer that stores this VecBufferBlocks' sub-buffers.
 int getCoordsPerVec()
          Returns the number of coordinates per logical vector element.
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

protected ByteBuffer buffer

coordsPerVec

protected int coordsPerVec

dataType

protected String dataType
Constructor Detail

VecBufferBlocks

public VecBufferBlocks(int coordsPerVec,
                       String dataType,
                       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:
IllegalArgumentException - if the coordsPerVec is less than 1, if the dataType is null, or if the buffer is null.

VecBufferBlocks

public VecBufferBlocks(int coordsPerVec,
                       String dataType,
                       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:
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

protected VecBufferBlocks(VecBufferBlocks that,
                          int[] indices,
                          int offset,
                          int length)

VecBufferBlocks

protected VecBufferBlocks(VecBufferBlocks that,
                          int beginIndex,
                          int endIndex)
Method Detail

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:
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.

createSlice

protected CompoundVecBuffer createSlice(int[] indices,
                                        int offset,
                                        int length)
Specified by:
createSlice in class CompoundVecBuffer

createSlice

protected CompoundVecBuffer createSlice(int beginIndex,
                                        int endIndex)
Specified by:
createSlice in class CompoundVecBuffer

createSubBuffer

protected VecBuffer createSubBuffer(int offsetInBytes,
                                    int lengthInBytes)
Specified by:
createSubBuffer in class CompoundVecBuffer

getBuffer

public ByteBuffer getBuffer()
Returns the ByteBuffer that stores this VecBufferBlocks' sub-buffers.

Returns:
this VecBufferBlocks' backing ByteBuffer.

getCoordsPerVec

public int getCoordsPerVec()
Returns the number of coordinates per logical vector element.

Specified by:
getCoordsPerVec in class CompoundVecBuffer
Returns:
the cardinality of a logical vector element.

getDataType

public String getDataType()
Returns the primitive data type used to interpret the elements of this VecBufferBlocks' backing ByteBuffer.

Returns:
this VecBufferBlocks' primitive data type.

subBufferSize

public int subBufferSize(int index)
Returns the size in logical vectors of the VecBuffer with the specified index.

Specified by:
subBufferSize in class CompoundVecBuffer
Parameters:
index - the index for the VecBuffer who's size is returned.
Returns:
the size of the specified VecBuffer.

NASA World Wind