Unlike {@link Collections#unmodifiableSet}, which is a view of a separate collection that can still change, an instance of this class contains its own private data and will never change. This class is convenient for {@code public static final} sets ("constant sets") and also lets youeasily make a "defensive copy" of a set provided to your class by a caller.
Warning: Like most sets, an {@code ImmutableSet} will not functioncorrectly if an element is modified after being placed in the set. For this reason, and to avoid general confusion, it is strongly recommended to place only immutable objects into this collection.
This class has been observed to perform significantly better than {@link HashSet} for objects with very fast {@link Object#hashCode} implementations(as a well-behaved immutable object should). While this class's factory methods create hash-based instances, the {@link ImmutableSortedSet} subclassperforms binary searches instead.
Note: Although this class is not final, it cannot be subclassed outside its package as it has no public or protected constructors. Thus, instances of this type are guaranteed to be immutable. @see ImmutableList @see ImmutableMap @author Kevin Bourrillion
|
|
|
|