- Added 'termlistFind' function, which is more generic than inTermlist

This commit is contained in:
ccremers 2004-08-27 13:10:46 +00:00
parent d8e0e93bcf
commit dfeaf83327
2 changed files with 22 additions and 0 deletions

View File

@ -133,6 +133,27 @@ inTermlist (Termlist tl, const Term term)
return 0;
}
//! Determine whether a term is an element of a termlist: yield pointer
__inline__ Termlist termlistFind (Termlist tl, const Term term)
{
#ifdef DEBUG
if (term == NULL)
{
error ("Trying to do inTermlist for a NULL term.");
}
#endif
while (tl != NULL)
{
if (isTermEqual (tl->term, term))
{
return tl;
}
tl = tl->next;
}
return NULL;
}
//! Equality of two term lists.
/**
* Are all elements of list 1 in list 2, and vice versa?

View File

@ -29,6 +29,7 @@ void termlistDelete (Termlist tl);
void termlistDestroy (Termlist tl);
void termlistPrint (Termlist tl);
__inline__ int inTermlist (Termlist tl, const Term term);
__inline__ Termlist termlistFind (Termlist tl, const Term term);
int isTermlistEqual (Termlist tl1, Termlist tl2);
Termlist termlistAdd (Termlist tl, Term term);
Termlist termlistAppend (const Termlist tl, const Term term);