Subversion Repositories PlanixRsrch.SVN

Compare Revisions

Ignore whitespace Rev 448 → Rev 449

/trunk/libmavl/mavl_get_ext.c
0,0 → 1,49
#include "mavl.h"
 
 
 
void * mavl_get_ext(struct mavl *t ,const void *search, int mode)
{
struct mavlnode *n,/**lastl,*/*last;
last = NULL; /*lastl=NULL;*/
n = t->root;
while(n){
int rc;
rc = t->cmp(search,mavlnode_dataptr(n));
/*printf("Compare: %s %s = %d\n",c1->key,c2->key, rc);*/
if (rc==0){
return mavlnode_dataptr(n);
}
if (rc<0){
if (mode == MAVL_FIND_FIRST)
last = n;
if (n->s[0]==NULL){
if (last == NULL)
return NULL;
return mavlnode_dataptr(last);
}
n=n->s[0];
}
else{
if (mode == MAVL_FIND_LAST)
last=n;
if(n->s[1]==NULL){
if (last == NULL)
return NULL;
return mavlnode_dataptr(last);
}
n=n->s[1];
}
}
return NULL;
}