-
-
Notifications
You must be signed in to change notification settings - Fork 9
Array
IsaacShelton edited this page Nov 16, 2022
·
7 revisions
Array
represents the type of an array.
Type | Size | Possible Values | Memory Management Model | File |
---|---|---|---|---|
Array |
32 bytes | Arrays of a Single Type | None | 2.7/Array.adept |
record <$T> Array (items *$T, length usize)
where
$T is any valid type
Name | Type | Description |
---|---|---|
items |
*$T |
Pointer to raw array of items |
length |
usize |
Length of items in units |
func __array__(this *<$T> Array) *$T
func __length__(this *<$T> Array) usize
func __access__(this *<$T> Array, index usize) *$T
implicit func __as__(initializer <$T> InitializerList) <$T> Array
implicit func __as__(initializer <long> InitializerList) <int> Array
implicit func __as__(initializer <double> InitializerList) <float> Array
Arrays can be created from initializer lists:
food <String> Array = {"Spaghetti", "Pizza", "Garlic Bread"}
board <<int> List> Array = {
{0, 0, 0, 0} as <int> Array,
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
}
Arrays have no memory management. The programmer is responsible for managing the memory that the array references.
-
func get(this *<$T> Array, index usize) $T
Gets an item from an Array.
-
func getPointer(this *<$T> Array, index usize) *$T
Gets a pointer to an item in an Array.
-
func contains(this *<$T> Array, value $~T) bool
Returns whether an Array contains an item that is equal to
value
. -
func applyDefer(this *<$T> Array) void
Calls
__defer__
on every element of an array
#default array_bounds_checks true
#default array_error_with_type __typeinfo__