java.lang.StringBuilder
, but for arrays of integers. The
client prepends data, so the array builds right to left, and may
finally take the built array, often without copying the data.
Modifier and Type | Field and Description |
---|---|
private int | |
private int | |
private int[] |
Access | Constructor and Description |
---|---|
public | |
public |
Modifier and Type | Method and Description |
---|---|
protected void | ensure(int
to make additional space for n)Implements abstract org. n elements.
|
public int | length()
Implements abstract org. |
public int | max()
Implements abstract org. |
protected void | prependUnchecked(int
to prepend v)Implements abstract org. |
public int[] | take()
Implements abstract org. |
protected int[] | value()
Implements abstract org. |
max | back to summary |
---|---|
private int max |
ptr | back to summary |
---|---|
private int ptr |
value | back to summary |
---|---|
private int[] value |
IntArrayReverseBuilder | back to summary |
---|---|
public IntArrayReverseBuilder(int capacity) Create an empty buffer of a defined initial capacity.
|
IntArrayReverseBuilder | back to summary |
---|---|
public IntArrayReverseBuilder() Create an empty buffer of a default initial capacity. |
ensure | back to summary |
---|---|
protected void ensure(int n) Implements abstract org. Doc from org. Ensure there is room for another
|
length | back to summary |
---|---|
public int length() Implements abstract org. Doc from org. The number of elements currently
|
max | back to summary |
---|---|
public int max() Implements abstract org. Doc from org. The maximum value stored.
|
prependUnchecked | back to summary |
---|---|
protected void prependUnchecked(int v) Implements abstract org. Doc from org. Prepend one element without ensuring that there is space. This
method is for use when it is known that there is space for the
element, for example, inside a loop before which when
|
take | back to summary |
---|---|
public int[] take() Implements abstract org. Doc from org. Provide the contents as an array and reset the builder to empty.
(This is a "destructive read".) The return type is Object in
order that sub-classes may define the specific type (for example,
|
value | back to summary |
---|---|
protected int[] value() Implements abstract org. Doc from org. An array of the elements in the buffer (not modified by methods on this object hereafter).
|