36 while (list[i] != NULL)
47 return list == NULL || list[0] == NULL;
60 for (
size_t i = 0; list[i] != NULL; i++) {
75 gmPtrList new_list = realloc(list, (length + 2) *
sizeof(
void *));
76 new_list[length] = obj;
77 new_list[length + 1] = NULL;
90 gmPtrList new_list = realloc(list, len *
sizeof(
void *));
91 new_list[len - 1] = NULL;
107 gmPtrList new_list = malloc((len - count + 1) *
sizeof(
void *));
109 for (
size_t i = 0; i < len; i++) {
110 if (list[i] != obj) {
111 new_list[index++] = list[i];
114 new_list[index] = NULL;
130 gmPtrList new_list = malloc(len *
sizeof(
void *));
132 for (
size_t i = 0; i < len; i++) {
134 new_list[new_idx++] = list[i];
137 new_list[new_idx] = NULL;
154 gmPtrList new_list = malloc((len + 2) *
sizeof(
void *));
155 for (
size_t i = 0; i < idx; i++) {
156 new_list[i] = list[i];
158 new_list[idx] = value;
159 for (
size_t i = idx; i < len; i++) {
160 new_list[i + 1] = list[i];
162 new_list[len + 1] = NULL;
176 for (
size_t i = 0; list[i] != NULL; i++) {
177 if (list[i] == value)
223#define gm_ptr_list_for_each(item, list) \
224 for (size_t i = 0; (list != NULL) && (item = list[i]) != NULL; i++)
235static inline size_t gm_bodies_length(
gmBodies list) {
238static inline int gm_bodies_is_empty(
gmBodies list) {
269static inline void gm_bodies_clear(
gmBodies list) {
278#define gm_bodies_for_each(item, list) \
279 for (size_t i = 0; (list != NULL) && (item = list[i]) != NULL; i++)
gmPtrList gm_ptr_list_pop_at(gmPtrList list, size_t idx)
Removes an element at a specific index.
Definition body_list.h:125
gmPtrList gm_ptr_list_insert_at(gmPtrList list, size_t idx, void *value)
Inserts a pointer at a specific index.
Definition body_list.h:149
void * gm_ptr_list_last(gmPtrList list)
Retrieves the last element of the list.
Definition body_list.h:202
gmPtrList gm_ptr_list_push(gmPtrList list, void *obj)
Adds a pointer to the end of the list.
Definition body_list.h:73
void ** gmPtrList
A dynamic, NULL-terminated array of generic pointers.
Definition body_list.h:25
size_t gm_ptr_list_length(gmPtrList list)
Calculates the number of elements in a pointer list.
Definition body_list.h:32
gmPtrList gm_ptr_list_pop(gmPtrList list)
Removes the last element from the list.
Definition body_list.h:86
void gm_ptr_list_clear(gmPtrList list)
Frees the memory used by the list.
Definition body_list.h:212
gmPtrList gm_ptr_list_remove(gmPtrList list, void *obj)
Removes all occurrences of a specific pointer from the list.
Definition body_list.h:101
int gm_ptr_list_is_empty(gmPtrList list)
Checks if a pointer list is empty.
Definition body_list.h:46
gmBody ** gmBodies
A specialized pointer list for gmBody pointers.
Definition body_list.h:233
int gm_ptr_list_find(gmPtrList list, void *value)
Finds the index of a specific pointer.
Definition body_list.h:173
size_t gm_ptr_list_count(gmPtrList list, void *obj)
Counts the occurrences of a specific pointer in the list.
Definition body_list.h:56
void * gm_ptr_list_get(gmPtrList list, size_t index)
Retrieves the element at a specific index.
Definition body_list.h:190
Structure representing a physics body with properties for collision and movement.
Definition body.h:19