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 Details

  • Method Details

    • createInstance

      @Nonnull @ReturnsMutableCopy public <T> CommonsHashSet<T> createInstance()
      Description copied from interface: ICommonsSet
      Create a new empty set. Overwrite this if you don't want to use CommonsHashSet.
      Specified by:
      createInstance in interface ICommonsSet<ELEMENTTYPE>
      Type Parameters:
      T - Set element type
      Returns:
      A new empty set. Never null.
    • getClone

      Specified by:
      getClone in interface ICloneable<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 between Predicate and Function and 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 be null.
      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 between Predicate and Function and the mapping case occurs more often.
      Type Parameters:
      SRCTYPE - source data type
      ELEMENTTYPE - final data type of the list
      Parameters:
      aValues - The iterable from which the elements are copied from. May be null.
      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 be null.
      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 between Predicate and Function and the mapping case occurs more often.
      Type Parameters:
      SRCTYPE - source data type
      ELEMENTTYPE - final data type of the list
      Parameters:
      aValues - The iterable from which the elements are copied from. May be null.
      aMapper - The mapping function to be executed for all provided elements. May not be null.
      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 between Predicate and Function and 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 be null.
      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 between Predicate and Function and the mapping case occurs more often.
      Type Parameters:
      SRCTYPE - source data type
      ELEMENTTYPE - final data type of the list
      Parameters:
      aValues - The array from which the elements are copied from. May be null.
      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 be null.
      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 between Predicate and Function and the mapping case occurs more often.
      Type Parameters:
      SRCTYPE - source data type
      ELEMENTTYPE - final data type of the list
      Parameters:
      aValues - The array from which the elements are copied from. May be null.
      aMapper - The mapping function to be executed for all provided elements. May not be null.
      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: