
com.cedarsoftware.util.CompactLinkedSet Maven / Gradle / Ivy
The newest version!
package com.cedarsoftware.util;
import java.util.Collection;
import java.util.Set;
/**
* A case-insensitive Set implementation that uses a compact internal representation
* for small sets. This Set exists to simplify JSON serialization. No custom reader nor
* writer is needed to serialize this set. It is a drop-in replacement for LinkedHashSet.
*
* @param the type of elements maintained by this set
*
* @author
* John DeRegnaucourt ([email protected])
*
* @see CompactSet
* @see CompactSet.Builder
*
* @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.
*/
public class CompactLinkedSet extends CompactSet {
/**
* Constructs an empty {@code CompactCIHashSet} with case-insensitive configuration.
*
* Specifically, it sets the set to be case-insensitive.
*
*
* @throws IllegalArgumentException if {@link #compactSize()} returns a value less than 2
*/
public CompactLinkedSet() {
super(CompactSet.createSimpleMap(true, CompactMap.DEFAULT_COMPACT_SIZE, CompactMap.INSERTION));
}
/**
* Constructs a {@code CompactCIHashSet} containing the elements of the specified collection.
*
* The set will be case-insensitive.
*
*
* @param other the collection whose elements are to be placed into this set
* @throws NullPointerException if the specified collection is null
* @throws IllegalArgumentException if {@link #compactSize()} returns a value less than 2
*/
public CompactLinkedSet(Collection other) {
this();
// Add all elements from the provided collection
addAll(other);
}
/**
* Indicates that this set is case-insensitive.
*
* @return {@code true} to denote case-insensitive behavior
*/
@Override
protected boolean isCaseInsensitive() {
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy