Type Parameters:
E - the type of elements maintained by this set
All Superinterfaces:
Iterable<E>

public interface PSet<E> extends Iterable<E>
Persistent (functional) Set.
Author:
Evgeny Mandrikov
  • Method Summary

    Modifier and Type
    Method
    Description
    add(E e)
     
    boolean
     
    boolean
     
    static <E> PSet<E>
    of()
    Returns a persistent set containing zero elements.
    static <E> PSet<E>
    of(E e1)
    Returns a persistent set containing one element.
    static <E> PSet<E>
    of(E e1, E e2)
    Returns a persistent set containing two elements.
    static <E> PSet<E>
    of(E e1, E e2, E e3)
    Returns a persistent set containing three elements.
    static <E> PSet<E>
    of(E e1, E e2, E e3, E e4)
    Returns a persistent set containing four elements.
    static <E> PSet<E>
    of(E e1, E e2, E e3, E e4, E e5)
    Returns a persistent set containing five elements.
    static <E> PSet<E>
    of(E e1, E e2, E e3, E e4, E e5, E e6)
    Returns a persistent set containing six elements.
    static <E> PSet<E>
    of(E e1, E e2, E e3, E e4, E e5, E e6, E e7)
    Returns a persistent set containing seven elements.
    static <E> PSet<E>
    of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8)
    Returns a persistent set containing eight elements.
    static <E> PSet<E>
    of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9)
    Returns a persistent set containing nine elements.
    static <E> PSet<E>
    of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10)
    Returns a persistent set containing ten elements.
    remove(E e)
     
    default Stream<E>
     
    The string representation consists of a list of elements in the ascending order of hash codes.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • add

      PSet<E> add(E e)
      Returns:
      new set with added element, or this if element already in the set
    • remove

      PSet<E> remove(E e)
      Returns:
      new set with removed element, or this if set does not contain given element
    • contains

      boolean contains(E e)
      Returns:
      true if this set contains the specified element
    • isEmpty

      boolean isEmpty()
      Returns:
      true if this set contains no elements
    • toString

      String toString()
      The string representation consists of a list of elements in the ascending order of hash codes. If two elements have same hash code, then their relative order is arbitrary, but stable.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this set
    • stream

      default Stream<E> stream()
      Returns:
      stream of the set's elements
    • of

      static <E> PSet<E> of()
      Returns a persistent set containing zero elements.
      Type Parameters:
      E - the PSet's element type
      Returns:
      an empty PSet
    • of

      static <E> PSet<E> of(E e1)
      Returns a persistent set containing one element.
      Type Parameters:
      E - the PSet's element type
      Parameters:
      e1 - the single element
      Returns:
      a PSet containing the specified element
    • of

      static <E> PSet<E> of(E e1, E e2)
      Returns a persistent set containing two elements.
      Type Parameters:
      E - the PSet's element type
      Parameters:
      e1 - the first element
      e2 - the second element
      Returns:
      a PSet containing the specified elements
    • of

      static <E> PSet<E> of(E e1, E e2, E e3)
      Returns a persistent set containing three elements.
      Type Parameters:
      E - the PSet's element type
      Parameters:
      e1 - the first element
      e2 - the second element
      e3 - the third element
      Returns:
      a PSet containing the specified elements
    • of

      static <E> PSet<E> of(E e1, E e2, E e3, E e4)
      Returns a persistent set containing four elements.
      Type Parameters:
      E - the PSet's element type
      Parameters:
      e1 - the first element
      e2 - the second element
      e3 - the third element
      e4 - the fourth element
      Returns:
      a PSet containing the specified elements
    • of

      static <E> PSet<E> of(E e1, E e2, E e3, E e4, E e5)
      Returns a persistent set containing five elements.
      Type Parameters:
      E - the PSet's element type
      Parameters:
      e1 - the first element
      e2 - the second element
      e3 - the third element
      e4 - the fourth element
      e5 - the fifth element
      Returns:
      a PSet containing the specified elements
    • of

      static <E> PSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6)
      Returns a persistent set containing six elements.
      Type Parameters:
      E - the PSet's element type
      Parameters:
      e1 - the first element
      e2 - the second element
      e3 - the third element
      e4 - the fourth element
      e5 - the fifth element
      e6 - the sixth element
      Returns:
      a PSet containing the specified elements
    • of

      static <E> PSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7)
      Returns a persistent set containing seven elements.
      Type Parameters:
      E - the PSet's element type
      Parameters:
      e1 - the first element
      e2 - the second element
      e3 - the third element
      e4 - the fourth element
      e5 - the fifth element
      e6 - the sixth element
      e7 - the seventh element
      Returns:
      a PSet containing the specified elements
    • of

      static <E> PSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8)
      Returns a persistent set containing eight elements.
      Type Parameters:
      E - the PSet's element type
      Parameters:
      e1 - the first element
      e2 - the second element
      e3 - the third element
      e4 - the fourth element
      e5 - the fifth element
      e6 - the sixth element
      e7 - the seventh element
      e8 - the eighth element
      Returns:
      a PSet containing the specified elements
    • of

      static <E> PSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9)
      Returns a persistent set containing nine elements.
      Type Parameters:
      E - the PSet's element type
      Parameters:
      e1 - the first element
      e2 - the second element
      e3 - the third element
      e4 - the fourth element
      e5 - the fifth element
      e6 - the sixth element
      e7 - the seventh element
      e8 - the eighth element
      e9 - the ninth element
      Returns:
      a PSet containing the specified elements
    • of

      static <E> PSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10)
      Returns a persistent set containing ten elements.
      Type Parameters:
      E - the PSet's element type
      Parameters:
      e1 - the first element
      e2 - the second element
      e3 - the third element
      e4 - the fourth element
      e5 - the fifth element
      e6 - the sixth element
      e7 - the seventh element
      e8 - the eighth element
      e9 - the ninth element
      e10 - the tenth element
      Returns:
      a PSet containing the specified elements