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>
A customized generic implementation of a hash set
with additional functionality like building powersets or uniting two sets of elements.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new EccoSet with no elements.CustomHashSet
(Collection<E> elements) Constructs a new EccoSet with the elements from the specified collection. -
Method Summary
Modifier and TypeMethodDescriptionboolean
intersect
(CustomHashSet<E> toIntersect) Returns a new set that is an intersection between this set and the given setintersectElement
(E toIntersect) Returns a new set that is an intersection between this set and the given setvoid
Replaces an equivalent element in the set with a new version of itpowerSet()
Returns the power set of this set.unite
(CustomHashSet<E> toUnite) Returns a new set that is the union of this set and the given setuniteElement
(E toUnite) Returns a new set that is the union of this set and the given setwithout
(CustomHashSet<E> without) Returns a new set that contains all elements in this set after removing the elements in the given setwithoutElement
(E without) Returns a new set that contains all elements in this set after removing the elements in the given setMethods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, remove, size, spliterator, toArray, toArray
Methods inherited from class java.util.AbstractSet
hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, 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
-
Constructor Details
-
CustomHashSet
public CustomHashSet()Constructs a new EccoSet with no elements. -
CustomHashSet
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
Replaces an equivalent element in the set with a new version of it -
unite
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
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
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
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
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
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
- Specified by:
equals
in interfaceCollection<E>
- Specified by:
equals
in interfaceSet<E>
- Overrides:
equals
in classAbstractSet<E>
-
powerSet
Returns the power set of this set.
-