- Moved roledef_shift to role.c

This commit is contained in:
ccremers 2004-08-12 11:22:49 +00:00
parent fe960cfb6a
commit 1791699c01
3 changed files with 32 additions and 12 deletions

View File

@ -80,18 +80,6 @@ mgu_iterate (const Termlist tl)
return iterate ();
}
//! Yield roledef pointer for a given index
Roledef
roledef_shift (Roledef rd, int i)
{
while (i > 0 && rd != NULL)
{
rd = rd->next;
i--;
}
return rd;
}
//------------------------------------------------------------------------
// Sub
//------------------------------------------------------------------------

View File

@ -255,3 +255,33 @@ roledef_iterate_events (Roledef rd, int (*func) ())
}
return 1;
}
//! Roledef length
/**
* Would be faster hard-coded,
* but this just shows the use of the iteration.
*/
int
roledef_length (const Roledef rd)
{
int count = 0;
int countplus (Roledef rd)
{
count++;
return 1;
}
roledef_iterate_events (rd, countplus);
return count;
}
//! Yield roledef pointer for a given index
Roledef
roledef_shift (Roledef rd, int i)
{
while (i > 0 && rd != NULL)
{
rd = rd->next;
i--;
}
return rd;
}

View File

@ -127,5 +127,7 @@ Role roleCreate (Term nameterm);
void rolePrint (Role r);
void rolesPrint (Role r);
int roledef_iterate_events (Roledef rd, int (*func) ());
int roledef_length (const Roledef rd);
Roledef roledef_shift (Roledef rd, int i);
#endif