#include #include #include #include "graph.h" int compare(const struct point* a, const struct point * b) { if(a->y < b->y) { return -1; } else if(a->y > b->y) { return 1; } if(a->x < b->x) { return -1; } else if(a->x > b->x) { return 1; } return 0; } @implementation Graph + new { self = [super new]; return self; } - init { graph = NULL; count = 0; } - free { free(graph); return [super free]; } - add: (int)Horiz: (int)Vert { if(graph) { graph = realloc(graph,sizeof(graph[0]) * (count+1)); } else { graph = malloc(sizeof(graph[0])); } graph[count].x = Horiz; graph[count].y = Vert; count++; return self; } /* - draw { int i; [self sort]; for(i=0;i