flag.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /** idea by Michael Shapiro
  2. ** code by Chuck Ehlschlaeger
  3. ** April 03, 1989
  4. */
  5. #include <stdio.h>
  6. #define FLAG struct _f_l_a_g_
  7. FLAG {
  8. int nrows, ncols, leng;
  9. unsigned char **array;
  10. };
  11. #define FLAG_UNSET(flags,row,col) \
  12. (flags)->array[(row)][(col)>>3] &= ~(1<<((col) & 7))
  13. #define FLAG_SET(flags,row,col) \
  14. (flags)->array[(row)][(col)>>3] |= (1<<((col) & 7))
  15. #define FLAG_GET(flags,row,col) \
  16. (flags)->array[(row)][(col)>>3] & (1<<((col) & 7))
  17. /* flag.[ch] is a set of routines which will set up an array of bits
  18. ** that allow the programmer to "flag" cells in a raster map.
  19. **/
  20. FLAG *FlagCreate(int nrows, int ncols);
  21. /** opens the structure flag.
  22. ** The flag structure will be a two dimensional array of bits the
  23. ** size of nrows by ncols. Will initalize flags to zero (unset).
  24. **/
  25. void FlagDestroy(FLAG * flags);
  26. /** closes flags and gives the memory back to the system.
  27. **/
  28. void FlagClearAll(FLAG * flags);
  29. /** sets all values in flags to zero.
  30. **/
  31. void FlagUnset(FLAG * flags, int row, int col);
  32. /** sets the value of (row, col) in flags to zero.
  33. **/
  34. void FlagSet(FLAG * flags, int row, int col);
  35. /** will set the value of (row, col) in flags to one.
  36. **/
  37. int FlagGet(FLAG * flags, int row, int col);
  38. /** returns the value in flags that is at (row, col).
  39. **/