diff --git a/collections/queue.c b/collections/vector.c similarity index 88% rename from collections/queue.c rename to collections/vector.c index d289acd..c9f9f24 100644 --- a/collections/queue.c +++ b/collections/vector.c @@ -2,10 +2,10 @@ #include #include -// Type for queue, change to the desired type to be used in the queue +// Type for vector, change to the desired type to be used in the vector #define VECTOR_TYPE int -typedef struct queue { +typedef struct vector { size_t length; VECTOR_TYPE* arr; size_t start; @@ -49,9 +49,7 @@ bool vector_remove(vector_t* self, VECTOR_TYPE* destination, bool from_end) { } *destination = self->arr[!from_end ? vector_end(self) : self->start]; - if (from_end) { - self->start = (self->start + 1) % self->length; - } + self->start = from_end ? (self->start + 1) % self->length : self->start; self->size--; return true; }