Class PSet<E>

  • Type Parameters:
    E - the type of element in this set
    All Implemented Interfaces:
    PersistentSet<E>

    public class PSet<E>
    extends java.lang.Object
    implements PersistentSet<E>
    A implementation of PersistentSet using Set.
    • Method Detail

      • empty

        public static <E> PSet<E> empty()
        Returns:
        an empty set
      • plus

        public PersistentSet<E> plus​(E e)
        Specified by:
        plus in interface PersistentSet<E>
        Parameters:
        e - an element
        Returns:
        a new set with the elements of this set and e
      • minus

        public PersistentSet<E> minus​(E e)
        Specified by:
        minus in interface PersistentSet<E>
        Parameters:
        e - an element
        Returns:
        a new set with the elements of this set except e
      • contains

        public boolean contains​(E e)
        Specified by:
        contains in interface PersistentSet<E>
        Parameters:
        e - an element
        Returns:
        whether this set contains e
      • stream

        public java.util.stream.Stream<E> stream()
        Specified by:
        stream in interface PersistentSet<E>
        Returns:
        a Stream of the elements in this set
      • asSet

        public java.util.Set<E> asSet()
        Description copied from interface: PersistentSet
        An immutable view of this as a java.util.Set.
        Specified by:
        asSet in interface PersistentSet<E>