Page 186 - ARM 64 Bit Assembly Language
P. 186
Abstract data types 173
204 wordlistnode *newword;
205 wordlistnode *wlst = wln_lookup(list->root,word);
206 if((wlst == NULL)||(strcmp(wlst->word, word) != 0))
207 { /* create a new node */
208 list->nwords++;
209 newword = wln_alloc(word);
210 list->root = wln_insert(list->root,newword);
211 }
212 else
213 wlst->count++;
214 }
215
216 /**********************************************************/
217 /* wln_print is an interal functino to print a table */
218 /* showing the number of occurrences for each word, */
219 /* followed by the word. */
220 void wln_print(wordlistnode *list)
221 {
222 if(list != NULL)
223 {
224 wln_print(list->left);
225 printf("%10d ’%s’\n",list->count,list->word);
226 wln_print(list->right);
227 }
228 }
229
230 /**********************************************************/
231 /* wl_print_alphabetical prints a table showing the number*/
232 /* of occurrences for each word, followed by the word. */
233 void wl_print(wordlist *list)
234 {
235 wln_print(list->root);
236 printf("There are %d unique words in the document\n",
237 list->nwords);
238 }
239
240 #ifndef USE_ASM
241 /**********************************************************/
242 /* wl_print_numerical prints a table showing the number */
243 /* of occurrences for each word, followed by the word, */
244 /* sorted in reverse order of occurence. */
245 void wl_print_numerical(wordlist *list)
246 {
247 printf("wl_print_numerical has not been implemented\n");
248 }
249 #endif