home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume27 / clc / part01 / libs / src / pset / ops.c
Encoding:
C/C++ Source or Header  |  1993-11-28  |  946 b   |  51 lines

  1. /*
  2.  * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7. static char RCSid[] = "$Id: ops.c,v 3.2 93/11/23 19:49:05 panos Exp $" ;
  8.  
  9. #include "pset.h"
  10.  
  11. #define PRIVATE                static
  12.  
  13. #ifndef NULL
  14. #define NULL                    0
  15. #endif
  16.  
  17.  
  18. /*
  19.  * Remove all NULL pointers from a pset
  20.  */
  21. void pset_compact( pset )
  22.     register pset_h pset ;
  23. {
  24.     register unsigned u ;
  25.  
  26.     for ( u = 0 ; u < pset_count( pset ) ; )
  27.         if ( pset_pointer( pset, u ) != NULL )
  28.             u++ ;
  29.         else
  30.             pset_remove_index( pset, u ) ;
  31. }
  32.  
  33.  
  34. /*
  35.  * Apply a function to all pointers of a pset
  36.  */
  37. void pset_apply( pset, func, arg )
  38.     register pset_h            pset ;
  39.     register void                (*func)() ;
  40.     register __pset_pointer arg ;
  41. {
  42.     register unsigned u ;
  43.  
  44.     for ( u = 0 ; u < pset_count( pset ) ; u++ )
  45.         if ( arg )
  46.             (*func)( arg, pset_pointer( pset, u ) ) ;
  47.         else
  48.             (*func)( pset_pointer( pset, u ) ) ;
  49. }
  50.  
  51.