PROGRAM:=main
-OBJS:=sokoban.o coord.o object.o
+OBJS:=sokoban.o coord.o object.o deque.o
CFLAGS:=-O3 -Wextra -Wall -Werror -fno-strict-aliasing -std=gnu11\
-I./sylvan/src
--- /dev/null
+#include <argp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sylvan.h>
+#include <lace.h>
+
+#include "deque.h"
+
+deque *create()
+{
+ deque *d;
+ d = (deque *)malloc(sizeof(deque));
+ d->front = NULL;
+ d->rear = NULL;
+ d->count = 0;
+
+ return d;
+}
+
+deque *enq(state_t *s, deque *d)
+{
+ if (d->rear == NULL){
+ d->rear = (node_t *)malloc(sizeof(node_t));
+ d->rear->ptr = NULL;
+ d->rear->s = s;
+ d->front = d->rear;
+ }
+ else {
+ node_t *temp = (node_t *)malloc(sizeof(node_t));
+ d->rear->ptr = temp;
+ temp->s = s;
+ temp->ptr = NULL;
+ d->rear = temp;
+ }
+ d->count++;
+
+ return d;
+}
+
+deque *deq(deque *d)
+{
+ node_t *front_tmp = d->front;
+
+ if (front_tmp != NULL){
+ front_tmp = front_tmp->ptr;
+ d->front = front_tmp;
+ }
+ else if (front_tmp != NULL) {
+ d->front = NULL;
+ d->rear = NULL;
+ }
+ d->count--;
+ return d;
+}
+
+int isEmpty(deque *d)
+{
+ if (d->front != NULL && d->rear != NULL) return 1;
+ else return 0;
+}
+
+state_t *get_front(deque *d)
+{
+ if (isEmpty(d) == 1) return d->front->s;
+ else return NULL;
+}
--- /dev/null
+#ifndef DEQUE_H
+#define DEQUE_H
+#include <stdio.h>
+#include <stdbool.h>
+#include "coord.h"
+
+typedef struct node {
+ state_t *s;
+ struct node *ptr;
+} node_t;
+
+typedef struct {
+ node_t *front;
+ node_t *rear;
+ int count;
+} deque;
+
+deque *create();
+
+deque *enq(state_t *s, deque *d);
+
+deque *deq(deque *d);
+
+int isEmpty(deque *d);
+
+state_t *get_front(deque *d);
+
+#endif