@@ -0,0 +1,1989 @@
+// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.%0Apackage com.intellij.util.indexing.hash;%0A%0Aimport com.intellij.util.indexing.ValueContainer;%0Aimport org.jetbrains.annotations.NotNull;%0Aimport org.jetbrains.annotations.Nullable;%0A%0Apublic class MergedValueContainer%3CValue%3E extends ValueContainer%3CValue%3E %7B%0A  private final ValueContainer%3CValue%3E myContainer1;%0A  private final ValueContainer%3CValue%3E myContainer2;%0A%0A  @NotNull%0A  public static %3CValue%3E ValueContainer%3CValue%3E merge(@NotNull ValueContainer%3CValue%3E container1, @NotNull ValueContainer%3CValue%3E container2) %7B%0A    if (container1.size() == 0) return container2;%0A    if (container2.size() == 0) return container1;%0A    return new MergedValueContainer%3C%3E(container1, container2);%0A  %7D%0A%0A  private MergedValueContainer(@NotNull ValueContainer%3CValue%3E container1, @NotNull ValueContainer%3CValue%3E container2) %7B%0A    myContainer1 = container1;%0A    myContainer2 = container2;%0A  %7D%0A%0A  @NotNull%0A  @Override%0A  public ValueIterator%3CValue%3E getValueIterator() %7B%0A    return new ValueIterator%3CValue%3E() %7B%0A      boolean mySecondIsUsed;%0A      ValueIterator%3CValue%3E myCurrent = myContainer1.getValueIterator();%0A%0A      @NotNull%0A      @Override%0A      public IntIterator getInputIdsIterator() %7B%0A        return myCurrent.getInputIdsIterator();%0A      %7D%0A%0A      @Nullable%0A      @Override%0A      public IntPredicate getValueAssociationPredicate() %7B%0A        return myCurrent.getValueAssociationPredicate();%0A      %7D%0A%0A      @Override%0A      public boolean hasNext() %7B%0A        if (myCurrent.hasNext()) return true;%0A        if (!mySecondIsUsed) %7B%0A          myCurrent = myContainer2.getValueIterator();%0A          mySecondIsUsed = true;%0A          return hasNext();%0A        %7D%0A        return false;%0A      %7D%0A%0A      @Override%0A      public Value next() %7B%0A        return myCurrent.next();%0A      %7D%0A    %7D;%0A  %7D%0A%0A  @Override%0A  public int size() %7B%0A    return myContainer1.size() + myContainer2.size();%0A  %7D%0A%7D%0A

introduce MergedValueContainer