G2A Many GEOs
SHARE
TWEET

Untitled

a guest Jun 1st, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void queue_insert(queue *q, data v) {
  2.     q->rear = (q->rear + 1) % q->capacity;
  3.     if (q->size == q->rear) {
  4.         q->capacity <<= 1; // double the capacity of the circular queue
  5.         q->values = realloc(q->values, sizeof(data) * q->capacity);
  6.     }
  7.     q->values[q->rear] = v;
  8.     q->size++;
  9.     return;
  10. }
  11. the queue is a circular queue. Here is the structure:
  12. typedef struct {
  13.     unsigned int capacity; ///< current capacity of the queue.
  14.     int front; ///< index of front element of the queue.
  15.     int rear; ///< index of next rear element of the queue.
  16.     int size; ///< count of number of values in the queue.
  17.     data *values; ///< array of data values.
  18. } queue;
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top