Class 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 passed Equivalence function 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
      boolean add​(E o)
      Deprecated.
      Adds the specified element to this set if it is not already present.
      void clear()
      Deprecated.
      Removes all of the elements from this set.
      boolean contains​(Object o)
      Deprecated.
      Returns true if this set contains the specified element.
      int hashCode()
      Deprecated.
      Returns the hash code value for this set using the Equivalence function associated with it.
      boolean isEmpty()
      Deprecated.
      Returns true if this set contains no elements.
      Iterator<E> iterator()
      Deprecated.
      Returns an iterator over the elements in this set.
      boolean remove​(Object o)
      Deprecated.
      Removes the specified element from this set if it is present.
      int size()
      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 capacity
        entryEq - 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 than Integer.MAX_VALUE elements, it returns Integer.MAX_VALUE.
        Returns:
        the number of elements in this set
      • isEmpty

        public boolean isEmpty()
        Deprecated.
        Returns true if this set contains no elements.
        Returns:
        true if this set contains no elements
      • contains

        public boolean contains​(Object o)
        Deprecated.
        Returns true if this set contains the specified element.
        Parameters:
        o - the object to be checked for containment in this set
        Returns:
        true if 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:
        true if 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:
        true if 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 the Equivalence function 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 that Equivalence.equals(Object s1, Object s2) implies that Equivalence.hashCode(Object s1)==Equivalence.hashCode(Object s2) for any two sets s1 and s2, as required by the general contract of Object.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