Class CustomHashSet<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
java.util.HashSet<E>
org.variantsync.boosting.datastructure.CustomHashSet<E>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Set<E>

public class CustomHashSet<E> extends HashSet<E>
A customized generic implementation of a hash set with additional functionality like building powersets or uniting two sets of elements.
See Also:
  • Constructor Details

    • CustomHashSet

      public CustomHashSet()
      Constructs a new EccoSet with no elements.
    • CustomHashSet

      public CustomHashSet(Collection<E> elements)
      Constructs a new EccoSet with the elements from the specified collection.
      Parameters:
      elements - the collection of elements to initialize the set with
      Throws:
      NullPointerException - if the specified collection is null
  • Method Details

    • overwrite

      public void overwrite(E element)
      Replaces an equivalent element in the set with a new version of it
    • unite

      public CustomHashSet<E> unite(CustomHashSet<E> toUnite)
      Returns a new set that is the union of this set and the given set
      Parameters:
      toUnite - The set to form the union with
      Returns:
      A new set that contains the union of elements from this set and the given set
    • uniteElement

      public CustomHashSet<E> uniteElement(E toUnite)
      Returns a new set that is the union of this set and the given set
      Parameters:
      toUnite - The set to form the union with
      Returns:
      A new set that contains the union of elements from this set and the given set
    • without

      public CustomHashSet<E> without(CustomHashSet<E> without)
      Returns a new set that contains all elements in this set after removing the elements in the given set
      Parameters:
      without - The elements that should not be in the new set
      Returns:
      New set with elements that are only in this set but not in the given set
    • withoutElement

      public CustomHashSet<E> withoutElement(E without)
      Returns a new set that contains all elements in this set after removing the elements in the given set
      Parameters:
      without - The elements that should not be in the new set
      Returns:
      New set with elements that are only in this set but not in the given set
    • intersect

      public CustomHashSet<E> intersect(CustomHashSet<E> toIntersect)
      Returns a new set that is an intersection between this set and the given set
      Parameters:
      toIntersect - set to intersect with
      Returns:
      a new set with the elements that represent the intersection of both sets
    • intersectElement

      public CustomHashSet<E> intersectElement(E toIntersect)
      Returns a new set that is an intersection between this set and the given set
      Parameters:
      toIntersect - set to intersect with
      Returns:
      a new set with the elements that represent the intersection of both sets
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface Collection<E>
      Specified by:
      equals in interface Set<E>
      Overrides:
      equals in class AbstractSet<E>
    • powerSet

      public CustomHashSet<CustomHashSet<E>> powerSet()
      Returns the power set of this set.