all queue has become vector
This commit is contained in:
parent
5ccabd2791
commit
6a265e23b7
1 changed files with 3 additions and 5 deletions
|
@ -2,10 +2,10 @@
|
|||
#include <stdlib.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
|
||||
|
||||
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;
|
||||
}
|
Reference in a new issue