From 1791699c0123acfddf75c336c638912ce162048e Mon Sep 17 00:00:00 2001 From: ccremers Date: Thu, 12 Aug 2004 11:22:49 +0000 Subject: [PATCH] - Moved roledef_shift to role.c --- src/arachne.c | 12 ------------ src/role.c | 30 ++++++++++++++++++++++++++++++ src/role.h | 2 ++ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/arachne.c b/src/arachne.c index 9560f43..0e3a843 100644 --- a/src/arachne.c +++ b/src/arachne.c @@ -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 //------------------------------------------------------------------------ diff --git a/src/role.c b/src/role.c index 926ff96..6871c4c 100644 --- a/src/role.c +++ b/src/role.c @@ -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; +} diff --git a/src/role.h b/src/role.h index f4a3ff5..9e9da5c 100644 --- a/src/role.h +++ b/src/role.h @@ -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