Merges the remainder orderings of this score with the one given. Call
canMergeRemainder first to verify if the merge makes any sense.
966364
public OrderingList<S> mergeRemainderOrdering(CompositeScore<S> other) {
        return getOrderingScore().mergeRemainderOrdering(other.getOrderingScore());
    }
78655
private void mergeCounters(Map<String, Map<Integer, MetricSnapshot>> newCounters,
                               Map<String, Map<Integer, MetricSnapshot>> oldCounters) {
        for (Map.Entry<String, Map<Integer, MetricSnapshot>> entry : newCounters.entrySet()) {
            String metricName = entry.getKey();
            Map<Integer, MetricSnapshot> snapshots = entry.getValue();
            Map<Integer, MetricSnapshot> oldSnapshots = oldCounters.get(metricName);
            if (oldSnapshots != null && oldSnapshots.size() > 0) {
                for (Map.Entry<Integer, MetricSnapshot> snapshotEntry : snapshots.entrySet()) {
                    Integer win = snapshotEntry.getKey();
                    MetricSnapshot snapshot = snapshotEntry.getValue();
                    MetricSnapshot oldSnapshot = oldSnapshots.get(win);
                    if (oldSnapshot != null) {
                        snapshot.set_longValue(snapshot.get_longValue() + oldSnapshot.get_longValue());
                    }
                }
            }
        }
    }
1092673
static boolean mergeVertices(Point pt_1, Point pt_2, double w_1,
			int rank_1, double w_2, int rank_2, Point pt_res, double[] w_res,
			int[] rank_res) {
		assert (!pt_1.isEmpty() && !pt_2.isEmpty());
		boolean res = pt_1.equals(pt_2);

		if (rank_1 > rank_2) {
			pt_res = pt_1;
			if (w_res != null) {
				rank_res[0] = rank_1;
				w_res[0] = w_1;
			}
			return res;
		} else if (rank_2 > rank_1) {
			pt_res = pt_2;
			if (w_res != null) {
				rank_res[0] = rank_1;
				w_res[0] = w_1;
			}
			return res;
		}

		pt_res = pt_1;
		Point2D pt2d = new Point2D();
		mergeVertices2D(pt_1.getXY(), pt_2.getXY(), w_1, rank_1, w_2, rank_2,
				pt2d, w_res, rank_res);
		pt_res.setXY(pt2d);
		return res;
	}
560172
public static int[] mergeSortedArrays(int[] nums1, int[] nums2, boolean ignoreEquals, boolean desc) {
        int len = nums1.length + nums2.length;
        int[] nums = new int[len];
        int m = 0;
        int n = 0;
        for (int i = 0; i < len; i++) {
            if (ignoreEquals && m < nums1.length && n < nums2.length && nums1[m] == nums2[n]) {
                if (m < nums1.length - 1) {
                    m++;
                } else if (n < nums2.length - 1) {
                    n++;
                }
                len--;
                i--;
                continue;
            }
            boolean inNums1 = n == nums2.length || (m != nums1.length && ((nums1[m] < nums2[n]) ^ desc));
            if (inNums1) {
                nums[i] = nums1[m++];
            } else {
                nums[i] = nums2[n++];
            }
        }
        if (nums1.length + nums2.length == len) {
            return nums;
        } else {
            int[] newNums = new int[len];
            System.arraycopy(nums, 0, newNums, 0, len);
            return newNums;
        }
    }
244996
private static void topDownMergeSort(int[] src, int[] dst, int fromIndex, int toIndex, IndirectComparator comp) {
    if (toIndex - fromIndex <= MIN_LENGTH_FOR_INSERTION_SORT) {
      insertionSort(fromIndex, toIndex - fromIndex, dst, comp);
      return;
    }

    final int mid = (fromIndex + toIndex) >>> 1;
    topDownMergeSort(dst, src, fromIndex, mid, comp);
    topDownMergeSort(dst, src, mid, toIndex, comp);

    /*
     * Both splits in of src are now sorted.
     */
    if (comp.compare(src[mid - 1], src[mid]) <= 0) {
      /*
       * If the lowest element in upper slice is larger than the highest element in
       * the lower slice, simply copy over, the data is fully sorted.
       */
      System.arraycopy(src, fromIndex, dst, fromIndex, toIndex - fromIndex);
    } else {
      /*
       * Run a manual merge.
       */
      for (int i = fromIndex, j = mid, k = fromIndex; k < toIndex; k++) {
        if (j == toIndex || (i < mid && comp.compare(src[i], src[j]) <= 0)) {
          dst[k] = src[i++];
        } else {
          dst[k] = src[j++];
        }
      }
    }
  }
