Repositories » libk0
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

trivial

Changeset 6c3badebc057

Parent 3cf5d2bdac57

by Rup Palchowdhury

Changes to one file · Browse files at 6c3badebc057 Showing diff from parent 3cf5d2bdac57 Diff from another changeset...

Change 1 of 3 Show Entire File test.c Stacked
 
12
13
14
15
16
 
17
18
19
20
 
21
22
23
 
50
51
52
53
 
54
55
56
57
 
 
58
59
60
 
76
77
78
79
80
81
82
83
84
 
 
 
 
 
 
 
 
85
86
87
88
 
 
 
89
90
91
92
 
 
 
93
94
95
96
 
 
 
 
 
97
98
99
 
12
13
14
 
 
15
16
17
18
19
20
21
22
23
 
50
51
52
 
53
54
55
56
 
57
58
59
60
61
 
77
78
79
 
 
 
 
 
 
80
81
82
83
84
85
86
87
88
 
 
 
89
90
91
92
 
 
 
93
94
95
96
 
 
 
97
98
99
100
101
102
103
104
@@ -12,12 +12,12 @@
  "i", "c", "e", "h", "h"};   char w[6][4] = {"cat", "mat", "bat", "hat", "rat", "sat"};   int i, c; - Node *lt, *n, *np; - TNode *t, *t_; + Node *np;   Post *pp;     /* hash table test */   + /*   const int NHASH = 3;   Node *htab[NHASH];   for (i = 0; i < NHASH; i++) @@ -50,11 +50,12 @@
  }   else   printf("Not found\n"); - + */     /* tree test */   /* - TNode *found; + TNode *t, *t_, *found; +   t = NULL;   for (i = 0; i < NUMNODES; i++)   t = nrinsert(t, newtnode(newpost(s[i], 1)), @@ -76,24 +77,28 @@
    /* list test */   - /* n = newnode((void *)newpost(s[1], 1)); */ - /* lt = newnode((void *)newpost(s[0], 0)); */ - /* for (i = 1; i < 3; i++) */ - /* lt = addfront(lt, newnode((void *)newpost(s[i], i))); */ - /* apply(lt, printpost, "%s %f\n"); */ - /* printf("\n"); */ + Node *lt, *n, *tmp; + + n = newnode((void *)newpost(s[1], 1)); + lt = newnode((void *)newpost(s[0], 0)); + for (i = 1; i < 3; i++) + lt = addfront(lt, newnode((void *)newpost(s[i], i))); + apply(lt, printpost, "%s %f\n"); + printf("\n");   - /* addend(lt, newnode((void *)newpost(s[3], 3))); */ - /* apply(lt, printpost, "%s %f\n"); */ - /* printf("\n"); */ + addend(lt, newnode((void *)newpost(s[3], 3))); + apply(lt, printpost, "%s %f\n"); + printf("\n");   - /* tmp = lookup(lt, n, postcmp); */ - /* printpost(tmp->data, "%s %f\n"); */ - /* printf("\n"); */ + tmp = lookup(lt, n, postcmp); + printpost(tmp->data, "%s %f\n"); + printf("\n");   - /* delnode(lt, n, postcmp, freepost); */ - /* apply(lt, printpost, "%s %f\n"); */ - /* printf("\n"); */ + delnode(lt, n, postcmp, freepost); + apply(lt, printpost, "%s %f\n"); + printf("\n"); + + freelist(lt, NULL);     return 0;  }