Class PersistentHashSet.MutableHashSet<E>

    • Method Detail

      • size

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

        public PersistentHashSet.MutableHashSet<E> put​(E val)
        Description copied from interface: MutableSet
        Adds an element. 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 may be returned unchanged.
        Specified by:
        put in interface BaseSet<E>
        Specified by:
        put in interface MutableSet<E>
        Parameters:
        val - the element to add to this set
        Returns:
        a new set with the element added (see note above about adding duplicate elements).
      • iterator

        public 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 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 interface UnmodCollection<E>
        Specified by:
        iterator in interface UnmodIterable<E>
        Specified by:
        iterator in interface UnmodSet<E>
      • contains

        public boolean contains​(java.lang.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 java.util.Collection<E>
        Specified by:
        contains in interface java.util.Set<E>
        Specified by:
        contains in interface UnmodSet<E>