mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[common] vector: inline common operations
This commit is contained in:
parent
ceff9dca9b
commit
ba527761ef
@ -34,10 +34,18 @@ Vector;
|
||||
Vector * vector_create(size_t itemSize, size_t capacity);
|
||||
void vector_free(Vector * vector);
|
||||
|
||||
inline static size_t vector_size(Vector * vector)
|
||||
{
|
||||
return vector->size;
|
||||
}
|
||||
|
||||
inline static void * vector_data(Vector * vector)
|
||||
{
|
||||
return vector->data;
|
||||
}
|
||||
|
||||
void * vector_push(Vector * vector, void * item);
|
||||
void vector_pop(Vector * vector);
|
||||
size_t vector_size(Vector * vector);
|
||||
void * vector_data(Vector * vector);
|
||||
void vector_at(Vector * vector, size_t index, void * data);
|
||||
void * vector_ptrTo(Vector * vector, size_t index);
|
||||
void vector_clear(Vector * vector);
|
||||
@ -59,7 +67,6 @@ void vector_clear(Vector * vector);
|
||||
index < (vector)->size ? vector_at((vector), index, &(name)), true : false; \
|
||||
++index)
|
||||
|
||||
|
||||
#define vector_forEachRefIdx(index, name, vector) \
|
||||
for (size_t index = 0; \
|
||||
index < (vector)->size ? (name) = vector_ptrTo((vector), index), true : false; \
|
||||
|
@ -82,16 +82,6 @@ void vector_pop(Vector * vector)
|
||||
--vector->size;
|
||||
}
|
||||
|
||||
size_t vector_size(Vector * vector)
|
||||
{
|
||||
return vector->size;
|
||||
}
|
||||
|
||||
void * vector_data(Vector * vector)
|
||||
{
|
||||
return vector->data;
|
||||
}
|
||||
|
||||
void vector_at(Vector * vector, size_t index, void * data)
|
||||
{
|
||||
DEBUG_ASSERT(index < vector->size && "Out of bounds access");
|
||||
|
Loading…
Reference in New Issue
Block a user