|
|
1.1 root 1: #import <objc/Object.h>
2: #import "SortController.h"
3: #import <stdlib.h>
4: #import <mach/message.h>
5:
6: #define MAXDATA 5 /* Message struct used to send drawing messages */
7: typedef struct {
8: msg_header_t h;
9: msg_type_t t;
10: int sortNum; /* unique integer to identify the sort */
11: int position[2]; /* positions of the elements */
12: int value[2]; /* values of the elements */
13: } simpleMsg;
14:
15: #define SORTING_MSG 0 /* Constants to identify the different messages */
16: #define COMPARE_MSG 1
17: #define SWAP_MSG 2
18: #define MOVE_MSG 3
19: #define FINISHED_MSG 4
20:
21:
22: @interface GenericSort:Object
23: {
24: char *sortName; /* name of this sort */
25: int sortNum; /* unique integer for this sort */
26: id sortView; /* custom view to draw in */
27: int numElements, *data; /* size and array of data set */
28: int compares, moves, fcalls; /* counters for different operations */
29: int compareVal, moveVal, fcallVal; /* tick values for sort operations */
30: int speedDelay; /* mseconds delay between operations */
31: BOOL animate; /* should sort highlight compares? */
32: simpleMsg drawMsg; /* message to send to draw sort */
33: }
34:
35: + initialize;
36: - init;
37:
38: /* TARGET-ACTION METHODS */
39: - setSize:(int)size address:(int*)address;
40: - setTicks:(int)value for:(int)tag;
41: - setAnimate:(BOOL)value;
42: - setSpeed:(int)value;
43:
44: /* PRIVATE METHODS */
45: - (BOOL)lessThan:(int)position1 :(int)position2;
46: - swap:(int)position1 with:(int)position2;
47: - moveValue:(int)value to:(int)position;
48: - sortDone;
49: - adjust;
50: - abort;
51:
52: /* PUBLIC METHODS */
53: - sort;
54: - (const char*)getName;
55: - view;
56: - (int)compares;
57: - (int)moves;
58: - (int)fcalls;
59: - (int)totalTicks;
60:
61: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.