]> jfr.im git - irc/evilnet/x3.git/blame - rx/rxbitset.h
Fix a misleading comment in x3.conf.example
[irc/evilnet/x3.git] / rx / rxbitset.h
CommitLineData
d76ed9a9 1/* classes: h_files */
2
3#ifndef RXBITSETH
4#define RXBITSETH
5
6/* Copyright (C) 1995, 1996 Tom Lord
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Library General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this software; see the file COPYING. If not, write to
20 * the Free Software Foundation, 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
22 */
23
24\f
25
26
27typedef unsigned long RX_subset;
28#define RX_subset_bits (8 * sizeof (RX_subset))
29#define RX_subset_mask (RX_subset_bits - 1)
30typedef RX_subset * rx_Bitset;
31
32#ifdef __STDC__
33typedef void (*rx_bitset_iterator) (rx_Bitset, int member_index);
34#else
35typedef void (*rx_bitset_iterator) ();
36#endif
37
38/* Return the index of the word containing the Nth bit.
39 */
40#define rx_bitset_subset(N) ((N) / RX_subset_bits)
41
42/* Return the conveniently-sized supset containing the Nth bit.
43 */
44#define rx_bitset_subset_val(B,N) ((B)[rx_bitset_subset(N)])
45
46
47/* Genericly combine the word containing the Nth bit with a 1 bit mask
48 * of the Nth bit position within that word.
49 */
50#define RX_bitset_access(B,N,OP) \
51 ((B)[rx_bitset_subset(N)] OP rx_subset_singletons[(N) & RX_subset_mask])
52
53#define RX_bitset_member(B,N) RX_bitset_access(B, N, &)
54#define RX_bitset_enjoin(B,N) RX_bitset_access(B, N, |=)
55#define RX_bitset_remove(B,N) RX_bitset_access(B, N, &= ~)
56#define RX_bitset_toggle(B,N) RX_bitset_access(B, N, ^= )
57
58/* How many words are needed for N bits?
59 */
60#define rx_bitset_numb_subsets(N) (((N) + RX_subset_bits - 1) / RX_subset_bits)
61
62/* How much memory should be allocated for a bitset with N bits?
63 */
64#define rx_sizeof_bitset(N) (rx_bitset_numb_subsets(N) * sizeof(RX_subset))
65\f
66
67extern RX_subset rx_subset_singletons[];
68
69
70\f
71#ifdef __STDC__
72extern int rx_bitset_is_equal (int size, rx_Bitset a, rx_Bitset b);
73extern int rx_bitset_is_subset (int size, rx_Bitset a, rx_Bitset b);
74extern int rx_bitset_empty (int size, rx_Bitset set);
75extern void rx_bitset_null (int size, rx_Bitset b);
76extern void rx_bitset_universe (int size, rx_Bitset b);
77extern void rx_bitset_complement (int size, rx_Bitset b);
78extern void rx_bitset_assign (int size, rx_Bitset a, rx_Bitset b);
79extern void rx_bitset_union (int size, rx_Bitset a, rx_Bitset b);
80extern void rx_bitset_intersection (int size,
81 rx_Bitset a, rx_Bitset b);
82extern void rx_bitset_difference (int size, rx_Bitset a, rx_Bitset b);
83extern void rx_bitset_revdifference (int size,
84 rx_Bitset a, rx_Bitset b);
85extern void rx_bitset_xor (int size, rx_Bitset a, rx_Bitset b);
86extern unsigned long rx_bitset_hash (int size, rx_Bitset b);
87extern int rx_bitset_population (int size, rx_Bitset a);
88
89#else /* STDC */
90extern int rx_bitset_is_equal ();
91extern int rx_bitset_is_subset ();
92extern int rx_bitset_empty ();
93extern void rx_bitset_null ();
94extern void rx_bitset_universe ();
95extern void rx_bitset_complement ();
96extern void rx_bitset_assign ();
97extern void rx_bitset_union ();
98extern void rx_bitset_intersection ();
99extern void rx_bitset_difference ();
100extern void rx_bitset_revdifference ();
101extern void rx_bitset_xor ();
102extern unsigned long rx_bitset_hash ();
103extern int rx_bitset_population ();
104
105#endif /* STDC */
106
107
108
109#endif /* RXBITSETH */