Class ImmutableSet.SetBuilderImpl<E>

    • Field Detail

      • dedupedElements

        E[] dedupedElements
      • distinct

        int distinct
    • Constructor Detail

      • SetBuilderImpl

        SetBuilderImpl​(int expectedCapacity)
      • SetBuilderImpl

        SetBuilderImpl​(ImmutableSet.SetBuilderImpl<E> toCopy)
        Initializes this SetBuilderImpl with a copy of the deduped elements array from toCopy.
    • Method Detail

      • ensureCapacity

        private void ensureCapacity​(int minCapacity)
        Resizes internal data structures if necessary to store the specified number of distinct elements.
      • addDedupedElement

        final void addDedupedElement​(E e)
        Adds e to the insertion-order array of deduplicated elements. Calls ensureCapacity.
      • add

        abstract ImmutableSet.SetBuilderImpl<E> add​(E e)
        Adds e to this SetBuilderImpl, returning the updated result. Only use the returned SetBuilderImpl, since we may switch implementations if e.g. hash flooding is detected.
      • copy

        abstract ImmutableSet.SetBuilderImpl<E> copy()
        Creates a new copy of this SetBuilderImpl. Modifications to that SetBuilderImpl will not affect this SetBuilderImpl or sets constructed from this SetBuilderImpl via build().
      • review

        ImmutableSet.SetBuilderImpl<E> review()
        Call this before build(). Does a final check on the internal data structures, e.g. shrinking unnecessarily large structures or detecting previously unnoticed hash flooding.