Class CompactSet<E>

java.lang.Object
com.cedarsoftware.util.CompactSet<E>
Type Parameters:
E - the type of elements maintained by this set
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>
Direct Known Subclasses:
CompactCIHashSet, CompactCILinkedSet, CompactLinkedSet

public class CompactSet<E> extends Object implements Set<E>
A memory-efficient Set implementation that internally uses CompactMap.

This implementation provides the same memory benefits as CompactMap while maintaining proper Set semantics. It can be configured for:

  • Case sensitivity for String elements
  • Element ordering (sorted, reverse, insertion)
  • Custom compact size threshold

Creating a CompactSet


 // Create a case-insensitive, sorted CompactSet
 CompactSet<String> set = CompactSet.<String>builder()
     .caseSensitive(false)
     .sortedOrder()
     .compactSize(80)
     .build();

 // Create a CompactSet with insertion ordering
 CompactSet<String> ordered = CompactSet.<String>builder()
     .insertionOrder()
     .build();
 
Author:
John DeRegnaucourt ([email protected])
Copyright (c) Cedar Software LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

License

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.