117724
private void mergeStatus(MultiStatus status, IStatus toMerge) {
		if (!toMerge.isOK()) {
			status.merge(toMerge);
		}
	}
703485
@Override
	public boolean canMerge(ItemStack itemStack, EntityPlayer player, World world, BlockPos pos, EnumFacing side)
	{
		IBlockState state = world.getBlockState(pos);
		if (isCorner(state))
			return false;

		return EnumFacingUtils.getRealSide(state, side) != EnumFacing.NORTH;
	}
796958
public void mergeWith(Core o) {
    o.num = this.num = (num < o.num ? num : o.num);
  }
45523
@Override
    public void merge(EvaluationBinary other) {
        if (other.countTruePositive == null) {
            //Other is empty - no op
            return;
        }

        if (countTruePositive == null) {
            //This evaluation is empty -> take results from other
            this.countTruePositive = other.countTruePositive;
            this.countFalsePositive = other.countFalsePositive;
            this.countTrueNegative = other.countTrueNegative;
            this.countFalseNegative = other.countFalseNegative;
            this.rocBinary = other.rocBinary;
        } else {
            if (this.countTruePositive.length != other.countTruePositive.length) {
                throw new IllegalStateException("Cannot merge EvaluationBinary instances with different sizes. This "
                                + "size: " + this.countTruePositive.length + ", other size: "
                                + other.countTruePositive.length);
            }

            //Both have stats
            addInPlace(this.countTruePositive, other.countTruePositive);
            addInPlace(this.countTrueNegative, other.countTrueNegative);
            addInPlace(this.countFalsePositive, other.countFalsePositive);
            addInPlace(this.countFalseNegative, other.countFalseNegative);

            if (this.rocBinary != null) {
                this.rocBinary.merge(other.rocBinary);
            }
        }
    }
744107
public void merge(CandidateCluster other) {
        indices.addAll(other.indices);
        VectorMath.add(sumVector, other.sumVector);
        centroid = null;
    }
523204
public void combine(DoubleSummaryStatistics other) {
        count += other.count;
        simpleSum += other.simpleSum;
        sumWithCompensation(other.sum);
        sumWithCompensation(other.sumCompensation);
        min = Math.min(min, other.min);
        max = Math.max(max, other.max);
    }
1103354
public FireDepartmentMetrics merge(FireDepartmentMetrics other)
  {
    Preconditions.checkNotNull(other, "Cannot merge a null FireDepartmentMetrics");
    FireDepartmentMetrics otherSnapshot = other.snapshot();
    processedCount.addAndGet(otherSnapshot.processed());
    processedWithErrorsCount.addAndGet(otherSnapshot.processedWithErrors());
    thrownAwayCount.addAndGet(otherSnapshot.thrownAway());
    rowOutputCount.addAndGet(otherSnapshot.rowOutput());
    unparseableCount.addAndGet(otherSnapshot.unparseable());
    dedupCount.addAndGet(otherSnapshot.dedup());
    numPersists.addAndGet(otherSnapshot.numPersists());
    persistTimeMillis.addAndGet(otherSnapshot.persistTimeMillis());
    persistBackPressureMillis.addAndGet(otherSnapshot.persistBackPressureMillis());
    failedPersists.addAndGet(otherSnapshot.failedPersists());
    failedHandoffs.addAndGet(otherSnapshot.failedHandoffs());
    mergeTimeMillis.addAndGet(otherSnapshot.mergeTimeMillis());
    mergeCpuTime.addAndGet(otherSnapshot.mergeCpuTime());
    persistCpuTime.addAndGet(otherSnapshot.persistCpuTime());
    handOffCount.addAndGet(otherSnapshot.handOffCount());
    sinkCount.addAndGet(otherSnapshot.sinkCount());
    messageMaxTimestamp.set(Math.max(messageMaxTimestamp(), otherSnapshot.messageMaxTimestamp()));
    messageGap.set(Math.max(messageGap(), otherSnapshot.messageGap()));
    return this;
  }
