Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

PackedInt32Array

A packed array of 32-bit integers.

Description

An array specifically designed to hold 32-bit integer values. Packs data tightly, so it saves memory for large array sizes.

Note: This type stores signed 32-bit integers, which means it can take values in the interval [-2^31, 2^31 - 1], i.e. [-2147483648, 2147483647]. Exceeding those bounds will wrap around. In comparison, int uses signed 64-bit integers which can hold much larger values. If you need to pack 64-bit integers tightly, see PackedInt64Array.

Note

There are notable differences when using this API with C#. See C# API differences to GDScript for more information.

Constructors

PackedInt32Array

PackedInt32Array()

PackedInt32Array

PackedInt32Array(from: PackedInt32Array)

PackedInt32Array

PackedInt32Array(from: Array)

Methods

bool

append(value: int)

void

append_array(array: PackedInt32Array)

int

bsearch(value: int, before: bool = true)

void

clear()

int

count(value: int) const

PackedInt32Array

duplicate()

void

fill(value: int)

int

find(value: int, from: int = 0) const

bool

has(value: int) const

int

insert(at_index: int, value: int)

bool

is_empty() const

bool

push_back(value: int)

void

remove_at(index: int)

int

resize(new_size: int)

void

reverse()

int

rfind(value: int, from: int = -1) const

void

set(index: int, value: int)

int

size() const

PackedInt32Array

slice(begin: int, end: int = 2147483647) const

void

sort()

PackedByteArray

to_byte_array() const

Operators

bool

operator !=(right: PackedInt32Array)

PackedInt32Array

operator +(right: PackedInt32Array)

bool

operator ==(right: PackedInt32Array)

int

operator [](index: int)


Constructor Descriptions

PackedInt32Array PackedInt32Array()

Constructs an empty PackedInt32Array.


PackedInt32Array PackedInt32Array(from: PackedInt32Array)

Constructs a PackedInt32Array as a copy of the given PackedInt32Array.


PackedInt32Array PackedInt32Array(from: Array)

Constructs a new PackedInt32Array. Optionally, you can pass in a generic Array that will be converted.


Method Descriptions

bool append(value: int)

Appends an element at the end of the array (alias of push_back).


void append_array(array: PackedInt32Array)

Appends a PackedInt32Array at the end of this array.


int bsearch(value: int, before: bool = true)

Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search. Optionally, a before specifi