#ifndef _QUEUEH
#define _QUEUEH

#include "transmng.h"

typedef struct Q_item *Q_item_ptr;
struct Q_item{
  T_Transaction *item;      // the item is a pointer to a transaction
  Q_item_ptr next;      // next item in the list
  Q_item_ptr prev;      // previous item in the list
};

typedef struct T_Queue *T_Queue_ptr;

struct T_Queue {
  Q_item_ptr first;
  Q_item_ptr last;
};

T_Queue_ptr Q_create();
bool Q_isEmpty(T_Queue_ptr);
void Q_print(T_Queue_ptr);
void Q_printR(T_Queue_ptr);
void Q_insert(T_Queue_ptr, T_Transaction*);
void Q_insertFirst(T_Queue_ptr, T_Transaction *);
void Q_reschedule(T_Queue_ptr, T_Tid);
void Q_insertQuery(T_Queue_ptr, T_Transaction *);
T_Transaction* Q_getAndRemove(T_Queue_ptr, T_Tid);
T_Transaction* Q_getFirst(T_Queue_ptr);
void Q_remove(T_Queue_ptr);
// T_Transaction* Q_extractByCC(T_Queue_ptr, C_set);

#endif
