samp.directory
← Skripte und Bibliotheken

Vince0789/pawn-array-util

Relatively simple yet useful utilities to work with arrays.

Bibliothek★ 3aktualisiert Feb. 2023MITPawnsampctl
Auf GitHub öffnen

Mit sampctl installieren

sampctl package install Vince0789/pawn-array-util

Führe das in deinem Projektordner aus. sampctl lädt das Paket und alles herunter, wovon es abhängt.

Im Pawn-Compiler ausprobieren →

Fügt seine Include-Dateien samt der Bibliotheken, von denen es abhängt, dem Pawn-Compiler in deinem Browser hinzu, bereit zum Einbinden in ein Skript.

README.md

pawn-array-util

Installation

Simply install to your project:

sampctl package install Vince0789/pawn-array-util

Include in your code and begin using the library:

#include <array_util>

Usage

Version 1.2.0 changed the naming convention from snake_case to PascalCase. The snake case variant of the below functions can still be used, but the compiler will issue a warning. Snake case variants will be removed in 2.0.0.

ArrayShift

stock ArrayShift(array[], value, size = sizeof array)

Appends value to the end of array. Pushes the first value off and returns it, moves everything down.

ArrayUnshift

stock ArrayUnshift(array[], value, size = sizeof array)

Inserts value at the start of array. Pushes the last value off and returns it, moves everything up.

ArraySort

stock ArraySort(array[], left = 0, right = sizeof array)

Sorts array in ascending order. Implementation of the QuickSort algorithm. This function does not return any value.

InArray

stock bool:InArray(needle, const haystack[], &index = -1, size = sizeof haystack)

Returns true if needle is in haystack, false otherwise. Using the index parameter, this function can be used in a while loop to find all instances of a certain value:

new index = -1;

while(InArray(5, theArrayToSearch, index))
{
    printf("found 5 at index: %d", index);
}

Testing

To test, simply run the package:

sampctl package run

Diese Seite wird aus dem erstellt, was GitHub über das Repository veröffentlicht. samp.directory hostet den Code nicht. Ein Problem mit diesem Eintrag melden

Vince0789/pawn-array-util: SA-MP Bibliothek | samp.directory