C Interfaces and Implementations: Techniques for Creating Reusable Software
by David R. Hanson - Princeton University
Chapter 13. Bit Vectors
The sets described in Chapter 9 can hold arbitrary elements because the elements are manipulated only by functions supplied by clients. Sets of integers are less flexible, but they’re used often enough to warrant a separate ADT. The Bit interface exports functions that manipulate bit vectors, which can be used to represent sets of integers from zero to N−1. For example, 256-bit vectors can be used to represent sets of characters efficiently.
Bit provides most of the set-manipulation functions provided by Set, and also a few functions that are specific to bit vectors. Unlike the sets provided by Set, the sets represented by bit vectors have a well-defined universe, which is the set of integers in the range zero to N−1. Thus, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access