diff --git a/src/collections/List.h b/src/collections/List.h index 545fe7f..4bdabab 100644 --- a/src/collections/List.h +++ b/src/collections/List.h @@ -20,6 +20,7 @@ T* List_##T##_expand(List_##T* ptr, u32 count);\ void List_##T##_push(List_##T* ptr, T value);\ void List_##T##_pushMany(List_##T* ptr, T* values, u32 count);\ + bool List_##T##_tryRemoveAt(List_##T* ptr, u32 i);\ #define List_define(T)\ @@ -52,6 +53,17 @@ T* empty_cell_ptr = List_##T##_expand(ptr, count);\ memcpy(empty_cell_ptr, values, count * sizeof(T));\ }\ + \ + bool List_##T##_tryRemoveAt(List_##T* ptr, u32 i){\ + if(ptr->len == 0 || i >= ptr->len)\ + return false;\ + \ + ptr->len--;\ + for(; i < ptr->len; i++){\ + ptr->data[i] = ptr->data[i + 1];\ + }\ + return true;\ + }\ List_declare(u32);