- Small sets are sometimes represented as collection of bits
- Elements are added using binary-or
pbitvec[j/BITS_PER_LONG] |= ((unsigned long)1 << (j % BITS_PER_LONG));
- Element presence is implemented using binary-and
#define FD_ISSET(n, p) \
((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
- Element removal is implemented using binary-and of the complement
#define FD_CLR(n, p) \
((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
- Set intersection is implemented using binary and
#define XFD_ANDSET(dst,b1,b2) \
(dst)->fds_bits[0] = ((b1)->fds_bits[0] & (b2)->fds_bits[0]); \
- Set union is implemented using binary or
- Larger sets are sometimes represented as an array of
values
resourceQuarks[q >> 3] |= 1 << (q & 0x7);