public abstract class CompoundVecBuffer extends Object
VecBuffer
objects. Each VecBuffer is retrieved via an index. The range of valid indices in a
CompoundVecBuffer is [0, size() - 1], inclusive. Implementations of CompoundVecBuffer define how each VecBuffer is
stored and retrieved according to its index.
To retrieve a single VecBuffer given an index, invoke subBuffer(int)
. To retrieve a VecBuffer's size, in
number of logical tuples, invoke subBufferSize(int)
.
To create a new view of this CompoundVecBuffer from one or many VecBuffers, invoke one of the slice
methods: slice(int, int)
creates a view of this CompoundVecbufer given a contiguous sequence of
VecBuffer indices.slice(int[], int, int)
creates a view of this CompoundVecBuffer given an array
of VecBuffer indices.Modifier and Type | Class and Description |
---|---|
protected class |
CompoundVecBuffer.CompoundIterator<T> |
protected class |
CompoundVecBuffer.CoordIterable |
protected static class |
CompoundVecBuffer.EmptyCompoundVecBuffer |
protected class |
CompoundVecBuffer.LocationIterable |
protected class |
CompoundVecBuffer.PositionIterable |
protected class |
CompoundVecBuffer.ReverseCompoundIterator<T> |
protected static interface |
CompoundVecBuffer.SubBufferIterable<T> |
protected class |
CompoundVecBuffer.VectorIterable |
Modifier and Type | Field and Description |
---|---|
protected static boolean |
ALLOCATE_DIRECT_BUFFERS |
protected int |
capacity |
protected int |
count |
protected static int |
DEFAULT_INITIAL_CAPACITY |
protected IntBuffer |
lengths |
protected IntBuffer |
offsets |
Modifier | Constructor and Description |
---|---|
|
CompoundVecBuffer()
Constructs a CompoundVecBuffer with the default initial capacity.
|
protected |
CompoundVecBuffer(CompoundVecBuffer that,
int[] indices,
int offset,
int length) |
protected |
CompoundVecBuffer(CompoundVecBuffer that,
int beginIndex,
int endIndex) |
|
CompoundVecBuffer(int capacity)
Constructs a CompoundVecBuffer with the specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
protected int |
addSubBuffer(int offset,
int length) |
void |
clear()
Sets the number sub-buffers to zero.
|
protected abstract CompoundVecBuffer |
createSlice(int[] indices,
int offset,
int length) |
protected abstract CompoundVecBuffer |
createSlice(int beginIndex,
int endIndex) |
protected abstract VecBuffer |
createSubBuffer(int offset,
int length) |
static CompoundVecBuffer |
emptyCompoundVecBuffer(int coordsPerVec)
Returns an empty CompoundVecBuffer.
|
protected void |
expandCapacity(int minCapacity) |
Iterable<double[]> |
getCoords()
Returns an iterator over this buffer's logical vectors, as double[] coordinate arrays.
|
Iterable<double[]> |
getCoords(int minCoordsPerVec)
Returns an iterator over this buffer's logical vectors, as double[] coordinate arrays.
|
abstract int |
getCoordsPerVec()
Returns the number of coordinates per logical vector element.
|
Iterable<? extends LatLon> |
getLocations()
Returns an iterator over this buffer's logical vectors, as LatLon locations.
|
Iterable<? extends Position> |
getPositions()
Returns an iterator over this buffer's logical vectors, as geographic Positions.
|
Iterable<double[]> |
getReverseCoords(int minCoordsPerVec)
Returns a reverse iterator over this buffer's logical vectors, as double[] coordinate arrays.
|
Iterable<? extends LatLon> |
getReverseLocations()
Returns a reverse iterator over this buffer's logical vectors, as LatLon locations.
|
Iterable<? extends Position> |
getReversePositions()
Returns a reverse iterator over this buffer's logical vectors, as geographic Positions.
|
Iterable<? extends Vec4> |
getReverseVectors()
Returns a reverse iterator over this buffer's logical vectors, as Vec4 references.
|
Iterable<? extends Vec4> |
getVectors()
Returns an iterator over this buffer's logical vectors, as Vec4 references.
|
int |
size()
Returns the number of VecBuffers stored in this CompoundVecBuffer.
|
CompoundVecBuffer |
slice(int[] indices)
Returns a new logical view of this CompoundVecBuffer.
|
CompoundVecBuffer |
slice(int[] indices,
int offset,
int length)
Returns a new logical view of this CompoundVecBuffer.
|
CompoundVecBuffer |
slice(int beginIndex,
int endIndex)
Returns a new logical view of this CompoundVecBuffer.
|
VecBuffer |
subBuffer(int index)
Returns the sub-buffer at the specified index as a
VecBuffer . |
abstract int |
subBufferSize(int index)
Returns the size in logical vectors of the VecBuffer with the specified index.
|
protected static final boolean ALLOCATE_DIRECT_BUFFERS
protected int capacity
protected int count
protected static final int DEFAULT_INITIAL_CAPACITY
protected IntBuffer lengths
protected IntBuffer offsets
public CompoundVecBuffer()
protected CompoundVecBuffer(CompoundVecBuffer that, int[] indices, int offset, int length)
protected CompoundVecBuffer(CompoundVecBuffer that, int beginIndex, int endIndex)
public CompoundVecBuffer(int capacity)
capacity
- the CompoundVecBuffer's initial capacity, in number of sub-buffers.IllegalArgumentException
- if the capacity is less than 1.protected int addSubBuffer(int offset, int length)
public void clear()
protected abstract CompoundVecBuffer createSlice(int[] indices, int offset, int length)
protected abstract CompoundVecBuffer createSlice(int beginIndex, int endIndex)
protected abstract VecBuffer createSubBuffer(int offset, int length)
public static CompoundVecBuffer emptyCompoundVecBuffer(int coordsPerVec)
coordsPerVec
- the number of coordinates per logical vector.protected void expandCapacity(int minCapacity)
public Iterable<double[]> getCoords()
public Iterable<double[]> getCoords(int minCoordsPerVec)
minCoordsPerVec
- the minimum number of coordinates returned in each double[] array.public abstract int getCoordsPerVec()
public Iterable<? extends LatLon> getLocations()
public Iterable<? extends Position> getPositions()
public Iterable<double[]> getReverseCoords(int minCoordsPerVec)
minCoordsPerVec
- the minimum number of coordinates returned in each double[] array.public Iterable<? extends LatLon> getReverseLocations()
public Iterable<? extends Position> getReversePositions()
public Iterable<? extends Vec4> getReverseVectors()
public Iterable<? extends Vec4> getVectors()
public int size()
public CompoundVecBuffer slice(int[] indices)
indices
, and contains this buffer's contents for each index in indices
. The returned
buffer shares this buffers's backing data. Changes to this buffer are reflected in the returned buffer, and vice
versa.indices
- an array containing the indices include in the subset.IllegalArgumentException
- if the array of indices is null, or if any of the indices is out of range.public CompoundVecBuffer slice(int[] indices, int offset, int length)
length
, and contains this buffer's contents for each index in indices
. The returned
buffer shares this buffers's backing data. Changes to this buffer are reflected in the returned buffer, and vice
versa.indices
- an array containing the indices include in the subset.offset
- the array starting index.length
- the number of array values to use.IllegalArgumentException
- if the array of indices is null, if the offset or length are invalid, or if any
of the indices is out of range.public CompoundVecBuffer slice(int beginIndex, int endIndex)
endIndex - beginIndex
+ 1
and references this buffer's contents starting at beginIndex
, and ending at
endIndex
. The returned buffer shares this buffers's backing data. Changes to this buffer are
reflected in the returned buffer, and vice versa.beginIndex
- the index of the first sub-buffer to include in the subset.endIndex
- the index of the last sub-buffer to include in the subset.IllegalArgumentException
- if beginIndex is out of range, if endIndex is out of range, or if beginIndex >
endIndex.public VecBuffer subBuffer(int index)
VecBuffer
.index
- the index of the VecBuffer to return.IllegalArgumentException
- if the index is out of range.public abstract int subBufferSize(int index)
index
- the index for the VecBuffer who's size is returned.IllegalArgumentException
- if the index is out of range.