|
|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
#include "list.h"
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include "../sprite.h"
|
|
|
|
|
|
|
|
|
|
Node * ListCreateNode(int *data){
|
|
|
|
|
Node * ListCreateNode(Sprite *data){
|
|
|
|
|
Node *new = (Node *) malloc(sizeof(Node));
|
|
|
|
|
new->data = *data;
|
|
|
|
|
return new;
|
|
|
|
|
@ -11,16 +12,16 @@ Node * ListCreateNode(int *data){
|
|
|
|
|
void ListPrintForward(List *list){
|
|
|
|
|
Node *current = list->head;
|
|
|
|
|
|
|
|
|
|
printf("\n[");
|
|
|
|
|
printf("\n[\n");
|
|
|
|
|
while(current != 0){
|
|
|
|
|
printf("%d,", current->data);
|
|
|
|
|
printf("(%f | %f),\n", current->data.x, current->data.y);
|
|
|
|
|
current = current->next;
|
|
|
|
|
}
|
|
|
|
|
printf("]\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ListInsertFront(List *list, int data){
|
|
|
|
|
Node *new = ListCreateNode(&data);
|
|
|
|
|
void ListInsertFront(List *list, Sprite *data){
|
|
|
|
|
Node *new = ListCreateNode(data);
|
|
|
|
|
|
|
|
|
|
if(list->head == 0){
|
|
|
|
|
list->head = new;
|
|
|
|
|
@ -38,8 +39,8 @@ void ListInsertFront(List *list, int data){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ListInsertBack(List *list, int data){
|
|
|
|
|
Node *new = ListCreateNode(&data);
|
|
|
|
|
void ListInsertBack(List *list, Sprite *data){
|
|
|
|
|
Node *new = ListCreateNode(data);
|
|
|
|
|
|
|
|
|
|
if(list->head == 0){
|
|
|
|
|
list->head = new;
|
|
|
|
|
@ -56,3 +57,10 @@ void ListInsertBack(List *list, int data){
|
|
|
|
|
list->tail = new;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List * ListInit(){
|
|
|
|
|
List *newList = (List *) malloc(sizeof(List));
|
|
|
|
|
newList->head = 0;
|
|
|
|
|
newList->tail = 0;
|
|
|
|
|
return newList;
|
|
|
|
|
}
|
|
|
|
|
|