A set is a collection of elements in which the same element does not appear more than once. For example, {A, B, C} is a set, but {A, B, C, A} is not. Unlike a list (Section 5.3), a set does not have any particular ordering: a given element either is or is not a member of the set. Thus, {A, B, C} and {C, B, A} are the same set.
Almost every large program makes use of sets. In this chapter, we present a Set interface (Section 11.1) and three implementations: ordered lists (Section 11.2), binary search trees (Section 11.3), and hash tables (Section 11.4). In Section 11.5, we revisit the Java collections framework, discussing Java's own Set interface, some built-in implementations, and the related Map interface.
Part I: Object-Oriented Programming
Encapsulation
Polymorphism
Inheritance
Part II: Linear Structures
Stacks and Queues
Array-Based Structures
Linked Structures
Part III: Algorithms
Analysis of Algorithms
Searching and Sorting
Recursion
Part IV: Trees and Sets
Trees
Sets
Part V: Advanced Topics
Advanced Linear Structures
Strings
Advanced Trees
Graphs
Memory Management
Out to the Disk
Part VI: Appendices
A. Review of Java
B. Unified Modeling Language
C. Summation Formulae
D. Further Reading
Index