all queue has become vector

This commit is contained in:
Tommaso Rodolfo Masera 2019-09-01 17:50:45 +02:00
parent 5ccabd2791
commit 6a265e23b7

View file

@ -2,10 +2,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
// 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 #define VECTOR_TYPE int
typedef struct queue { typedef struct vector {
size_t length; size_t length;
VECTOR_TYPE* arr; VECTOR_TYPE* arr;
size_t start; 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]; *destination = self->arr[!from_end ? vector_end(self) : self->start];
if (from_end) { self->start = from_end ? (self->start + 1) % self->length : self->start;
self->start = (self->start + 1) % self->length;
}
self->size--; self->size--;
return true; return true;
} }