Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- #include <string.h>
- #include "linkedlist.h"
- struct linkedList
- {
- char *data;
- int key;
- int left;
- int right;
- int size;
- };
- LinkedList createLinkedList(int size)
- {
- LinkedList newLL = malloc(sizeof *newLL);
- newLL->data = malloc(sizeof(int) * (size+1));
- newLL->size = size;
- newLL->left = 0;
- newLL->right = 0;
- return newLL;
- }
- bool isFull(LinkedList LL)
- {
- return abs(abs(LL->left)- abs(LL->right)) == LL->size;
- }
- void insertFront(LinkedList LL, const char * newInfo)
- {
- if(isFull(LL))
- {
- printf("FULL");
- exit(1);
- }
- LL->data[((--(LL->left) % LL->size) + LL->size) % LL->size] = newInfo;
- }
- bool isEmpty(LinkedList LL)
- {
- return LL->left == LL->right;
- }
- const char * removeEnd(LinkedList LL)
- {
- if(isEmpty(LL))
- {
- const char * statement;
- statement = "EMPTY";
- return statement;
- }
- return LL->data[((--(LL->right) % LL->size) + LL->size) % LL->size];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement