From 6a265e23b7d3163ff9e43871b11aaaf1a279a32c Mon Sep 17 00:00:00 2001 From: tommi27 Date: Sun, 1 Sep 2019 17:50:45 +0200 Subject: [PATCH] all queue has become vector --- collections/{queue.c => vector.c} | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) rename collections/{queue.c => vector.c} (88%) 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; }