MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / splay_delete

Function splay_delete

libCacheSim/dataStructure/splay.c:195–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195sTree * splay_delete(key_type i, sTree * t) {
196 /* Deletes i from the sTree if it's there. */
197 /* Return a pointer to the resulting sTree. */
198 sTree * x;
199 if (t==NULL) return NULL;
200 long root_value = t->value;
201 t = splay(i,t);
202 if (key_cmp(i, t->key) == 0) { /* found it */
203 if (t->left == NULL) {
204 x = t->right;
205 } else {
206 x = splay(i, t->left); // i is the largest element in left sub sTree,
207 // so the new splay sTree does not have right sub sTree
208 x->right = t->right;
209 }
210 free_node(t);
211 if (x != NULL) {
212 x->value = root_value-1;
213 }
214 return x;
215 }
216 return t; /* It wasn't there */
217}
218
219
220//sTree *find_node(key_type e, sTree *t) {

Callers 2

get_stack_dist_add_reqFunction · 0.85

Calls 2

splayFunction · 0.85
free_nodeFunction · 0.85

Tested by

no test coverage detected