home *** CD-ROM | disk | FTP | other *** search
- #import <objc/Object.h>
- #import "SortController.h"
- #import <stdlib.h>
- #import <mach/message.h>
-
- #define MAXDATA 5 /* Message struct used to send drawing messages */
- typedef struct {
- msg_header_t h;
- msg_type_t t;
- int sortNum; /* unique integer to identify the sort */
- int position[2]; /* positions of the elements */
- int value[2]; /* values of the elements */
- } simpleMsg;
-
- #define SORTING_MSG 0 /* Constants to identify the different messages */
- #define COMPARE_MSG 1
- #define SWAP_MSG 2
- #define MOVE_MSG 3
- #define FINISHED_MSG 4
-
-
- @interface GenericSort:Object
- {
- char *sortName; /* name of this sort */
- int sortNum; /* unique integer for this sort */
- id sortView; /* custom view to draw in */
- int numElements, *data; /* size and array of data set */
- int compares, moves, fcalls; /* counters for different operations */
- int compareVal, moveVal, fcallVal; /* tick values for sort operations */
- int speedDelay; /* mseconds delay between operations */
- BOOL animate; /* should sort highlight compares? */
- simpleMsg drawMsg; /* message to send to draw sort */
- }
-
- + initialize;
- - init;
-
- /* TARGET-ACTION METHODS */
- - setSize:(int)size address:(int*)address;
- - setTicks:(int)value for:(int)tag;
- - setAnimate:(BOOL)value;
- - setSpeed:(int)value;
-
- /* PRIVATE METHODS */
- - (BOOL)lessThan:(int)position1 :(int)position2;
- - swap:(int)position1 with:(int)position2;
- - moveValue:(int)value to:(int)position;
- - sortDone;
- - adjust;
- - abort;
-
- /* PUBLIC METHODS */
- - sort;
- - (const char*)getName;
- - view;
- - (int)compares;
- - (int)moves;
- - (int)fcalls;
- - (int)totalTicks;
-
- @end