Package com.cedarsoftware.util
Class CompactSet.Builder<E>
java.lang.Object
com.cedarsoftware.util.CompactSet.Builder<E>
- Enclosing class:
- CompactSet<E>
Builder for creating CompactSet instances with custom configurations.
Internally, the builder configures a CompactMap
(with <E, Object>).
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Creates a new CompactSet with the configured options.caseSensitive
(boolean caseSensitive) Sets whether String elements should be compared case-sensitively.compactSize
(int size) Sets the maximum size for compact array storage.Configures the set to maintain elements in insertion order.Specifies the type of backing Map to use when the set grows beyond the compact size.noOrder()
Configures the set to maintain elements in no specific order, like a HashSet.Configures the set to maintain elements in reverse sorted order.Configures the set to maintain elements in natural sorted order.
-
Method Details
-
caseSensitive
Sets whether String elements should be compared case-sensitively.- Parameters:
caseSensitive
- if false, do case-insensitive compares
-
compactSize
Sets the maximum size for compact array storage. -
sortedOrder
Configures the set to maintain elements in natural sorted order.Requires elements to be
Comparable
-
reverseOrder
Configures the set to maintain elements in reverse sorted order.Requires elements to be
Comparable
-
insertionOrder
Configures the set to maintain elements in insertion order. -
noOrder
Configures the set to maintain elements in no specific order, like a HashSet. -
mapType
Specifies the type of backing Map to use when the set grows beyond the compact size. This enables concurrent backing collections for thread-safe operations.Examples:
ConcurrentHashMap.class
- for high-concurrency unordered accessConcurrentSkipListMap.class
- for concurrent sorted accessLinkedHashMap.class
- for insertion-order preservationTreeMap.class
- for natural ordering
- Parameters:
mapType
- the Map class to use as backing storage when size exceeds compact threshold- Returns:
- this builder for method chaining
- Throws:
IllegalArgumentException
- if mapType is not a valid Map class or from allowed packages
-
build
Creates a new CompactSet with the configured options.
-