Arrays (zCArray)
Set of function for working with ZenGin's zCArray
data structure.
Initialization
The best way to initialize all Ikarus functions is to call MEM_InitAll()
in the Init_Global()
initialization function.
Warning
If you want to use Ikarus in Gothic 1, it is best to define your own Init_Global()
function and call it from every world initialization function.
Implementation
Functions
MEM_ArrayCreate
Creates an empty zCArray
(allocates memory) and returns a pointer to it.
The function returns a pointer to the created zCArray
.
MEM_ArrayFree
Frees the memory allocated for a zCArray
and its data.
var int zCArray_ptr
Pointer to thezCArray
to be freed
MEM_ArrayClear
Clears the data of a zCArray
, freeing the memory used by its elements. The array becomes empty.
var int zCArray_ptr
Pointer to thezCArray
to be cleared
MEM_ArraySize
Returns the size (number of elements) of an array.
var int zCArray_ptr
Pointer to thezCArray
Return value
The function returns a number of a zCArray
elements.
MEM_ArrayWrite
Writes a value at a specific position in the zCArray
.
var int zCArray_ptr
Pointer to thezCArray
var int pos
Position in the array where the value will be writtenvar int value
Value to be written
MEM_ArrayRead
Reads the value at a specific position in the zCArray
.
var int zCArray_ptr
Pointer to thezCArray
var int pos
Position in the array from which the value will be read
Return value
The function returns the value at a specific position in the zCArray
.
MEM_ArrayInsert
Appends a value to the end of the zCArray
. The array is automatically resized if it is too small.
var int zCArray_ptr
Pointer to thezCArray
var int value
Value to be inserted
MEM_ArrayPush
Alias for MEM_ArrayInsert
, inserts a value at the end of the zCArray
.
var int zCArray_ptr
Pointer to thezCArray
var int value
Value to be inserted
MEM_ArrayPop
Removes and returns the last element from the zCArray
.
var int zCArray_ptr
Pointer to thezCArray
Return value
The function returns the element removed from the end of an array.
MEM_ArrayTop
Returns the last element of the zCArray
without removing it.
var int zCArray_ptr
Pointer to thezCArray
Return value
The function returns the last element of an array.
MEM_ArrayIndexOf
Searches the zCArray
for the first occurrence of a value
and returns its index.
var int zCArray_ptr
Pointer to thezCArray
var int value
Value to search for
Return value
The function returns the index of a first occurrence of a value
. If not found -1
is returned.
MEM_ArrayRemoveIndex
Removes the element at a specific index from the zCArray
.
var int zCArray_ptr
Pointer to thezCArray
var int index
Index of the element to be removed
MEM_ArrayRemoveValue
Removes all occurrences of a value from the zCArray
.
var int zCArray_ptr
Pointer to thezCArray
var int value
Value to be removed
MEM_ArrayRemoveValueOnce
Removes the first occurrence of a value from the zCArray
. If value is not found, a warning is issued.
var int zCArray_ptr
Pointer to thezCArray
var int value
Value to be removed
MEM_ArraySort
Sorts the elements of the zCArray
in ascending order.
var int zCArray_ptr
Pointer to thezCArray
MEM_ArrayUnique
Removes duplicate elements from the zCArray
.
var int zCArray_ptr
Pointer to thezCArray
MEM_ArrayToString
Converts the zCArray
to a string representation.
var int zCArray_ptr
Pointer to thezCArray
Return value
The function returns a string representation of a given array.