Class IntSets.Singleton

  • All Implemented Interfaces:
    IntCollection, IntIterable, IntSet, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<java.lang.Integer>, java.util.Collection<java.lang.Integer>, java.util.Set<java.lang.Integer>
    Direct Known Subclasses:
    IntSortedSets.Singleton
    Enclosing class:
    IntSets

    public static class IntSets.Singleton
    extends AbstractIntSet
    implements java.io.Serializable, java.lang.Cloneable
    An immutable class representing a type-specific singleton set.

    This class may be useful to implement your own in case you subclass a type-specific set.

    See Also:
    Serialized Form
    • Method Detail

      • contains

        public boolean contains​(int k)
        Description copied from class: AbstractIntCollection
        Returns true if this collection contains the specified element.

        This implementation iterates over the elements in the collection, looking for the specified element.

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

        public boolean remove​(int k)
        Description copied from class: AbstractIntSet
        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
        Overrides:
        remove in class AbstractIntSet
        See Also:
        Collection.remove(Object)
      • iterator

        public IntListIterator 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 java.util.Collection<java.lang.Integer>
        Specified by:
        iterator in interface IntCollection
        Specified by:
        iterator in interface IntIterable
        Specified by:
        iterator in interface IntSet
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Integer>
        Specified by:
        iterator in interface java.util.Set<java.lang.Integer>
        Specified by:
        iterator in class AbstractIntSet
        Returns:
        a type-specific iterator on the elements of this collection.
        See Also:
        Iterable.iterator()
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<java.lang.Integer>
        Specified by:
        size in interface java.util.Set<java.lang.Integer>
        Specified by:
        size in class java.util.AbstractCollection<java.lang.Integer>
      • addAll

        public boolean addAll​(java.util.Collection<? extends java.lang.Integer> c)
        Specified by:
        addAll in interface java.util.Collection<java.lang.Integer>
        Specified by:
        addAll in interface java.util.Set<java.lang.Integer>
        Overrides:
        addAll in class java.util.AbstractCollection<java.lang.Integer>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<java.lang.Integer>
        Specified by:
        removeAll in interface java.util.Set<java.lang.Integer>
        Overrides:
        removeAll in class java.util.AbstractCollection<java.lang.Integer>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<java.lang.Integer>
        Specified by:
        retainAll in interface java.util.Set<java.lang.Integer>
        Overrides:
        retainAll in class java.util.AbstractCollection<java.lang.Integer>
      • addAll

        public boolean addAll​(IntCollection c)
        Description copied from interface: IntCollection
        Adds all elements of the given type-specific collection to this collection.
        Specified by:
        addAll in interface IntCollection
        Overrides:
        addAll in class AbstractIntCollection
        Parameters:
        c - a type-specific collection.
        Returns:
        true if this collection changed as a result of the call.
        See Also:
        Collection.addAll(Collection)
      • removeAll

        public boolean removeAll​(IntCollection c)
        Description copied from interface: IntCollection
        Remove from this collection all elements in the given type-specific collection.
        Specified by:
        removeAll in interface IntCollection
        Overrides:
        removeAll in class AbstractIntCollection
        Parameters:
        c - a type-specific collection.
        Returns:
        true if this collection changed as a result of the call.
        See Also:
        Collection.removeAll(Collection)
      • retainAll

        public boolean retainAll​(IntCollection c)
        Description copied from interface: IntCollection
        Retains in this collection only elements from the given type-specific collection.
        Specified by:
        retainAll in interface IntCollection
        Overrides:
        retainAll in class AbstractIntCollection
        Parameters:
        c - a type-specific collection.
        Returns:
        true if this collection changed as a result of the call.
        See Also:
        Collection.retainAll(Collection)
      • clone

        public java.lang.Object clone()