1 /* IIheap.h */ 2 3 #include "../cfiles.h" 4 5 /*--------------------------------------------------------------------*/ 6 /* 7 ------------------------------------------------------------------ 8 IIheap -- heap with integer ids, integer values and a map from 9 each integer value to a heap location 10 11 size -- present size of the heap 12 maxsize -- maximum size of the heap 13 heapLoc -- heap location of each id, size maxsize 14 keys -- object key of each location in the heap, size maxsize 15 values -- object value of each location in the heap, size maxsize 16 17 created -- 95sep30, cca 18 ------------------------------------------------------------------ 19 */ 20 typedef struct _IIheap IIheap ; 21 struct _IIheap { 22 int size ; 23 int maxsize ; 24 int *heapLoc ; 25 int *keys ; 26 int *values ; 27 } ; 28 /*--------------------------------------------------------------------*/ 29 /* 30 ------------------------------------------------------------------------ 31 --- methods found in basics.c ------------------------------------------ 32 ------------------------------------------------------------------------ 33 */ 34 /* 35 ----------------------------------------------------- 36 create and return a new instance of the IIheap object 37 38 created -- 95sep30, cca 39 ----------------------------------------------------- 40 */ 41 IIheap * 42 IIheap_new ( 43 void 44 ) ; 45 /* 46 ------------------------------------------- 47 set the default fields for an IIheap object 48 49 created -- 95sep30, cca 50 ------------------------------------------- 51 */ 52 void 53 IIheap_setDefaultFields ( 54 IIheap *heap 55 ) ; 56 /* 57 ----------------------- 58 clear the data fields 59 60 created -- 95sep30, cca 61 ----------------------- 62 */ 63 void 64 IIheap_clearData ( 65 IIheap *heap 66 ) ; 67 /* 68 ----------------------- 69 free the IIheap object 70 71 created -- 95sep30, cca 72 ----------------------- 73 */ 74 void 75 IIheap_free ( 76 IIheap *heap 77 ) ; 78 /* 79 -------------------------------- 80 initializer, 81 set heap maximum size to maxsize 82 and allocate the arrays 83 84 created -- 95sep30, cca 85 -------------------------------- 86 */ 87 void 88 IIheap_init ( 89 IIheap *heap, 90 int maxsize 91 ) ; 92 /* 93 ------------------------------------------------ 94 fill pkey with the key and pvalue with the value 95 of the minimum (key, value) pair in the heap 96 97 created -- 95sep30, cca 98 ------------------------------------------------ 99 */ 100 void 101 IIheap_root ( 102 IIheap *heap, 103 int *pkey, 104 int *pvalue 105 ) ; 106 /* 107 ------------------------------------------ 108 insert the (key, value) pair into the heap 109 110 created -- 95sep30, cca 111 ------------------------------------------ 112 */ 113 void 114 IIheap_insert ( 115 IIheap *heap, 116 int key, 117 int value 118 ) ; 119 /* 120 ---------------------------- 121 remove (key,*) from the heap 122 123 created -- 95sep30, cca 124 ---------------------------- 125 */ 126 void 127 IIheap_remove ( 128 IIheap *heap, 129 int key 130 ) ; 131 /* 132 ----------------------------------------------- 133 purpose -- to write the IIheap object to a file 134 135 created -- 95sep30, cca 136 ----------------------------------------------- 137 */ 138 void 139 IIheap_print ( 140 IIheap *heap, 141 FILE *fp 142 ) ; 143 /* 144 ---------------------------------------------- 145 return the number of bytes taken by the object 146 147 created -- 95sep30, cca 148 ---------------------------------------------- 149 */ 150 int 151 IIheap_sizeOf ( 152 IIheap *heap 153 ) ; 154 /*--------------------------------------------------------------------*/ 155