190663
@Override
	public void merge(MinMaxHolder another){
		Long anotherMin = another.getMaxAsLong();
		if (anotherMin != null){
			evaluate(anotherMin);
		}
		Long anotherMax = another.getMaxAsLong();
		if (anotherMax != null){
			evaluate(anotherMax);
		}
	}
950833
@Nullable
  private List<IntBuffer> mergeIndexesAndWriteColumns(
      final List<IndexableAdapter> adapters,
      final ProgressIndicator progress,
      final TimeAndDimsIterator timeAndDimsIterator,
      final GenericColumnSerializer timeWriter,
      final ArrayList<GenericColumnSerializer> metricWriters,
      final List<DimensionMergerV9> mergers,
      final boolean fillRowNumConversions
  ) throws IOException
  {
    final String section = "walk through and merge rows";
    progress.startSection(section);
    long startTime = System.currentTimeMillis();

    List<IntBuffer> rowNumConversions = null;
    int rowCount = 0;
    if (fillRowNumConversions) {
      rowNumConversions = new ArrayList<>(adapters.size());
      for (IndexableAdapter adapter : adapters) {
        int[] arr = new int[adapter.getNumRows()];
        Arrays.fill(arr, INVALID_ROW);
        rowNumConversions.add(IntBuffer.wrap(arr));
      }
    }

    long time = System.currentTimeMillis();
    while (timeAndDimsIterator.moveToNext()) {
      progress.progress();
      TimeAndDimsPointer timeAndDims = timeAndDimsIterator.getPointer();
      timeWriter.serialize(timeAndDims.timestampSelector);

      for (int metricIndex = 0; metricIndex < timeAndDims.getNumMetrics(); metricIndex++) {
        metricWriters.get(metricIndex).serialize(timeAndDims.getMetricSelector(metricIndex));
      }

      for (int dimIndex = 0; dimIndex < timeAndDims.getNumDimensions(); dimIndex++) {
        DimensionMerger merger = mergers.get(dimIndex);
        if (merger.canSkip()) {
          continue;
        }
        merger.processMergedRow(timeAndDims.getDimensionSelector(dimIndex));
      }

      if (timeAndDimsIterator instanceof RowCombiningTimeAndDimsIterator) {
        RowCombiningTimeAndDimsIterator comprisedRows = (RowCombiningTimeAndDimsIterator) timeAndDimsIterator;

        for (int originalIteratorIndex = comprisedRows.nextCurrentlyCombinedOriginalIteratorIndex(0);
             originalIteratorIndex >= 0;
             originalIteratorIndex =
                 comprisedRows.nextCurrentlyCombinedOriginalIteratorIndex(originalIteratorIndex + 1)) {

          IntBuffer conversionBuffer = rowNumConversions.get(originalIteratorIndex);
          int minRowNum = comprisedRows.getMinCurrentlyCombinedRowNumByOriginalIteratorIndex(originalIteratorIndex);
          int maxRowNum = comprisedRows.getMaxCurrentlyCombinedRowNumByOriginalIteratorIndex(originalIteratorIndex);

          for (int rowNum = minRowNum; rowNum <= maxRowNum; rowNum++) {
            while (conversionBuffer.position() < rowNum) {
              conversionBuffer.put(INVALID_ROW);
            }
            conversionBuffer.put(rowCount);
          }

        }

      } else if (timeAndDimsIterator instanceof MergingRowIterator) {
        RowPointer rowPointer = (RowPointer) timeAndDims;
        IntBuffer conversionBuffer = rowNumConversions.get(rowPointer.getIndexNum());
        int rowNum = rowPointer.getRowNum();
        while (conversionBuffer.position() < rowNum) {
          conversionBuffer.put(INVALID_ROW);
        }
        conversionBuffer.put(rowCount);
      } else {
        if (fillRowNumConversions) {
          throw new IllegalStateException(
              "Filling row num conversions is supported only with RowCombining and Merging iterators"
          );
        }
      }

      if ((++rowCount % 500000) == 0) {
        log.info("walked 500,000/%d rows in %,d millis.", rowCount, System.currentTimeMillis() - time);
        time = System.currentTimeMillis();
      }
    }
    if (rowNumConversions != null) {
      for (IntBuffer rowNumConversion : rowNumConversions) {
        rowNumConversion.rewind();
      }
    }
    log.info("completed walk through of %,d rows in %,d millis.", rowCount, System.currentTimeMillis() - startTime);
    progress.stopSection(section);
    return rowNumConversions;
  }
