Interface NonEmptySetBuilder<A>

  • Type Parameters:
    A - the element type
    All Superinterfaces:
    SetBuilder<A>

    public interface NonEmptySetBuilder<A>
    extends SetBuilder<A>
    A builder for ImmutableNonEmptySets.

    A NonEmptySetBuilder is immutable and all add operations return a new SetBuilder. To construct the ImmutableNonEmptySet, call build().

    It is safe to continue adding to a NonEmptySetBuilder even after build is called. It is also safe to "fork" a NonEmptySetBuilder, but be aware that internal copies may be made when doing so.

    • Method Detail

      • addAll

        NonEmptySetBuilder<A> addAll​(java.util.Collection<A> elements)
        Adds all elements in a java.util.Collection to this NonEmptySetBuilder.
        Specified by:
        addAll in interface SetBuilder<A>
        Parameters:
        elements - the collection to add
        Returns:
        a new NonEmptySetBuilder with the elements added
      • addAll

        NonEmptySetBuilder<A> addAll​(software.kes.enhancediterables.FiniteIterable<A> elements)
        Adds all elements in a FiniteIterable to this NonEmptySetBuilder.

        Since Sets are FiniteIterables, this method accepts any Set.

        Specified by:
        addAll in interface SetBuilder<A>
        Parameters:
        elements - the FiniteIterable to add
        Returns:
        a new NonEmptySetBuilder with the elements added
      • build

        ImmutableNonEmptySet<A> build()
        Builds a new ImmutableNonEmptySet.

        It is safe to call this at any point, and it safe to continue adding elements after calling this.

        Specified by:
        build in interface SetBuilder<A>
        Returns:
        an ImmutableNonEmptySet.
      • builder

        static <A> NonEmptySetBuilder<A> builder​(A first)
        Creates a new NonEmptySetBuilder.
        Type Parameters:
        A - the element type
        Parameters:
        first - the first element
        Returns:
        an empty SetBuilder
      • builder

        static <A> NonEmptySetBuilder<A> builder​(int initialCapacity,
                                                 A first)
        Creates a new NonEmptySetBuilder with an initial capacity hint.
        Type Parameters:
        A - the element type
        Parameters:
        initialCapacity - an initial capacity hint. Must be >= 0.
        first - the first element
        Returns:
        an empty SetBuilder