Interface IArrayBuilder<T>

All Known Implementing Classes:
TrieArray.Builder

public interface IArrayBuilder<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    default IArrayBuilder<T>
    add(Iterable<? extends T> source)
    Adds all values in the Collection to the values included in the collection when build() is called.
    default IArrayBuilder<T>
    add(Iterator<? extends T> source)
    Adds all values in the Iterator to the values included in the collection when build() is called.
    default <K extends T>
    IArrayBuilder<T>
    add(K... source)
    Adds all values in the array to the values included in the collection when build() is called.
    default IArrayBuilder<T>
    add(Indexed<? extends T> source)
    Adds all values in the Indexed to the values included in the collection when build() is called.
    default IArrayBuilder<T>
    add(Indexed<? extends T> source, int offset, int limit)
    Adds all values in the specified range of Indexed to the values included in the collection when build() is called.
    add(T value)
    Adds the specified value to the values included in the collection when build() is called.
    Builds and returns a collection containing all of the added values.
    Removes all objects and resets the builder to it's initial post-build state.
    put(int index, T value)
    Adds the specified value to the values included in the collection when build() is called.
    default IArrayBuilder<T>
    putAll(Iterator<IMapEntry<Integer,? extends T>> source)
    Adds all values from the provided Iterator using the entry keys as indexes and the entry values as values.
    setNextIndex(int index)
    Sets the index at which next call to add() will insert the value.
    int
    Determines how many values will be in the collection if build() is called now.
  • Method Details

    • build

      @Nonnull IArray<T> build()
      Builds and returns a collection containing all of the added values. May be called as often as desired and is safe to call and then continue adding more elements to build another collection with those additional elements.
      Returns:
      the collection
    • size

      int size()
      Determines how many values will be in the collection if build() is called now.
    • put

      @Nonnull IArrayBuilder<T> put(int index, T value)
      Adds the specified value to the values included in the collection when build() is called.
      Returns:
      the builder (convenience for chaining multiple calls)
    • add

      @Nonnull IArrayBuilder<T> add(T value)
      Adds the specified value to the values included in the collection when build() is called.
      Returns:
      the builder (convenience for chaining multiple calls)
    • setNextIndex

      IArrayBuilder<T> setNextIndex(int index)
      Sets the index at which next call to add() will insert the value.
    • add

      @Nonnull default IArrayBuilder<T> add(Iterator<? extends T> source)
      Adds all values in the Iterator to the values included in the collection when build() is called.
      Parameters:
      source - Iterator containing values to add
      Returns:
      the builder (convenience for chaining multiple calls)
    • add

      @Nonnull default IArrayBuilder<T> add(Iterable<? extends T> source)
      Adds all values in the Collection to the values included in the collection when build() is called.
      Parameters:
      source - Collection containing values to add
      Returns:
      the builder (convenience for chaining multiple calls)
    • add

      @Nonnull default <K extends T> IArrayBuilder<T> add(K... source)
      Adds all values in the array to the values included in the collection when build() is called.
      Parameters:
      source - array containing values to add
      Returns:
      the builder (convenience for chaining multiple calls)
    • add

      @Nonnull default IArrayBuilder<T> add(Indexed<? extends T> source, int offset, int limit)
      Adds all values in the specified range of Indexed to the values included in the collection when build() is called.
      Parameters:
      source - Indexed containing values to add
      Returns:
      the builder (convenience for chaining multiple calls)
    • add

      @Nonnull default IArrayBuilder<T> add(Indexed<? extends T> source)
      Adds all values in the Indexed to the values included in the collection when build() is called.
      Parameters:
      source - Indexed containing values to add
      Returns:
      the builder (convenience for chaining multiple calls)
    • putAll

      @Nonnull default IArrayBuilder<T> putAll(@Nonnull Iterator<IMapEntry<Integer,? extends T>> source)
      Adds all values from the provided Iterator using the entry keys as indexes and the entry values as values. Intended to simplify adding all values from an existing IArray or IMap into a new Builder.
      Parameters:
      source - Iterator containing entries to add
      Returns:
      the builder (convenience for chaining multiple calls)
    • clear

      Removes all objects and resets the builder to it's initial post-build state.
      Returns:
      the builder (convenience for chaining multiple calls)