ALN
0.1.1
|
Amazing Lucky Numbers Library API. More...
Go to the source code of this file.
Macros | |
#define | ALN_API_EXPORT __attribute__((visibility("default"))) |
#define | ALN_API_IMPORT |
#define | ALN_API ALN_API_IMPORT |
Typedefs | |
typedef struct _ALN | ALN |
Opaque structure representing the Amazing Lucky Numbers generator. | |
Functions | |
ALN_API ALN * | aln_new (unsigned int count, unsigned int min, unsigned int max, int allow_repeat) |
Creates a new ALN instance. More... | |
ALN_API void | aln_free (ALN *aln) |
Frees an ALN instance. More... | |
ALN_API void | aln_reset (ALN *aln) |
Resets an ALN instance. More... | |
ALN_API int | aln_draw_number (ALN *aln, unsigned int *number) |
Draws a single lucky number. More... | |
ALN_API int | aln_draw_all (ALN *aln) |
Draws all remaining lucky numbers. More... | |
ALN_API unsigned int | aln_get_number (const ALN *aln, unsigned int index) |
Gets a specific lucky number by index. More... | |
Amazing Lucky Numbers Library API.
This library provides functions to manage and generate lucky numbers.
ALN_API int aln_draw_all | ( | ALN * | aln | ) |
Draws all remaining lucky numbers.
This function draws all remaining lucky numbers from the ALN instance.
aln | Pointer to the ALN instance. |
0 | Successfully drew all numbers. |
-1 | Failed to draw all numbers. |
ALN_API int aln_draw_number | ( | ALN * | aln, |
unsigned int * | number | ||
) |
Draws a single lucky number.
This function draws a single lucky number from the ALN instance.
aln | Pointer to the ALN instance. |
number | Pointer to store the drawn number. |
0 | Successfully drew a number. |
-1 | Failed to draw a number. |
ALN_API void aln_free | ( | ALN * | aln | ) |
Frees an ALN instance.
This function deallocates an ALN instance created with aln_new.
aln | Pointer to the ALN instance to free. |
ALN_API unsigned int aln_get_number | ( | const ALN * | aln, |
unsigned int | index | ||
) |
Gets a specific lucky number by index.
This function retrieves a specific lucky number by its index in the ALN instance. Either aln_draw_number() or aln_draw_all() should be called before calling this function.
aln | Pointer to the ALN instance. |
index | The index of the number to retrieve. Index starts from 0. |
ALN_API ALN* aln_new | ( | unsigned int | count, |
unsigned int | min, | ||
unsigned int | max, | ||
int | allow_repeat | ||
) |
Creates a new ALN instance.
This function allocates and initializes a new ALN instance for generating lucky numbers.
count | The number of lucky numbers to generate. |
min | The minimum value a generated number can be. |
max | The maximum value a generated number can be. |
allow_repeat | If 1, allows duplicate numbers; if 0, numbers will be unique. |
ALN_API void aln_reset | ( | ALN * | aln | ) |
Resets an ALN instance.
This function resets the state of the ALN instance, allowing numbers to be drawn again.
aln | Pointer to the ALN instance to reset. |