#ident "$URL: svn://elmer/devel/SVN/SDDAS/trunk/libant/StrHierApply.c $ %D% SwRI" /* StrHierApply -- apply functions to StrHier nodes */ #include "StrHier.h" /* for StrHier type */ /* StrHierApplyPre -- apply function to each node in StrHier,preorder */ void StrHierApplyPre( StrHier h, StrHierFun f) { LinkList children = StrHierChildren(h); /* apply to node */ f(h); /* apply to children */ for (; children; children = children->next) StrHierApplyPre(StrHierOnList(children),f); } /* StrHierApplyToLeaves -- apply function to leaves of StrHier */ void StrHierApplyToLeaves( StrHier h, StrHierFun f) { LinkList children = StrHierChildren(h); if (!SUBLIST(h)) /* apply to node */ f(h); else /* visit children */ for (; children; children = children->next) StrHierApplyToLeaves(StrHierOnList(children),f); }