File: flag.h

package info (click to toggle)
grass 8.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 277,040 kB
  • sloc: ansic: 460,798; python: 227,732; cpp: 42,026; sh: 11,262; makefile: 7,007; xml: 3,637; sql: 968; lex: 520; javascript: 484; yacc: 450; asm: 387; perl: 157; sed: 25; objc: 6; ruby: 4
file content (63 lines) | stat: -rw-r--r-- 1,588 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef __FLAG_H__
#define __FLAG_H__

/* flag.[ch] is a set of routines which will set up an array of bits
 ** that allow the programmer to "flag" cells in a raster map.
 **
 ** FLAG *
 ** flag_create(nrows,ncols)
 ** int nrows, ncols;
 **     opens the structure flag.
 **     The flag structure will be a two dimensional array of bits the
 **     size of nrows by ncols.  Will initialize flags to zero (unset).
 **
 ** flag_destroy(flags)
 ** FLAG *flags;
 **     closes flags and gives the memory back to the system.
 **
 ** flag_clear_all(flags)
 ** FLAG *flags;
 **     sets all values in flags to zero.
 **
 ** flag_unset(flags, row, col)
 ** FLAG *flags;
 ** int row, col;
 **     sets the value of (row, col) in flags to zero.
 **
 ** flag_set(flags, row, col)
 ** FLAG *flags;
 ** int row, col;
 **     will set the value of (row, col) in flags to one.
 **
 ** int
 ** flag_get(flags, row, col)
 ** FLAG *flags;
 ** int row, col;
 **     returns the value in flags that is at (row, col).
 **
 ** idea by Michael Shapiro
 ** code by Chuck Ehlschlaeger
 ** April 03, 1989
 */
#define FLAG struct _flagsss_
FLAG
{
    int nrows, ncols, leng;
    unsigned char **array;
};

#define FLAG_UNSET(flags, row, col) \
    (flags)->array[(row)][(col) >> 3] &= ~(1 << ((col)&7))

#define FLAG_SET(flags, row, col) \
    (flags)->array[(row)][(col) >> 3] |= (1 << ((col)&7))

#define FLAG_GET(flags, row, col) \
    (flags)->array[(row)][(col) >> 3] & (1 << ((col)&7))

/* flag.c */
FLAG *flag_create(int, int);
int flag_destroy(FLAG *);
int flag_clear_all(FLAG *);

#endif /* __FLAG_H__ */