1105152
public void merge(ClusteringFeature x) {
		assert (this.sumPoints.length == x.sumPoints.length);
		this.numPoints += x.numPoints;
		super.setWeight(this.numPoints);
		for (int i = 0; i < this.sumPoints.length; i++) {
			this.sumPoints[i] += x.sumPoints[i];
		}
		this.sumSquaredLength += x.sumSquaredLength;
	}
944008
@Override
	protected ACC mergeState(ACC a, ACC b) {
		return aggregateTransformation.aggFunction.merge(a, b);
	}
654099
protected final boolean mergeLists(List<UnclosedBranchDescriptor> child1open,
										List<UnclosedBranchDescriptor> child2open,
										List<UnclosedBranchDescriptor> result,
										boolean markJoinedBranchesAsPipelineBreaking) {

		//remove branches which have already been closed
		removeClosedBranches(child1open);
		removeClosedBranches(child2open);
		
		result.clear();
		
		// check how many open branches we have. the cases:
		// 1) if both are null or empty, the result is null
		// 2) if one side is null (or empty), the result is the other side.
		// 3) both are set, then we need to merge.
		if (child1open == null || child1open.isEmpty()) {
			if(child2open != null && !child2open.isEmpty()) {
				result.addAll(child2open);
			}
			return false;
		}
		
		if (child2open == null || child2open.isEmpty()) {
			result.addAll(child1open);
			return false;
		}

		int index1 = child1open.size() - 1;
		int index2 = child2open.size() - 1;
		
		boolean didCloseABranch = false;

		// as both lists (child1open and child2open) are sorted in ascending ID order
		// we can do a merge-join-like loop which preserved the order in the result list
		// and eliminates duplicates
		while (index1 >= 0 || index2 >= 0) {
			int id1 = -1;
			int id2 = index2 >= 0 ? child2open.get(index2).getBranchingNode().getId() : -1;

			while (index1 >= 0 && (id1 = child1open.get(index1).getBranchingNode().getId()) > id2) {
				result.add(child1open.get(index1));
				index1--;
			}
			while (index2 >= 0 && (id2 = child2open.get(index2).getBranchingNode().getId()) > id1) {
				result.add(child2open.get(index2));
				index2--;
			}

			// match: they share a common branching child
			if (id1 == id2) {
				didCloseABranch = true;
				
				// if this is the latest common child, remember it
				OptimizerNode currBanchingNode = child1open.get(index1).getBranchingNode();
				
				long vector1 = child1open.get(index1).getJoinedPathsVector();
				long vector2 = child2open.get(index2).getJoinedPathsVector();
				
				// check if this is the same descriptor, (meaning that it contains the same paths)
				// if it is the same, add it only once, otherwise process the join of the paths
				if (vector1 == vector2) {
					result.add(child1open.get(index1));
				}
				else {
					// we merge (re-join) a branch

					// mark the branch as a point where we break the pipeline
					if (markJoinedBranchesAsPipelineBreaking) {
						currBanchingNode.markAllOutgoingConnectionsAsPipelineBreaking();
					}

					if (this.hereJoinedBranches == null) {
						this.hereJoinedBranches = new ArrayList<OptimizerNode>(2);
					}
					this.hereJoinedBranches.add(currBanchingNode);

					// see, if this node closes the branch
					long joinedInputs = vector1 | vector2;

					// this is 2^size - 1, which is all bits set at positions 0..size-1
					long allInputs = (0x1L << currBanchingNode.getOutgoingConnections().size()) - 1;

					if (joinedInputs == allInputs) {
						// closed - we can remove it from the stack
						addClosedBranch(currBanchingNode);
					} else {
						// not quite closed
						result.add(new UnclosedBranchDescriptor(currBanchingNode, joinedInputs));
					}
				}

				index1--;
				index2--;
			}
		}

		// merged. now we need to reverse the list, because we added the elements in reverse order
		Collections.reverse(result);
		return didCloseABranch;
	}