Class EquivalentHashSet<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- org.infinispan.commons.equivalence.EquivalentHashSet<E>
-
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>
public class EquivalentHashSet<E> extends AbstractSet<E>
Deprecated.Custom hash-based set which accepts no null values, where equality and hash code calculations are done based on passedEquivalencefunction implementations for values, as opposed to relying on their own equals/hashCode/toString implementations. This is handy when using key/values whose mentioned methods cannot be overriden, i.e. arrays, and in situations where users want to avoid using wrapper objects.- Since:
- 5.3
- Author:
- Galder ZamarreƱo
-
-
Constructor Summary
Constructors Constructor Description EquivalentHashSet(int initialCapacity, Equivalence<? super E> entryEq)Deprecated.Constructs a new, empty set, with a given initial capacity and a particular equivalence function to compare entries.EquivalentHashSet(Equivalence<? super E> entryEq)Deprecated.Constructs a new, empty set, with a given equivalence function
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanadd(E o)Deprecated.Adds the specified element to this set if it is not already present.voidclear()Deprecated.Removes all of the elements from this set.booleancontains(Object o)Deprecated.Returnstrueif this set contains the specified element.inthashCode()Deprecated.Returns the hash code value for this set using theEquivalencefunction associated with it.booleanisEmpty()Deprecated.Returnstrueif this set contains no elements.Iterator<E>iterator()Deprecated.Returns an iterator over the elements in this set.booleanremove(Object o)Deprecated.Removes the specified element from this set if it is present.intsize()Deprecated.Returns the number of elements in this set.
-
-
-
Constructor Detail
-
EquivalentHashSet
public EquivalentHashSet(Equivalence<? super E> entryEq)
Deprecated.Constructs a new, empty set, with a given equivalence function- Parameters:
entryEq- the Equivalence function to be used to compare entries in this set.
-
EquivalentHashSet
public EquivalentHashSet(int initialCapacity, Equivalence<? super E> entryEq)Deprecated.Constructs a new, empty set, with a given initial capacity and a particular equivalence function to compare entries.- Parameters:
initialCapacity- this set's initial capacityentryEq- the Equivalence function to be used to compare entries in this set.
-
-
Method Detail
-
iterator
public Iterator<E> iterator()
Deprecated.Returns an iterator over the elements in this set.- Returns:
- an iterator over the elements in this set
-
size
public int size()
Deprecated.Returns the number of elements in this set. If this set contains more thanInteger.MAX_VALUEelements, it returnsInteger.MAX_VALUE.- Returns:
- the number of elements in this set
-
isEmpty
public boolean isEmpty()
Deprecated.Returnstrueif this set contains no elements.- Returns:
trueif this set contains no elements
-
contains
public boolean contains(Object o)
Deprecated.Returnstrueif this set contains the specified element.- Parameters:
o- the object to be checked for containment in this set- Returns:
trueif this set contains the specified element
-
add
public boolean add(E o)
Deprecated.Adds the specified element to this set if it is not already present.- Parameters:
o- element to be added to this set- Returns:
trueif the set did not already contain the specified element
-
remove
public boolean remove(Object o)
Deprecated.Removes the specified element from this set if it is present.- Parameters:
o- object to be removed from this set, if present- Returns:
trueif the set contained the specified element
-
clear
public void clear()
Deprecated.Removes all of the elements from this set.
-
hashCode
public int hashCode()
Deprecated.Returns the hash code value for this set using theEquivalencefunction associated with it. The hash code of a set is defined to be the sum of the hash codes of the elements in the set, where the hash code of a null element is defined to be zero. This ensures thatEquivalence.equals(Object s1, Object s2)implies thatEquivalence.hashCode(Object s1)==Equivalence.hashCode(Object s2)for any two sets s1 and s2, as required by the general contract ofObject.hashCode().This implementation iterates over the set, calling the hashCode method on each element in the set, and adding up the results.
- Returns:
- the hash code value for this set
-
-