Summary
This lesson lists the important interfaces and classes of the Collections Framework.
We'll cover the following...
Set | |
---|---|
EnumSet | An EnumSet is a specialized Set collection to work with enum classes. EnumSet should always be preferred over any other Set implementation when we are storing enum values. All of the elements in an enum set must come from a single enum type that is specified, explicitly or implicitly, when the set is created. Enum sets are represented internally as bit vectors. EnumSet is a public abstract class that contains multiple static factory methods that allow us to create instances. There are two implementations:
Example
|
HashSet | This class implements the Set interface, backed by a hash table (actually a HashMap instance). It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time. This class permits the null element. |
LinkedHashSet | Hash table and linked list implementation of the Set interface, with predictable iteration order. This implementation differs from HashSet in that it maintains a doubly-linked list running through all of its entries. This linked list defines the iteration ordering, which is the order in which elements were inserted into the set (insertion-order). Note that insertion order is not affected if an element is re-inserted into the set. |
CopyOnWriteArraySet | A Set that uses an internal
|