Merges two {@link StatValueAO} lists, by cumulating corresponding values.
@param firstStat List of {@link StatValueAO}
@param secondStat List of {@link StatValueAO}
14020
private List<StatValueAO> mergeStatValues(List<StatValueAO> firstStat, List<StatValueAO> secondStat) {
        // If stats are null or not of the same type return nothing
        if (firstStat == null || secondStat == null) {
            return new ArrayList<>();
        }

        List<StatValueAO> result = new ArrayList<>();
        for (StatValueAO firstStatValue : firstStat) {
            for (StatValueAO secondStatValue : secondStat) {
                // If it's one stat value type cumulate them
                if (firstStatValue.getName().equals(secondStatValue.getName())) {
                    try {
                        // Stat value equals NoR, just set it
                        if ("NoR".equals(firstStatValue.getValue()) || "NoR".equals(secondStatValue.getValue())) {
                            final StatValueAO norValue = new LongValueAO(firstStatValue.getName(), Long.MAX_VALUE);
                            result.add(norValue);
                        } else if (firstStatValue instanceof LongValueAO && secondStatValue instanceof LongValueAO) {
                            Number firstStatNumber = NumberFormat.getNumberInstance(Locale.US).parse(firstStatValue.getValue());
                            Number secondStatNumber = NumberFormat.getNumberInstance(Locale.US).parse(secondStatValue.getValue());
                            final StatValueAO sumValue = new LongValueAO(firstStatValue.getName(), firstStatNumber.longValue() + secondStatNumber.longValue());

                            result.add(sumValue);
                        } else if (firstStatValue instanceof DoubleValueAO && secondStatValue instanceof DoubleValueAO) {
                            Number firstStatNumber = NumberFormat.getNumberInstance(Locale.US).parse(firstStatValue.getValue());
                            Number secondStatNumber = NumberFormat.getNumberInstance(Locale.US).parse(secondStatValue.getValue());
                            final StatValueAO sumValue = new DoubleValueAO(firstStatValue.getName(), firstStatNumber.doubleValue() + secondStatNumber.doubleValue());

                            result.add(sumValue);
                        }
                    }
                    catch (ParseException ex) {
                        LOGGER.warn("Can't parse stat values: " + firstStatValue.getValue() + " and " + secondStatValue.getValue());
                    }
                }
            }
        }

        return result;
    }
114529
private synchronized void initCounterState(Long currentValue) {
      if (weakCounter == null) {
         weakCounter = currentValue == null ?
               newCounterValue(configuration) :
               newCounterValue(currentValue, configuration);
      }
   }
510646
protected String concat(String first, String second) {
        return first == null ? second : String.format("%s.%s", first, second);
    }
555801
@Override
    public DescriptorValue calculate(IAtom first, IAtom second, IAtomContainer atomContainer) {
        IAtomContainer ac;
        try {
            ac = (IAtomContainer) atomContainer.clone();
        } catch (CloneNotSupportedException e) {
            return getDummyDescriptorValue(e);
        }
        IAtom clonedFirst = ac.getAtom(atomContainer.indexOf(first));
        IAtom clonedSecond = ac.getAtom(atomContainer.indexOf(first));

        IAtomContainer mol = ac.getBuilder().newInstance(IAtomContainer.class, ac);
        if (checkAromaticity) {
            try {
                AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
                Aromaticity.cdkLegacy().apply(mol);
            } catch (CDKException e) {
                return getDummyDescriptorValue(e);
            }
        }
        boolean piContact = false;
        int counter = 0;

        if (acold != ac) {
            acold = ac;
            acSet = ConjugatedPiSystemsDetector.detect(mol);
        }
        java.util.Iterator<IAtomContainer> detected = acSet.atomContainers().iterator();

        List<IAtom> neighboorsFirst = mol.getConnectedAtomsList(clonedFirst);
        List<IAtom> neighboorsSecond = mol.getConnectedAtomsList(clonedSecond);

        while (detected.hasNext()) {
            IAtomContainer detectedAC = detected.next();
            if (detectedAC.contains(clonedFirst) && detectedAC.contains(clonedSecond)) {
                counter += 1;
                break;
            }
            if (isANeighboorsInAnAtomContainer(neighboorsFirst, detectedAC)
                    && isANeighboorsInAnAtomContainer(neighboorsSecond, detectedAC)) {
                counter += 1;
                break;
            }
        }

        if (counter > 0) {
            piContact = true;
        }
        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new BooleanResult(
                piContact), getDescriptorNames());
    }
787788
public static void swap(final int[][] array, final long first, final long second)
    {
        final int t = array[segment(first)][displacement(first)];
        array[segment(first)][displacement(first)] = array[segment(second)][displacement(second)];
        array[segment(second)][displacement(second)] = t;
    }
949666
void combine(final MomentStatistics b) {
		requireNonNull(b);

		final double m2 = _m2.value();
		final double m3 = _m3.value();

		final double pn = _n;
		final double n = _n + b._n;
		final double nn = n*n;

		final double d = b._m1.value() - _m1.value();
		final double dd = d*d;

		_n += b._n;

		_m1.add(d*b._n/n);

		_m2.add(b._m2).add(dd*pn*b._n/n);

		_m3.add(b._m3)
			.add(dd*d*(pn*b._n*(pn - b._n)/nn))
			.add(3.0*d*(pn*b._m2.value() - b._n*m2)/n);

		final double bnbn = (double)b._n*(double)b._n;

		_m4.add(b._m4)
			.add(dd*dd*(pn*b._n*(pn*pn - pn*b._n + bnbn)/(nn*n)))
			.add(6.0*dd*(pn*pn*b._m2.value() + bnbn*m2)/nn)
			.add(4.0*d*(pn*b._m3.value() - b._n*m3)/n);
	}
