[common] vector: implement item removal

This commit is contained in:
Quantum authored and Geoffrey McRae committed 2021-08-30 18:21:54 +10:00
1 parent bbd39b8185
commit f0beedb5ba
2 files changed
+11

No files matched your search

+10
View File
@@ -99,6 +99,16 @@ void vector_pop(Vector * vector)
--vector->size;
}
void vector_remove(Vector * vector, size_t index)
{
DEBUG_ASSERT(index < vector->size && "Attempting to remove non-existent index!");
memmove((char *)vector->data + index * vector->itemSize,
(char *)vector->data + (index + 1) * vector->itemSize,
(vector->size - index - 1) * vector->itemSize
);
--vector->size;
}
void vector_at(Vector * vector, size_t index, void * data)
{
DEBUG_ASSERT(index < vector->size && "Out of bounds access");