Class PersistentHashSet<E>

    • Method Detail

      • of

        public static <E> PersistentHashSet<E> of​(Iterable<E> elements)
        Returns a new PersistentHashSet of the values. The vararg version of this method is StaticImports.set(Object...) If the input contains duplicate elements, later values overwrite earlier ones.
        Parameters:
        elements - The items to put into a vector.
        Returns:
        a new PersistentHashSet of the given elements.
      • contains

        public boolean contains​(Object key)
        Description copied from interface: UnmodSet
        Returns true if the set contains the given item. This is the defining method of a set. Sets have to override this because the default implementation in UnmodCollection is O(n) whereas a sorted set should be O(log n) or O(1).
        Specified by:
        contains in interface Collection<E>
        Specified by:
        contains in interface Set<E>
        Specified by:
        contains in interface UnmodSet<E>
      • equator

        public Equator<E> equator()
        Returns the Equator used by this set for equals comparisons and hashCodes
      • put

        @NotNull
        public @NotNull PersistentHashSet<E> put​(E o)
        Description copied from interface: ImSet
        Adds an element, returning a modified version of the set (leaving the original set unchanged). If the element already exists in this set, the new value overwrites the old one. If the new element is the same as an old element (based on the address of that item in memory, not an equals test), the old set is returned unchanged.
        Specified by:
        put in interface BaseSet<E>
        Specified by:
        put in interface ImSet<E>
        Parameters:
        o - the element to add to this set
        Returns:
        a new set with the element added (see note above about adding duplicate elements).
      • iterator

        @NotNull
        public @NotNull UnmodIterator<E> iterator()
        Description copied from interface: UnmodSet
        Iterates over contents with no guarantees about their ordering. An unmodifiable iterator A one-time use, mutable, not-thread-safe way to get each value of the underling collection in turn. I experimented with various thread-safe alternatives, but the JVM is optimized around iterators so this is the lowest common denominator of collection iteration, even though iterators are inherently mutable.
        Specified by:
        iterator in interface Collection<E>
        Specified by:
        iterator in interface Iterable<E>
        Specified by:
        iterator in interface Set<E>
        Specified by:
        iterator in interface UnmodCollection<E>
        Specified by:
        iterator in interface UnmodIterable<E>
        Specified by:
        iterator in interface UnmodSet<E>
      • size

        public int size()
        Description copied from interface: Sized
        Returns the number of items in this collection or iterable.
        Specified by:
        size in interface Collection<E>
        Specified by:
        size in interface Set<E>
        Specified by:
        size in interface Sized