838098
public LCMSDataSubset merge(LCMSDataSubset other) {
    LCMSDataSubset merged = new LCMSDataSubset();

    Set<Integer> msLvlsThis = getMsLvls();
    Set<Integer> msLvlsThat = other.getMsLvls();
    // only merge if both are not null, otherwise null signifies the whole
    // run, so we can keep it null in the merged version
    if (msLvlsThis != null && msLvlsThat != null) {
      HashSet<Integer> mergedMsLvls = new HashSet<>(msLvlsThis);
      mergedMsLvls.addAll(msLvlsThat);
      merged.setMsLvls(mergedMsLvls);
    }

    // merge mz ranges
    List<DoubleRange> mzRangesThis = getMzRanges();
    List<DoubleRange> mzRangesThat = other.getMzRanges();
    if (mzRangesThis != null && mzRangesThat != null) {
      ArrayList<DoubleRange> mergedMzRanges = new ArrayList<>(mzRangesThis);
      mergedMzRanges.addAll(mzRangesThat);
      merged.setMzRanges(mergedMzRanges);
    }

    // compare scan number ranges
    Integer scanNumLoThis = getScanNumLo();
    Integer scanNumLoThat = other.getScanNumLo();
    if (scanNumLoThis != null && scanNumLoThat != null) {
      merged.setScanNumLo(Math.min(scanNumLoThis, scanNumLoThat));
    }
    Integer scanNumHiThis = getScanNumHi();
    Integer scanNumHiThat = other.getScanNumHi();
    if (scanNumHiThis != null && scanNumHiThat != null) {
      merged.setScanNumHi(Math.max(scanNumHiThis, scanNumHiThat));
    }

    return merged;
  }
881501
public void combine(WSStatistic otherStat) {
        if (!validate(otherStat))
            return;

        CountStatisticImpl other = (CountStatisticImpl) otherStat;
        count += other.count;

        // Compare lastSampleTime
        if (other.lastSampleTime > lastSampleTime)
            lastSampleTime = other.lastSampleTime;
    }
654071
public double setCount(F first, S second, double value) {
        Counter<S> counter = maps.get(first);
        if (counter == null) {
            counter = new Counter<S>();
            maps.put(first, counter);
        }

        return counter.setCount(second, value);
    }
226416
@Nullable
  public com.simiacryptus.util.data.ScalarStatistics add(@javax.annotation.Nonnull final double... values) {
    double v1 = 0;
    double v2 = 0;
    double vmax = max;
    double vmin = max;
    int z = 0;
    double vlog = 0;
    int n = 0;
    int p = 0;
    for (final double v : values) {
      v1 += v;
      v2 += v * v;
      vmin = Math.min(min, v);
      vmax = Math.max(max, v);
      if (Math.abs(v) < com.simiacryptus.util.data.ScalarStatistics.zeroTol) {
        z++;
      }
      else {
        if (v < 0) {
          n++;
        }
        else {
          p++;
        }
        vlog += Math.log10(Math.abs(v));
      }
    }
    synchronized (this) {
      sum0 += values.length;
      sum1 += v1;
      sum2 += v2;
      min = Math.min(min, vmin);
      max = Math.max(max, vmax);
      negatives += n;
      positives += p;
      sumLog += vlog;
      zeros += z;
    }
    return this;
  }
771385
private void mergeInstantFields() {
        if (fieldValues.containsKey(INSTANT_SECONDS)) {
            if (zone != null) {
                mergeInstantFields0(zone);
            } else {
                Long offsetSecs = fieldValues.get(OFFSET_SECONDS);
                if (offsetSecs != null) {
                    ZoneOffset offset = ZoneOffset.ofTotalSeconds(offsetSecs.intValue());
                    mergeInstantFields0(offset);
                }
            }
        }
    }
523681
public void combine(SpdStat other) {
        if (other == null)
            return;
        if (stat.isEnabled() && other.isEnabled())
            //stat.combine((TimeStatisticImpl)other.getStatistic());
            stat.combine(other.getStatistic());
    }
1320746
public void addFirstAndLast(final CalendarDay first, final CalendarDay last) {
    list.clear();
    list.add(first);
    list.add(last);
  }
743503
public static <T> boolean isEqual(final T first, final T second) {
        /* test to see if they are both null, or both reference the same object */
        if (first == second) return true;

        if (first == null && second != null) return false;

        return first.equals(second);
    }
736819
public static ListValue of(Blob first, Blob... other) {
    return newBuilder().addValue(first, other).build();
  }
717843
public void addPair(String first, String second)
    {
        Map<String, Integer> firstMatrix = transferMatrix.get(first);
        if (firstMatrix == null)
        {
            firstMatrix = new TreeMap<String, Integer>();
            transferMatrix.put(first, firstMatrix);
        }
        Integer frequency = firstMatrix.get(second);
        if (frequency == null) frequency = 0;
        firstMatrix.put(second, frequency + 1);
    }
945775
public static float getScore(String first, String second) {
        int frequency = getFrequency(first, second);
        float score = frequency/(float)maxFrequency;
        if(LOGGER.isDebugEnabled()) {
            if(score>0) {
                LOGGER.debug("二元模型 " + first + ":" + second + " 获得分值：" + score);
            }
        }
        return score;
    }