Class Seq
Nothing here touches the wire. These are the operations a generated message
class performs around a Visitor callback: put an element at the
index its id names, grow a primitive array as elements actually arrive, re-arm a
reused destination. Their code has the same shape for every schema — a
count, a maxlen or a capacity arrives as an argument and an
element type as a type parameter — which is why they live in the corelib rather
than being emitted, rationale and all, into every generated package
(generator#345).
This is the one place in this library that names List. The
codec itself stays array- and primitive-based; a generated message is what holds
a list, because a wrapper array of strings, blobs or sub-messages has no
primitive form.
Three reservations, one shape. Every wrapper array a schema can
declare reaches this class through one of three calls, which differ only in what
a slot holds: placeElem(List, int, T, T, Bound) puts a decoded string or blob at
the index its id names; reserveElem(List, int, Supplier, Bound) makes the slot a struct,
union or nested-array element will be routed into; reserveRow(List, int, Bound)
and its six primitive overloads reserve a matrix row. The schema dependence of
all three is exactly a bound, an element type and an element default — an
argument, a type parameter and an argument — which is the whole of why they fit
here at all.
Two rules run through all of it. Ids are positions (MESSAGE_SPEC §5.1):
an array element's id is its index, an interior element equal to the
element default may be omitted, and the highest id present is what gives the
decoded array its length — so a missing id fills a gap rather than shifting
every later element down by one, and a repeated id replaces rather than appends.
A count is untrusted: it is the wire's claim about how many elements
follow, bounded by nothing until a schema count or a receiver limit
bounds it, so no method here allocates from a count alone.
The index bound (MESSAGE_SPEC §7.1, CORELIB_PLAN §6.2.1). Every
reservation here — placeElem(List, int, T, T, Bound), reserveElem(List, int, Supplier, Bound), reserveRow(List, int, Bound)
and the six primitive reserveRow* overloads — takes a Bound on the
array's element index and compares it here, before anything is created and
before the list is grown to hold it. A wrapper array announces no count, so the
index is what bounds it: its length is highest present id + 1 (MESSAGE_SPEC §5.1),
and two elements at id 0 and id 65535 are a 65536-slot list. The bound is the
schema count where the schema declares one (Bound.schema(long),
a capacity; a breach is INVALID) and the receiver's
max_dyn_array_count where it does not (Bound.receiver(long); a
breach is LIMIT_EXCEEDED) — exactly one of the two, never both. §6.2.1
permits this placement — "a corelib MAY take a limit as an argument and perform
the check itself, and a port that does is conformant" — and each rule then has
one implementation: a caller that passes the bound does not also guard in
front of the call.
checkIndex(int, Bound) is that comparison on its own, published for the sites
that must judge the index before the reservation runs: a generated
fixlenBegin arm bounds a string or blob element's index at
the length word, so that a message ending right there is still refused
rather than reported INCOMPLETE (MESSAGE_SPEC §5.2), and a native matrix
row's header judges the row's index before the row's own element count. The
reservation that follows re-runs it, which costs one comparison against a folded
constant and spares the two sites from having to agree by inspection.
Nothing here holds a limit. The number is the caller's, used for that
one comparison and not retained; there is no default, no fallback and no
clamping, and Sofab.ARRAY_MAX is a format ceiling rather than a
receiver cap. The schema count is the schema's number, handed in the
same way.
The two answers are separate values, and an unstated one is refused.
A Bound reaches the comparison with a number only by naming its rule —
Bound.schema(long) or Bound.receiver(long) — and each carries its
own verdict, so a
caller who never configured a cap cannot arrive here spelling what a
schema-bounded array spells. A null, and Bound.SCHEMA_BOUNDED
(which carries no count), are Sofab.argument(String) rather than an uncompared
index. §6.2.1: "no unset state and no unlimited mode", and a codec "MUST NOT read
an omitted argument as unlimited".
What the caps here do not cover. A string or blob
element's own maxlen is not one of these arguments: the payload arrives
through the visitor's own callback, and its length must be decided at the
length word so that a message truncated right after that word is refused
rather than INCOMPLETE (MESSAGE_SPEC §5.2). There is no reservation here
for it to ride — PayloadAcc.checkStringLength(int, Bound) and
PayloadAcc.string(int, int, byte[], int, int, Bound) own that half.
The cap on a row's own element count, and on the count of a top-level
native array, is not one of these arguments: n below is a length the caller has already bounded, and the
two numbers can be governed by different rules — an inner array the schema
bounds inside an outer one it does not. A native array count also has no call
into this class at all; generated code writes new int[count] straight
into its field. Those checks therefore stay in generated code, deliberately,
and this class must not grow a helper to hold them: a call invented to carry a
check costs more than the guard it replaces.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intInitial element capacity for an array whose length is not bounded by the schema.static final byte[]Shared zero-length arrays.static final double[]The shared emptydouble[]; seeEMPTY_BYTES.static final float[]The shared emptyfloat[]; seeEMPTY_BYTES.static final int[]The shared emptyint[]; seeEMPTY_BYTES.static final long[]The shared emptylong[]; seeEMPTY_BYTES.static final short[]The shared emptyshort[]; seeEMPTY_BYTES. -
Method Summary
Modifier and TypeMethodDescriptionstatic long[]boolsToLongs(List<Boolean> values) Convert a boolean wrapper array to thelong[]the encoder writes.static voidcheckIndex(int id, Bound bound) The element-index rule, written once for all nine reservations — and published for the one site that has none to ride.static byte[]ensureCap(byte[] a, int i, int cap) Enlargeaso indexican be written, doubling its length but never exceedingcap.static double[]ensureCap(double[] a, int i, int cap) ensureCap(byte[], int, int)for adouble[].static float[]ensureCap(float[] a, int i, int cap) ensureCap(byte[], int, int)for afloat[].static int[]ensureCap(int[] a, int i, int cap) ensureCap(byte[], int, int)for anint[].static long[]ensureCap(long[] a, int i, int cap) ensureCap(byte[], int, int)for along[].static short[]ensureCap(short[] a, int i, int cap) ensureCap(byte[], int, int)for ashort[].static <T> List<T> The null-absorbing identity a wrapper array is read through on the encode side — by the serialize loop and by the all-default predicate alike.static <T> voidPlace a leaf element — a wrapper array'sstringorblob— at the index its wire id names, growing the list and filling the gaps that omitted interior elements left (MESSAGE_SPEC §5.1, §2).static <T> voidreserveElem(List<T> out, int id, Supplier<T> make, Bound bound) Reserve a framed element — the slot a wrapper array'sstruct,unionor nested-array element is routed into: bound the index, then grow the list toid + 1, giving each new slot its own element frommake(MESSAGE_SPEC §5.1, §2).static <T> voidreserveRow(List<List<T>> rows, int id, Bound bound) Reserve the row at indexidof a matrix — an array whose elements are themselves arrays — as an empty row, growing the outer list with empty rows so that a gap in the ids decodes as an empty row instead of shifting every later row down by one.static byte[]reserveRowBytes(List<byte[]> rows, int id, int n, Bound bound) reserveRow(List, int, Bound)for a primitive row: the same id-keyed placement and the same gap fill with the empty row, but the new row is handed back so the caller can fill it by index instead of reading it out of the list once per element.static double[]reserveRowDoubles(List<double[]> rows, int id, int n, Bound bound) reserveRowBytes(List, int, int, Bound)for adouble[]row.static float[]reserveRowFloats(List<float[]> rows, int id, int n, Bound bound) reserveRowBytes(List, int, int, Bound)for afloat[]row.static int[]reserveRowInts(List<int[]> rows, int id, int n, Bound bound) reserveRowBytes(List, int, int, Bound)for anint[]row.static long[]reserveRowLongs(List<long[]> rows, int id, int n, Bound bound) reserveRowBytes(List, int, int, Bound)for along[]row.static short[]reserveRowShorts(List<short[]> rows, int id, int n, Bound bound) reserveRowBytes(List, int, int, Bound)for ashort[]row.static <T> List<T> Empty a list in place, keeping its capacity, and materialize one only when the field is null.
-
Field Details
-
ARRAY_INIT_CAP
public static final int ARRAY_INIT_CAPInitial element capacity for an array whose length is not bounded by the schema. The announced count decides the ceiling, never the first allocation: a decoder that sized the destination from an untrusted count would let a three-byte header ask for gigabytes, so growth starts here andensureCap(int[], int, int)doubles it against elements that have actually arrived.- See Also:
-
EMPTY_BYTES
public static final byte[] EMPTY_BYTESShared zero-length arrays. A generated field initializer references one of these instead of allocating a fresh empty array per instance — decode replaces the value anyway, and a zero-length array has no state to share. -
EMPTY_SHORTS
public static final short[] EMPTY_SHORTSThe shared emptyshort[]; seeEMPTY_BYTES. -
EMPTY_INTS
public static final int[] EMPTY_INTSThe shared emptyint[]; seeEMPTY_BYTES. -
EMPTY_LONGS
public static final long[] EMPTY_LONGSThe shared emptylong[]; seeEMPTY_BYTES. -
EMPTY_FLOATS
public static final float[] EMPTY_FLOATSThe shared emptyfloat[]; seeEMPTY_BYTES. -
EMPTY_DOUBLES
public static final double[] EMPTY_DOUBLESThe shared emptydouble[]; seeEMPTY_BYTES.
-
-
Method Details
-
placeElem
Place a leaf element — a wrapper array'sstringorblob— at the index its wire id names, growing the list and filling the gaps that omitted interior elements left (MESSAGE_SPEC §5.1, §2).Three rules of §5.1 sit in this one loop, and not one of them is visible in the bytes: two implementations can disagree about every one and still emit an identical message, which is why they are written here once instead of being re-emitted per schema (CORELIB_PLAN §7.2 item 8 asks for them separately for the same reason).
- A missing id fills a gap with
defrather than shifting every later element down by one — an interior element equal to the element default is omitted by a conformant encoder (§2). - The array's length is highest present id + 1, so growing to
id + 1per element is exactly right and no trailing fill is ever needed: the last element is never elided. - A repeated id replaces rather than appends (§7.4), which
setdoes by construction and anaddcould not.
The index is bounded before the list grows (§7.2 item 8), so a refused id leaves the list exactly as it was and a lower id delivered afterwards still lands at its own index. Where the schema declares a
count,boundcarries it and a breach isINVALID(MESSAGE_SPEC §7.1); where it declares none,boundcarries the receiver cap and a breach isLIMIT_EXCEEDED. Never both (§6.2.1); seecheckIndex(int, Bound).defis shared, not copied. The gap value of an array of strings or blobs is""orEMPTY_BYTES— immutable, or zero-length and so with no state to share — so a gap costs no allocation. An element whose default is a mutable object belongs inreserveElem(List, int, Supplier, Bound)instead, which makes one per slot.- Type Parameters:
T- element type- Parameters:
out- the destination list, which this growsid- the element's wire id, which is its indexdef- the element default, filling any gap belowidvalue- the decoded elementbound-Bound.schema(long)carrying the schemacount, orBound.receiver(long)carrying the caller'smax_dyn_array_countwhere the schema declares none (§6.2.1) — seecheckIndex(int, Bound)- Throws:
UncheckedIOException- wrapping anINVALID_MSGSofabExceptionwhenidis at or past the schemacount, aLIMIT_EXCEEDEDone when it is at or past the receiver cap, or anARGUMENTone whenboundis null orBound.SCHEMA_BOUNDED; the list is left untouched in all three
- A missing id fills a gap with
-
reserveElem
Reserve a framed element — the slot a wrapper array'sstruct,unionor nested-array element is routed into: bound the index, then grow the list toid + 1, giving each new slot its own element frommake(MESSAGE_SPEC §5.1, §2).The same three rules as
placeElem(List, int, T, T, Bound)and the same ordering — the index is decided before the list grows (§7.2 item 8) — with one deliberate difference: a slot already present is left alone. A framed element's fields arrive one at a time and each is routed into the object this call reserved, so a re-opened element id must merge into what its earlier fields built rather than start the element again (§7.4); replacing the slot would discard them. That is also why nothing is returned: generated code parksidin its own element-index register and reaches the element throughout.get(...)on the field arms that follow.A factory, not a shared default. A struct, union or nested row is mutable and reachable by the caller, and an arriving element decodes into the object placed here, so one shared instance would alias every element of the array onto it — the single reason this is a second method rather than
placeElem(List, int, T, T, Bound)with one more argument.makeis a generated method reference (SomeElem::new): it names a generated type, which is the schema dependence a type parameter is allowed to carry, and javac lowers a non-capturing one to a constant, so the argument allocates nothing per call.What this does not own is the routing — binding the element index, switching into the element's scope, emptying a re-opened nested row. That has a different shape per schema and stays generated. This owns growth and the bound, and stops at the slot.
- Type Parameters:
T- element type- Parameters:
out- the destination list, which this growsid- the element's wire id, which is its indexmake- the element factory, called once per slot this createsbound-Bound.schema(long)carrying the schemacount, orBound.receiver(long)carrying the caller'smax_dyn_array_countwhere the schema declares none (§6.2.1) — seecheckIndex(int, Bound)- Throws:
UncheckedIOException- wrapping anINVALID_MSGSofabExceptionwhenidis at or past the schemacount, aLIMIT_EXCEEDEDone when it is at or past the receiver cap, or anARGUMENTone whenboundis null orBound.SCHEMA_BOUNDED; the list is left untouched in all three
-
reserveRow
Reserve the row at indexidof a matrix — an array whose elements are themselves arrays — as an empty row, growing the outer list with empty rows so that a gap in the ids decodes as an empty row instead of shifting every later row down by one.Gaps are ordinary: an interior row equal to the element default (the empty row) is omitted by a conformant encoder (MESSAGE_SPEC §2), and only the last row is guaranteed present — which is what makes the decoded length, highest present id + 1, exact. The row is replaced rather than merged into, because an array wrapper is the array's value (§7.4).
"Replaced" is a statement about the value, not the object: an already present row is emptied in place — the same rule
reset(List)follows for a reused decode destination — instead of being swapped for a fresh list. Decoding N rows then allocates N lists rather than 2N, one to grow into the slot and one to overwrite it. A caller holding a reference to a row across a decode into the same destination sees it emptied; a decode destination is not shared.idis the wire's, and this grows the list to hold it, so it is bounded here. Which bound depends on the outer array: where the schema declares a capacity,boundcarries it and a breach isINVALID(MESSAGE_SPEC §7.1); where the schema declares none,boundcarries the receiver cap and a breach isLIMIT_EXCEEDED(§6.2.1).- Type Parameters:
T- row element type- Parameters:
rows- the outer list, one entry per rowid- index of the row to reservebound-Bound.schema(long)carrying the outer array's schemacount, orBound.receiver(long)carrying the caller'smax_dyn_array_countwhere the schema declares none (§6.2.1) — seecheckIndex(int, Bound)- Throws:
UncheckedIOException- wrapping anINVALID_MSGSofabExceptionwhenidis at or past the schemacount, aLIMIT_EXCEEDEDone when it is at or past the receiver cap, or anARGUMENTone whenboundis null orBound.SCHEMA_BOUNDED; the list is left untouched in all three
-
reserveRowBytes
reserveRow(List, int, Bound)for a primitive row: the same id-keyed placement and the same gap fill with the empty row, but the new row is handed back so the caller can fill it by index instead of reading it out of the list once per element.nis the caller's capped reservation, never the wire count — an untrusted count must not be able to force an up-front allocation — andensureCap(byte[], int, int)grows the row as elements arrive.- Parameters:
rows- the outer list, one entry per rowid- index of the row to reserven- initial length of the new rowbound-Bound.schema(long)carrying the outer array's schemacount, orBound.receiver(long)carrying the caller'smax_dyn_array_count, bounding the row index — seecheckIndex(int, Bound). It does not boundn, which the caller has already bounded.- Returns:
- the new row, now at index
id - Throws:
UncheckedIOException- wrapping anINVALID_MSGSofabExceptionwhenidis at or past the schemacount, aLIMIT_EXCEEDEDone when it is at or past the receiver cap, or anARGUMENTone whenboundis null orBound.SCHEMA_BOUNDED; the list is left untouched in all three
-
reserveRowShorts
reserveRowBytes(List, int, int, Bound)for ashort[]row.- Parameters:
rows- the outer list, one entry per rowid- index of the row to reserven- initial length of the new rowbound-Bound.schema(long)carrying the outer array's schemacount, orBound.receiver(long)carrying the caller'smax_dyn_array_count, bounding the row index — seecheckIndex(int, Bound). It does not boundn, which the caller has already bounded.- Returns:
- the new row, now at index
id - Throws:
UncheckedIOException- wrapping anINVALID_MSGSofabExceptionwhenidis at or past the schemacount, aLIMIT_EXCEEDEDone when it is at or past the receiver cap, or anARGUMENTone whenboundis null orBound.SCHEMA_BOUNDED; the list is left untouched in all three
-
reserveRowInts
reserveRowBytes(List, int, int, Bound)for anint[]row.- Parameters:
rows- the outer list, one entry per rowid- index of the row to reserven- initial length of the new rowbound-Bound.schema(long)carrying the outer array's schemacount, orBound.receiver(long)carrying the caller'smax_dyn_array_count, bounding the row index — seecheckIndex(int, Bound). It does not boundn, which the caller has already bounded.- Returns:
- the new row, now at index
id - Throws:
UncheckedIOException- wrapping anINVALID_MSGSofabExceptionwhenidis at or past the schemacount, aLIMIT_EXCEEDEDone when it is at or past the receiver cap, or anARGUMENTone whenboundis null orBound.SCHEMA_BOUNDED; the list is left untouched in all three
-
reserveRowLongs
reserveRowBytes(List, int, int, Bound)for along[]row.- Parameters:
rows- the outer list, one entry per rowid- index of the row to reserven- initial length of the new rowbound-Bound.schema(long)carrying the outer array's schemacount, orBound.receiver(long)carrying the caller'smax_dyn_array_count, bounding the row index — seecheckIndex(int, Bound). It does not boundn, which the caller has already bounded.- Returns:
- the new row, now at index
id - Throws:
UncheckedIOException- wrapping anINVALID_MSGSofabExceptionwhenidis at or past the schemacount, aLIMIT_EXCEEDEDone when it is at or past the receiver cap, or anARGUMENTone whenboundis null orBound.SCHEMA_BOUNDED; the list is left untouched in all three
-
reserveRowFloats
reserveRowBytes(List, int, int, Bound)for afloat[]row.- Parameters:
rows- the outer list, one entry per rowid- index of the row to reserven- initial length of the new rowbound-Bound.schema(long)carrying the outer array's schemacount, orBound.receiver(long)carrying the caller'smax_dyn_array_count, bounding the row index — seecheckIndex(int, Bound). It does not boundn, which the caller has already bounded.- Returns:
- the new row, now at index
id - Throws:
UncheckedIOException- wrapping anINVALID_MSGSofabExceptionwhenidis at or past the schemacount, aLIMIT_EXCEEDEDone when it is at or past the receiver cap, or anARGUMENTone whenboundis null orBound.SCHEMA_BOUNDED; the list is left untouched in all three
-
reserveRowDoubles
reserveRowBytes(List, int, int, Bound)for adouble[]row.- Parameters:
rows- the outer list, one entry per rowid- index of the row to reserven- initial length of the new rowbound-Bound.schema(long)carrying the outer array's schemacount, orBound.receiver(long)carrying the caller'smax_dyn_array_count, bounding the row index — seecheckIndex(int, Bound). It does not boundn, which the caller has already bounded.- Returns:
- the new row, now at index
id - Throws:
UncheckedIOException- wrapping anINVALID_MSGSofabExceptionwhenidis at or past the schemacount, aLIMIT_EXCEEDEDone when it is at or past the receiver cap, or anARGUMENTone whenboundis null orBound.SCHEMA_BOUNDED; the list is left untouched in all three
-
checkIndex
The element-index rule, written once for all nine reservations — and published for the one site that has none to ride. A bound must have been stated, and the index is refused before anything is created and before the list is grown to hold it (CORELIB_PLAN §7.2 item 8), so a lower id delivered after a refused one still lands at its own index.Which verdict a breach earns is the bound's, and exactly one of the two is ever in force (§6.2.1, "never both"):
Bound.schema(long)— the schemacount, a capacity: the list starts empty, the wire carries the length, andid >= countisSofabError.INVALID_MSG(MESSAGE_SPEC §7.1). NeverLIMIT_EXCEEDED.Bound.receiver(long)— themax_dyn_array_countfor an array the schema leaves open, andid >= capisSofabError.LIMIT_EXCEEDED.
The site with no reservation is the length word of a
stringorblobelement: generated code bounds the element's index there, so that a message ending right after that word is refused rather than reportedINCOMPLETE(MESSAGE_SPEC §5.2), and the placement that follows —placeElem(List, int, T, T, Bound)— runs the same comparison again against the same folded constant.The index is compared with
>=rather than>because a wrapper array's length is highest present id + 1 (MESSAGE_SPEC §5.1): an element at indexnmakes a list ofn + 1. Rejected, never clamped — placing the element atn - 1instead would be data corruption.A missing bound, or
Bound.SCHEMA_BOUNDED— which carries no count to compare — is a defect in the call and answersSofabError.ARGUMENT, not a verdict on the bytes and not silence, which would grow the list uncompared (§6.3).The fast path is one comparison against a folded constant; the verdict is decided out of line, on the path that throws.
- Parameters:
id- the element's wire id, which is its indexbound-Bound.schema(long)carrying the schemacount, orBound.receiver(long)carrying the caller'smax_dyn_array_count(§6.2.1)- Throws:
UncheckedIOException- wrapping anINVALID_MSGSofabExceptionwhenidis at or past the schemacount, aLIMIT_EXCEEDEDone when it is at or past the receiver cap, or anARGUMENTone whenboundis null orBound.SCHEMA_BOUNDED
-
reset
Empty a list in place, keeping its capacity, and materialize one only when the field is null.A generated
reset()calls this, so re-arming a reused decode destination costs no allocation — which is the whole point of taking a destination from the caller.- Type Parameters:
T- element type- Parameters:
list- the list to re-arm, possibly null- Returns:
list, emptied, or a fresh list when it was null
-
orEmpty
The null-absorbing identity a wrapper array is read through on the encode side — by the serialize loop and by the all-default predicate alike.No narrowing happens here and none may: the wire count is a compact array's length and the highest wrapper id is its last index (MESSAGE_SPEC §3 / §5.1), so dropping a trailing default element would not re-shape the bytes, it would shorten the value. What the interior may drop — a leaf equal to the element default, an all-default sequence element — is decided per element inside the loop, never here.
- Type Parameters:
T- element type- Parameters:
list- the field's value, possibly null- Returns:
list, or an immutable empty list when it was null
-
boolsToLongs
Convert a boolean wrapper array to thelong[]the encoder writes.This is the one boxed-to-primitive conversion the encode side still needs. Every other native array — top level or a matrix row — is already a primitive array of its declared width and reaches
OStream.writeArrayUnsigned(int, long[])and friends unconverted; a boolean array is the one with no primitive overload of its own,boolbeing carried on the wire as an unsigned 0 or 1.- Parameters:
values- the field's value; a null element counts as false- Returns:
- one long per element, 1 for true and 0 for false
-
ensureCap
public static byte[] ensureCap(byte[] a, int i, int cap) Enlargeaso indexican be written, doubling its length but never exceedingcap.This is the growth policy for an array being filled element by element, and its whole point is that it tracks elements that have actually arrived. The alternative — sizing the destination from the announced count — hands an attacker a multi-gigabyte allocation for a three-byte header, since a count is bounded only by
Sofab.ARRAY_MAXuntil a schemacountor a receiver limit bounds it. Doubling keeps the fill amortized O(n), and thecapclamp means a valid array of the announced length still ends up exactly right-sized rather than at the next power of two.capis a ceiling on the result, not a bound the caller is relieved of checking: it is the announced count for an unbounded field and the schema capacity for a bounded one, both already validated by the caller, and a fill that stays below its own count therefore never sees it clamp. Returnsauntouched wheneverialready fits, so the call sits on the hot path unguarded.- Parameters:
a- the array so fari- index about to be writtencap- growth ceiling: the announced or declared element count- Returns:
a, or a longer copy of it
-
ensureCap
public static short[] ensureCap(short[] a, int i, int cap) ensureCap(byte[], int, int)for ashort[].- Parameters:
a- the array so fari- index about to be writtencap- growth ceiling: the announced or declared element count- Returns:
a, or a longer copy of it
-
ensureCap
public static int[] ensureCap(int[] a, int i, int cap) ensureCap(byte[], int, int)for anint[].- Parameters:
a- the array so fari- index about to be writtencap- growth ceiling: the announced or declared element count- Returns:
a, or a longer copy of it
-
ensureCap
public static long[] ensureCap(long[] a, int i, int cap) ensureCap(byte[], int, int)for along[].- Parameters:
a- the array so fari- index about to be writtencap- growth ceiling: the announced or declared element count- Returns:
a, or a longer copy of it
-
ensureCap
public static float[] ensureCap(float[] a, int i, int cap) ensureCap(byte[], int, int)for afloat[].- Parameters:
a- the array so fari- index about to be writtencap- growth ceiling: the announced or declared element count- Returns:
a, or a longer copy of it
-
ensureCap
public static double[] ensureCap(double[] a, int i, int cap) ensureCap(byte[], int, int)for adouble[].- Parameters:
a- the array so fari- index about to be writtencap- growth ceiling: the announced or declared element count- Returns:
a, or a longer copy of it
-