home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / unix / dgrep.arc / SET.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-14  |  1.0 KB  |  47 lines

  1. /**********************************************************************\
  2.  *
  3.  *    SET.C
  4.  *
  5.  * Set routines.
  6.  *
  7.  * Author: Jarmo Ruuth 15-Mar-1988
  8.  *
  9.  * Copyright (C) 1988-90 by Jarmo Ruuth
  10.  * May be freely copied for any non-commercial usage.
  11. \**********************************************************************/
  12.  
  13. #include "system.h"
  14. #include "set.h"
  15.  
  16. /**********************************************************************
  17.  *
  18.  *    set_empty
  19.  */
  20. bool set_empty(REG1 set_t* set, int setsize)
  21. {
  22.     REG2 int    i = setsize/sizeof(set_t) - 1;
  23.     
  24.     for (set += i; i >= 0; i--, set--)
  25.         if (*set)
  26.             return FALSE;
  27.     return TRUE;
  28. }
  29.  
  30. /**********************************************************************
  31.  *
  32.  *    set_union
  33.  *
  34.  * Union of two sets.
  35.  */
  36. void set_union(REG1 set_t* result, REG3 set_t* set1, REG4 set_t* set2,
  37.            int setsize)
  38. {
  39.     REG2 int    i = setsize/sizeof(set_t) - 1;
  40.     
  41.     result += i;
  42.     set1 += i;
  43.     set2 += i;
  44.     for (; i >= 0; i--, result--, set1--, set2--)
  45.         *result = *set1 | *set2;
  46. }
  47.