Interface NonEmptyVectorBuilder<A>

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

    public interface NonEmptyVectorBuilder<A>
    extends VectorBuilder<A>
    A builder for ImmutableNonEmptyVectors.

    A NonEmptyVectorBuilder is immutable and all add operations return a new VectorBuilder. To construct the ImmutableNonEmptyVector, call build().

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

    • Method Detail

      • addAll

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

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

        Since Vectors are FiniteIterables, this method accepts any Vector.

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

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

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

        Specified by:
        build in interface VectorBuilder<A>
        Returns:
        an ImmutableNonEmptyVector.
      • builder

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

        static <A> NonEmptyVectorBuilder<A> builder​(int initialCapacity,
                                                    A first)
        Creates a new NonEmptyVectorBuilder 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 VectorBuilder