PureBasic - Array

Overview

Arrays are structures to store indexed elements. Unlike a list or a map, the elements are allocated in a contiguous manner in memory. Therefore, it's not possible to easily insert or remove an element. On other hand, it provides a very fast direct access to a random element.

To work with Arrays, they have to be declared first. This could be done with the keyword Dim and can be resized with ReDim.

Arrays can be sorted using SortArray() or SortStructuredArray(), and can also be randomized using RandomizeArray().

Note: These arrays are called dynamic because they can change size. However, there are also so-called static arrays, which can not be resized and are only used in structures. These arrays are written with square brackets. For example: ArrayStatic[2]. See here. The functions of this Array library can not be used with this type of array.

Command Index

ArraySize
CopyArray
FreeArray

Sort & misc.

SortArray()
SortStructuredArray()
RandomizeArray()

Example

Array.pb

Supported OS

All

Reference Manual - Index