Class CommonsHashSet<ELEMENTTYPE>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- 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 specialHashSetimplementation based onICommonsSet.- Author:
- Philip Helger
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CommonsHashSet()CommonsHashSet(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <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>createInstance()Create a new empty set.CommonsHashSet<ELEMENTTYPE>getClone()-
Methods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, remove, size, spliterator
-
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods 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, setAllMapped
-
Methods 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, getCount
-
Methods inherited from interface com.helger.commons.collection.impl.ICommonsSet
getAll, getAllInstanceOf, getAllMapped, getAllMapped, getAsUnmodifiable, replace
-
Methods inherited from interface com.helger.commons.lang.IHasSize
isEmpty, isNotEmpty, size
-
-
-
-
Constructor Detail
-
CommonsHashSet
public CommonsHashSet()
-
CommonsHashSet
public CommonsHashSet(int nInitialCapacity)
-
CommonsHashSet
public CommonsHashSet(int nInitialCapacity, @Nonnegative float fLoadFactor)
-
CommonsHashSet
public CommonsHashSet(@Nullable Collection<? extends ELEMENTTYPE> aCont)
-
CommonsHashSet
public CommonsHashSet(@Nullable Iterable<? extends ELEMENTTYPE> aIterable)
-
CommonsHashSet
public CommonsHashSet(@Nullable Enumeration<? extends ELEMENTTYPE> aIterable)
-
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
public CommonsHashSet(@Nullable ELEMENTTYPE aValue)
-
CommonsHashSet
@SafeVarargs public CommonsHashSet(@Nullable ELEMENTTYPE... aValues)
-
CommonsHashSet
public CommonsHashSet(@Nullable SRCTYPE[] aValues, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
-
-
Method Detail
-
createInstance
@Nonnull @ReturnsMutableCopy public <T> CommonsHashSet<T> 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
@Nonnull @ReturnsMutableCopy public CommonsHashSet<ELEMENTTYPE> 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:
ICommonsCollection.addAll(Iterable, Predicate)
-
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:
ICommonsCollection.addAllMapped(Iterable, Predicate, Function)
-
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:
ICommonsCollection.addAllMapped(Iterable, Function, Predicate)
-
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:
ICommonsCollection.addAll(Object[], Predicate)
-
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:
ICommonsCollection.addAllMapped(Object[], Predicate, Function)
-
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:
ICommonsCollection.addAllMapped(Iterable, Function, Predicate)
-
-