Arrays of Int16: basics #
The type, its model, and the operations compiled to the runtime: reads, writes,
push, capacity, append and copySlice.
Arrays of Int16 values, stored unboxed in a scalar array, 2 bytes per element.
The logical model is an Array Int16: Int16Array.mk and Int16Array.toArray convert
between the two. cases and induction split a Int16Array as mk a.
Instances For
The Int16Array whose elements are a.
Instances For
The number of elements of a.
Instances For
For internal use only.
Instances For
For internal use only.
Instances For
Decides a.size < USize.size, which holds for every array in memory, as for usize. The safe loops
index with USize, so their csimp proofs test the bound, with a fallback for the other case. At
runtime this instance is isTrue without a test, so the compiler removes the test and the fallback,
which would otherwise cost a Nat comparison and, when the fallback calls a fold, a closure for its
function. This is the one unchecked fact behind those proofs.
The element at the USize index i. It compiles to an inline load.
Instances For
The element at index i.
Instances For
For internal use only.
Instances For
Stores v at index i in place. Only valid when a is exclusive and i is in bounds. Public only
so that uset can be inlined into code in other modules.
Instances For
For internal use only.
Instances For
Returns a itself when it is not shared, and a copy otherwise. Logically this is the identity.
It is useful before a run of in-place writes, so that only the first one can copy.
Instances For
ensureCapacity and ensureExclusiveWithCapacity when a lacks room for n elements: copies a
with room for exactly max n a.size elements. Out of line so that inlined call sites stay small.
Public only so that those functions can be inlined into code in other modules.
Instances For
For internal use only.
Instances For
Returns a itself when it has room for n elements, and otherwise a copy with room for exactly
max n a.size elements. Logically this is the identity. Unlike ensureExclusiveWithCapacity, it
does not copy a just because it is shared.
Instances For
For internal use only.
Instances For
Returns a itself when it is not shared and has room for n elements, and otherwise a single copy
with room for exactly max n a.size elements. Logically this is the identity. It is useful before a
run of in-place writes and pushes, so that none of them copies.
Instances For
For internal use only.
Instances For
For internal use only.
Instances For
Case analysis on a Int16Array as mk a. It is the default for cases and induction.
Instances For
An empty array with room for capacity elements before reallocating.
Instances For
Replaces the element at index i, in place when a is not shared. It compiles to inline C: one
check that a is exclusive, copying it if not, and one store.
Instances For
For internal use only.
Instances For
Replaces the element at index i, in place when a is not shared, like uset.
Instances For
For internal use only.
Instances For
The element at index i. Panics if i is out of bounds, and then returns default.
Instances For
The element at index i, or v₀ if i is out of bounds.
Instances For
Replaces the element at index i. If i is out of bounds, the array is returned unmodified.
Instances For
For internal use only.
Instances For
Appends v to a, in place when a is not shared and has room. A full array grows to capacity
2 * capacity + 1, so repeated pushes take amortized constant time.
Instances For
Appends the elements of b to a, in place when a is not shared and has room.
Instances For
Copies the elements of src from index srcOff up to, but not including, srcOff + len into
dest starting at index destOff, growing dest if necessary. The copy works in place when dest
is not shared and has room. If exact is false, the capacity is doubled when dest grows.