Skip to content
IsaacShelton edited this page Nov 16, 2022 · 7 revisions

Array

Array represents the type of an array.

Specifications

Type Size Possible Values Memory Management Model File
Array 32 bytes Arrays of a Single Type None 2.7/Array.adept

Definition

record <$T> Array (items *$T, length usize)

where

$T is any valid type

Fields

Name Type Description
items *$T Pointer to raw array of items
length usize Length of items in units

Overloads

  • 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

Array Literals

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}
}

Memory Management

Arrays have no memory management. The programmer is responsible for managing the memory that the array references.

Methods

  • func get(this *<$T> Array, index usize) $T

    Gets an item from an Array.

    [view src]

  • func getPointer(this *<$T> Array, index usize) *$T

    Gets a pointer to an item in an Array.

    [view src]

  • func contains(this *<$T> Array, value $~T) bool

    Returns whether an Array contains an item that is equal to value.

    [view src]

  • func applyDefer(this *<$T> Array) void

    Calls __defer__ on every element of an array

    [view src]

Settings

#default array_bounds_checks true
#default array_error_with_type __typeinfo__
Clone this wiki locally