Class AbstractIntSet

All Implemented Interfaces:
IntCollection, IntIterable, IntSet, Cloneable, Iterable<Integer>, Collection<Integer>, Set<Integer>
Direct Known Subclasses:
AbstractIntSortedSet, IntArraySet, IntOpenCustomHashSet, IntOpenHashBigSet, IntOpenHashSet, IntSets.Singleton

public abstract class AbstractIntSet
extends AbstractIntCollection
implements Cloneable, IntSet
An abstract class providing basic methods for sets implementing a type-specific interface.

Note that the type-specific Set interface adds a type-specific remove() method, as it is no longer harmful for subclasses. Thus, concrete subclasses of this class must implement remove() (the rem() implementation of this class just delegates to remove()).

  • Method Details

    • iterator

      public abstract IntIterator iterator()
      Description copied from interface: IntCollection
      Returns a type-specific iterator on the elements of this collection.

      Note that this specification strengthens the one given in Iterable.iterator(), which was already strengthened in the corresponding type-specific class, but was weakened by the fact that this interface extends Collection.

      Specified by:
      iterator in interface Collection<Integer>
      Specified by:
      iterator in interface IntCollection
      Specified by:
      iterator in interface IntIterable
      Specified by:
      iterator in interface IntSet
      Specified by:
      iterator in interface Iterable<Integer>
      Specified by:
      iterator in interface Set<Integer>
      Specified by:
      iterator in class AbstractIntCollection
      Returns:
      a type-specific iterator on the elements of this collection.
      See Also:
      Iterable.iterator()
    • equals

      public boolean equals​(Object o)
      Specified by:
      equals in interface Collection<Integer>
      Specified by:
      equals in interface Set<Integer>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns a hash code for this set. The hash code of a set is computed by summing the hash codes of its elements.
      Specified by:
      hashCode in interface Collection<Integer>
      Specified by:
      hashCode in interface Set<Integer>
      Overrides:
      hashCode in class Object
      Returns:
      a hash code for this set.
    • remove

      public boolean remove​(int k)
      Removes an element from this set.

      Note that the corresponding method of a type-specific collection is rem(). This unfortunate situation is caused by the clash with the similarly named index-based method in the List interface. Delegates to the type-specific rem() method implemented by type-specific abstract Collection superclass.

      Specified by:
      remove in interface IntSet
      See Also:
      Collection.remove(Object)
    • rem

      @Deprecated public boolean rem​(int k)
      Deprecated.
      Please use remove() instead.
      Removes a single instance of the specified element from this collection, if it is present (optional operation).

      Note that this method should be called remove(), but the clash with the similarly named index-based method in the List interface forces us to use a distinguished name. For simplicity, the set interfaces reinstates remove().

      This implementation iterates over the elements in the collection, looking for the specified element and tries to remove it. Delegates to the type-specific remove() method specified in the type-specific Set interface.

      Specified by:
      rem in interface IntCollection
      Specified by:
      rem in interface IntSet
      Overrides:
      rem in class AbstractIntCollection
      See Also:
      Collection.remove(Object)