Class CommonsHashSet<ELEMENTTYPE>
java.lang.Object
java.util.AbstractCollection<ELEMENTTYPE>
java.util.AbstractSet<ELEMENTTYPE>
java.util.HashSet<ELEMENTTYPE>
com.helger.commons.collection.impl.CommonsHashSet<ELEMENTTYPE>
- Type Parameters:
ELEMENTTYPE- Set element type
- All Implemented Interfaces:
ICommonsCollection<ELEMENTTYPE>,ICommonsIterable<ELEMENTTYPE>,ICommonsSet<ELEMENTTYPE>,ICloneable<ICommonsSet<ELEMENTTYPE>>,IHasSize,Serializable,Cloneable,Iterable<ELEMENTTYPE>,Collection<ELEMENTTYPE>,Set<ELEMENTTYPE>
public class CommonsHashSet<ELEMENTTYPE>
extends HashSet<ELEMENTTYPE>
implements ICommonsSet<ELEMENTTYPE>
A special
HashSet implementation based on ICommonsSet.- Author:
- Philip Helger
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCommonsHashSet(int nInitialCapacity) CommonsHashSet(int nInitialCapacity, float fLoadFactor) CommonsHashSet(ELEMENTTYPE aValue) CommonsHashSet(ELEMENTTYPE... aValues) CommonsHashSet(Iterable<? extends ELEMENTTYPE> aIterable) CommonsHashSet(Iterable<? extends SRCTYPE> aValues, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) CommonsHashSet(Collection<? extends ELEMENTTYPE> aCont) CommonsHashSet(Collection<? extends SRCTYPE> aValues, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) CommonsHashSet(Enumeration<? extends ELEMENTTYPE> aIterable) CommonsHashSet(SRCTYPE[] aValues, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) -
Method Summary
Modifier and TypeMethodDescriptionstatic <ELEMENTTYPE>
CommonsHashSet<ELEMENTTYPE> createFiltered(ELEMENTTYPE[] aValues, Predicate<? super ELEMENTTYPE> aFilter) static <ELEMENTTYPE>
CommonsHashSet<ELEMENTTYPE> createFiltered(Iterable<? extends ELEMENTTYPE> aValues, Predicate<? super ELEMENTTYPE> aFilter) static <SRCTYPE,ELEMENTTYPE>
CommonsHashSet<ELEMENTTYPE> createFiltered(Iterable<? extends SRCTYPE> aValues, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper, Predicate<? super ELEMENTTYPE> aFilter) Create a new hash set that contains a subset of the provided iterable.static <SRCTYPE,ELEMENTTYPE>
CommonsHashSet<ELEMENTTYPE> createFiltered(Iterable<? extends SRCTYPE> aValues, Predicate<? super SRCTYPE> aFilter, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) Create a new hash set that contains a subset of the provided iterable.static <SRCTYPE,ELEMENTTYPE>
CommonsHashSet<ELEMENTTYPE> createFiltered(SRCTYPE[] aValues, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper, Predicate<? super ELEMENTTYPE> aFilter) Create a new hash set that contains a subset of the provided array.static <SRCTYPE,ELEMENTTYPE>
CommonsHashSet<ELEMENTTYPE> createFiltered(SRCTYPE[] aValues, Predicate<? super SRCTYPE> aFilter, Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) Create a new hash set that contains a subset of the provided array.<T> CommonsHashSet<T> Create a new empty set.getClone()Methods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, newHashSet, remove, size, spliterator, toArray, toArrayMethods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface com.helger.commons.collection.impl.ICommonsCollection
addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addIf, addIfNotNull, addObject, getAtIndex, getAtIndex, getAtIndex, getAtIndex, getAtIndexMapped, getAtIndexMapped, getAtIndexMapped, getAtIndexMapped, getCopyAsList, getCount, getSorted, iterator2, removeAll, removeObject, set, setAll, setAll, setAllMapped, setAllMappedMethods inherited from interface com.helger.commons.collection.impl.ICommonsIterable
containsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstIndex, findFirstMapped, findFirstMapped, findLastIndex, forEachBreakable, forEachByIndex, forEachThrowing, getCountMethods inherited from interface com.helger.commons.collection.impl.ICommonsSet
getAll, getAllInstanceOf, getAllMapped, getAllMapped, getAsUnmodifiable, replaceMethods inherited from interface com.helger.commons.lang.IHasSize
isEmpty, isNotEmpty, size
-
Constructor Details
-
CommonsHashSet
public CommonsHashSet() -
CommonsHashSet
public CommonsHashSet(int nInitialCapacity) -
CommonsHashSet
-
CommonsHashSet
-
CommonsHashSet
-
CommonsHashSet
-
CommonsHashSet
public CommonsHashSet(@Nullable Collection<? extends SRCTYPE> aValues, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) -
CommonsHashSet
public CommonsHashSet(@Nullable Iterable<? extends SRCTYPE> aValues, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) -
CommonsHashSet
-
CommonsHashSet
-
CommonsHashSet
public CommonsHashSet(@Nullable SRCTYPE[] aValues, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper)
-
-
Method Details
-
createInstance
Description copied from interface:ICommonsSetCreate a new empty set. Overwrite this if you don't want to useCommonsHashSet.- Specified by:
createInstancein interfaceICommonsSet<ELEMENTTYPE>- Type Parameters:
T- Set element type- Returns:
- A new empty set. Never
null.
-
getClone
- Specified by:
getClonein interfaceICloneable<ELEMENTTYPE>- Returns:
- A 100% deep-copy of the implementing class.
-
createFiltered
@Nonnull @ReturnsMutableCopy public static <ELEMENTTYPE> CommonsHashSet<ELEMENTTYPE> createFiltered(@Nullable Iterable<? extends ELEMENTTYPE> aValues, @Nullable Predicate<? super ELEMENTTYPE> aFilter) Create a new hash set that contains a subset of the provided iterable.
Note: this method is a static factory method because the compiler sometimes cannot deduce betweenPredicateandFunctionand the mapping case occurs more often.- Type Parameters:
ELEMENTTYPE- data type to create the list of- Parameters:
aValues- The iterable from which the elements are copied from. May benull.aFilter- The filter to be applied to check if the element should be added or not.- Returns:
- The created hash set. Never
null. - Since:
- 10.0.0
- See Also:
-
createFiltered
@Nonnull @ReturnsMutableCopy public static <SRCTYPE,ELEMENTTYPE> CommonsHashSet<ELEMENTTYPE> createFiltered(@Nullable Iterable<? extends SRCTYPE> aValues, @Nullable Predicate<? super SRCTYPE> aFilter, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) Create a new hash set that contains a subset of the provided iterable. This method filters the elements before they are mapped.
Note: this method is a static factory method because the compiler sometimes cannot deduce betweenPredicateandFunctionand the mapping case occurs more often.- Type Parameters:
SRCTYPE- source data typeELEMENTTYPE- final data type of the list- Parameters:
aValues- The iterable from which the elements are copied from. May benull.aFilter- The filter to be applied to check if the element should be added or not.aMapper- The mapping function to be executed for all provided elements. May not benull.- Returns:
- The created hash set. Never
null. - Since:
- 10.0.0
- See Also:
-
createFiltered
@Nonnull @ReturnsMutableCopy public static <SRCTYPE,ELEMENTTYPE> CommonsHashSet<ELEMENTTYPE> createFiltered(@Nullable Iterable<? extends SRCTYPE> aValues, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper, @Nullable Predicate<? super ELEMENTTYPE> aFilter) Create a new hash set that contains a subset of the provided iterable. This method maps the elements before they are filtered.
Note: this method is a static factory method because the compiler sometimes cannot deduce betweenPredicateandFunctionand the mapping case occurs more often.- Type Parameters:
SRCTYPE- source data typeELEMENTTYPE- final data type of the list- Parameters:
aValues- The iterable from which the elements are copied from. May benull.aMapper- The mapping function to be executed for all provided elements. May not benull.aFilter- The filter to be applied on the mapped element to check if the element should be added or not.- Returns:
- The created hash set. Never
null. - Since:
- 10.0.0
- See Also:
-
createFiltered
@Nonnull @ReturnsMutableCopy public static <ELEMENTTYPE> CommonsHashSet<ELEMENTTYPE> createFiltered(@Nullable ELEMENTTYPE[] aValues, @Nullable Predicate<? super ELEMENTTYPE> aFilter) Create a new hash set that contains a subset of the provided array.
Note: this method is a static factory method because the compiler sometimes cannot deduce betweenPredicateandFunctionand the mapping case occurs more often.- Type Parameters:
ELEMENTTYPE- data type of the list- Parameters:
aValues- The array from which the elements are copied from. May benull.aFilter- The filter to be applied to check if the element should be added or not.- Returns:
- The created hash set. Never
null. - Since:
- 10.0.0
- See Also:
-
createFiltered
@Nonnull @ReturnsMutableCopy public static <SRCTYPE,ELEMENTTYPE> CommonsHashSet<ELEMENTTYPE> createFiltered(@Nullable SRCTYPE[] aValues, @Nullable Predicate<? super SRCTYPE> aFilter, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper) Create a new hash set that contains a subset of the provided array. This method filters the elements before they are mapped.
Note: this method is a static factory method because the compiler sometimes cannot deduce betweenPredicateandFunctionand the mapping case occurs more often.- Type Parameters:
SRCTYPE- source data typeELEMENTTYPE- final data type of the list- Parameters:
aValues- The array from which the elements are copied from. May benull.aFilter- The filter to be applied to check if the element should be added or not.aMapper- The mapping function to be executed for all provided elements. May not benull.- Returns:
- The created hash set. Never
null. - Since:
- 10.0.0
- See Also:
-
createFiltered
@Nonnull @ReturnsMutableCopy public static <SRCTYPE,ELEMENTTYPE> CommonsHashSet<ELEMENTTYPE> createFiltered(@Nullable SRCTYPE[] aValues, @Nonnull Function<? super SRCTYPE, ? extends ELEMENTTYPE> aMapper, @Nullable Predicate<? super ELEMENTTYPE> aFilter) Create a new hash set that contains a subset of the provided array. This method maps the elements before they are filtered.
Note: this method is a static factory method because the compiler sometimes cannot deduce betweenPredicateandFunctionand the mapping case occurs more often.- Type Parameters:
SRCTYPE- source data typeELEMENTTYPE- final data type of the list- Parameters:
aValues- The array from which the elements are copied from. May benull.aMapper- The mapping function to be executed for all provided elements. May not benull.aFilter- The filter to be applied on the mapped element to check if the element should be added or not.- Returns:
- The created hash set. Never
null. - Since:
- 10.0.0
- See Also:
-