Class RegularImmutableSet<E>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

    final class RegularImmutableSet<E>
    extends ImmutableSet<E>
    Implementation of ImmutableSet with two or more elements.
    • Field Detail

      • elements

        private final transient java.lang.Object[] elements
      • table

        final transient java.lang.Object[] table
      • mask

        private final transient int mask
      • hashCode

        private final transient int hashCode
    • Constructor Detail

      • RegularImmutableSet

        RegularImmutableSet​(java.lang.Object[] elements,
                            int hashCode,
                            java.lang.Object[] table,
                            int mask)
    • Method Detail

      • contains

        public boolean contains​(java.lang.Object target)
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.Set<E>
        Specified by:
        contains in class ImmutableCollection<E>
      • size

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

        public UnmodifiableIterator<E> iterator()
        Description copied from class: ImmutableCollection
        Returns an unmodifiable iterator across the elements in this collection.
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.Set<E>
        Specified by:
        iterator in class ImmutableSet<E>
      • spliterator

        public java.util.Spliterator<E> spliterator()
        Specified by:
        spliterator in interface java.util.Collection<E>
        Specified by:
        spliterator in interface java.lang.Iterable<E>
        Specified by:
        spliterator in interface java.util.Set<E>
        Overrides:
        spliterator in class ImmutableCollection<E>
      • internalArrayStart

        int internalArrayStart()
        Description copied from class: ImmutableCollection
        If this collection is backed by an array of its elements in insertion order, returns the offset where this collection's elements start.
        Overrides:
        internalArrayStart in class ImmutableCollection<E>
      • internalArrayEnd

        int internalArrayEnd()
        Description copied from class: ImmutableCollection
        If this collection is backed by an array of its elements in insertion order, returns the offset where this collection's elements end.
        Overrides:
        internalArrayEnd in class ImmutableCollection<E>
      • copyIntoArray

        int copyIntoArray​(java.lang.Object[] dst,
                          int offset)
        Description copied from class: ImmutableCollection
        Copies the contents of this immutable collection into the specified array at the specified offset. Returns offset + size().
        Overrides:
        copyIntoArray in class ImmutableCollection<E>
      • isPartialView

        boolean isPartialView()
        Description copied from class: ImmutableCollection
        Returns true if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods. This is generally used to determine whether copyOf implementations should make an explicit copy to avoid memory leaks.
        Specified by:
        isPartialView in class ImmutableCollection<E>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<E>
        Specified by:
        hashCode in interface java.util.Set<E>
        Overrides:
        hashCode in class ImmutableSet<E>