Example usage for java.lang Math rint

List of usage examples for java.lang Math rint

Introduction

In this page you can find the example usage for java.lang Math rint.

Prototype

public static double rint(double a) 

Source Link

Document

Returns the double value that is closest in value to the argument and is equal to a mathematical integer.

Usage

From source file:com.screenslicer.core.scrape.Dissect.java

public static List<Result> perform(Element body, Node parent, List<Node> nodes, boolean lenientUrl,
        boolean lenientTitle, boolean trim, Map<String, Object> cache) {
    String baseParentHash = nodeHash(parent, nodes, lenientUrl, lenientTitle);
    String parentHashTrim = "nodeList-<<trim=true>>" + baseParentHash;
    String parentHashNoTrim = "nodeList-<<trim=false>>" + baseParentHash;
    if (trim && cache.containsKey(parentHashTrim)) {
        return (List<Result>) cache.get(parentHashTrim);
    }/*from  w w  w  .  jav a 2s. c  o  m*/
    if (!trim && cache.containsKey(parentHashNoTrim)) {
        return (List<Result>) cache.get(parentHashNoTrim);
    }
    List<Result> noTrimDissected = new ArrayList<Result>();
    List<Result> dissected = new ArrayList<Result>();
    double avgTitle = 0;
    double avgSummary = 0;
    if (trim && cache.containsKey(parentHashNoTrim)) {
        dissected = (List<Result>) cache.get(parentHashNoTrim);
        avgTitle = (Double) cache.get("dissectAvgTitle>>" + baseParentHash);
        avgSummary = (Double) cache.get("dissectAvgSummary>>" + baseParentHash);
    } else {
        dissected = Expand.perform(body, parent, nodes, lenientUrl, lenientTitle, cache);
        if (dissected.isEmpty()) {
            cache.put(parentHashTrim, dissected);
            cache.put(parentHashNoTrim, dissected);
            return dissected;
        }
        boolean useDDMMYYYY = true;
        for (Result cur : dissected) {
            if (!cur.isDDMMYYYY()) {
                useDDMMYYYY = false;
                break;
            }
        }
        if (useDDMMYYYY) {
            for (Result cur : dissected) {
                cur.useDDMMYYYY();
            }
        }
        for (Result cur : dissected) {
            if (cur.title() != null) {
                avgTitle += cur.title().trim().length();
            }
            if (cur.summary() != null) {
                avgSummary += cur.summary().trim().length();
            }
        }
        avgTitle /= dissected.size();
        avgSummary /= dissected.size();
        if (avgTitle > avgSummary && avgSummary > MIN_EXPECTED_FIELD) {
            for (Result cur : dissected) {
                cur.swapTitleAndSummary();
            }
            double tmp = avgTitle;
            avgTitle = avgSummary;
            avgSummary = tmp;
        }
        int totalAlt = 0;
        for (Result cur : dissected) {
            totalAlt += cur.isAltUrlAndTitle() ? 1 : 0;
        }
        boolean useAlt = totalAlt > dissected.size() / TWICE;
        for (Result cur : dissected) {
            cur.useAltUrlAndTitle(useAlt);
        }
        List<Double> avgTitleFallbacks = new ArrayList<Double>();
        Map<String, Integer> dupTitles = new HashMap<String, Integer>();
        double bestTitleFallbackAvg = 0d;
        int bestTitleFallbackIndex = -1;
        for (Result cur : dissected) {
            String title = cur.title();
            if (!dupTitles.containsKey(title)) {
                dupTitles.put(title, 0);
            }
            dupTitles.put(title, dupTitles.get(title).intValue() + 1);
            for (int i = 0; i < cur.altFallbackTitleCount(); i++) {
                if (i >= avgTitleFallbacks.size()) {
                    avgTitleFallbacks.add(0d);
                }
                if (cur.title() != null) {
                    double val = avgTitleFallbacks.get(i);
                    val += cur.altFallbackTitle(i).trim().length();
                    avgTitleFallbacks.remove(i);
                    avgTitleFallbacks.add(i, val);
                }
            }
        }
        for (int i = 0; i < avgTitleFallbacks.size(); i++) {
            double val = avgTitleFallbacks.get(i);
            val /= dissected.size();
            avgTitleFallbacks.remove(i);
            avgTitleFallbacks.add(i, val);
        }
        for (int i = 0; i < avgTitleFallbacks.size(); i++) {
            if (avgTitleFallbacks.get(i) > bestTitleFallbackAvg) {
                bestTitleFallbackAvg = avgTitleFallbacks.get(i);
                bestTitleFallbackIndex = i;
            }
        }
        boolean doFallback = (int) Math.rint(bestTitleFallbackAvg) > (int) Math.rint(avgTitle);
        int third = (int) Math.rint(((double) dissected.size()) / 3d);
        Map<String, Integer> dupFallbackTitles = new HashMap<String, Integer>();
        for (Result cur : dissected) {
            if (dupTitles.get(cur.title()) > third) {
                String fallbackTitle = cur.altFallbackTitle(bestTitleFallbackIndex);
                if (!dupFallbackTitles.containsKey(fallbackTitle)) {
                    dupFallbackTitles.put(fallbackTitle, 0);
                }
                dupFallbackTitles.put(fallbackTitle, dupFallbackTitles.get(fallbackTitle).intValue() + 1);
            }
        }
        double newTitleLen = 0;
        for (Result cur : dissected) {
            if (doFallback || (dupTitles.get(cur.title()) > third
                    && dupFallbackTitles.get(cur.altFallbackTitle(bestTitleFallbackIndex)) < third)) {
                cur.useAltFallbackUrlAndTitle(bestTitleFallbackIndex);
            }
            String newTitle = cur.title();
            newTitleLen += newTitle == null ? 0 : newTitle.length();
        }
        avgTitle = newTitleLen / (double) dissected.size();
        cache.put("dissectAvgTitle>>" + baseParentHash, avgTitle);
        cache.put("dissectAvgSummary>>" + baseParentHash, avgSummary);
        for (Result cur : dissected) {
            noTrimDissected.add(cur.copy());
        }
        cache.put(parentHashNoTrim, noTrimDissected);
    }
    if (!trim) {
        return noTrimDissected;
    }
    if (avgSummary > MIN_EXPECTED_AVG_SUMMARY || avgTitle > MIN_EXPECTED_AVG_TITLE) {
        List<Result> toRemove = new ArrayList<Result>();
        for (int i = 0; i < dissected.size(); i++) {
            String title = dissected.get(i).title();
            title = title == null ? "" : title;
            String summary = dissected.get(i).summary();
            String strippedSummary = summary == null ? ""
                    : uncountedText.matcher(summary).replaceAll("").trim();
            if (title.length() < MIN_EXPECTED_TITLE && strippedSummary.length() < MIN_EXPECTED_SUMMARY) {
                toRemove.add(dissected.get(i));
            }
        }
        for (Result cur : toRemove) {
            dissected.remove(cur);
        }
    }
    Map<String, Result> unique = new LinkedHashMap<String, Result>();
    for (Result cur : dissected) {
        unique.put(cur.url(), cur);
    }
    dissected = new ArrayList<Result>(unique.values());
    if (avgSummary > MIN_EXPECTED_FIELD || avgTitle > MIN_EXPECTED_FIELD) {
        Map<String, Integer> count = new HashMap<String, Integer>();
        for (Result cur : dissected) {
            String key = cur.title() + "<<>>" + cur.summary() + "<<>>" + cur.date();
            if (count.containsKey(key)) {
                count.put(key, count.get(key).intValue() + 1);
            } else {
                count.put(key, 1);
            }
        }
        double size = (double) dissected.size();
        List<Result> toRemove = new ArrayList<Result>();
        for (Map.Entry<String, Integer> entry : count.entrySet()) {
            if (((double) entry.getValue()) / size > SIGNIFICANT_RESULTS_RATIO) {
                for (Result cur : dissected) {
                    String key = cur.title() + "<<>>" + cur.summary() + "<<>>" + cur.date();
                    if (key.equals(entry.getKey())) {
                        toRemove.add(cur);
                    }
                }
            }
        }
        for (Result cur : toRemove) {
            dissected.remove(cur);
        }
    }
    if (dissected.size() > BANNED_SYMBOLS_FILTER_PREREQ_RESULT_NUM) {
        boolean firstBanned = false;
        boolean lastBanned = false;
        if (isBanned(dissected.get(0))) {
            firstBanned = true;
        }
        if (isBanned(dissected.get(dissected.size() - 1))) {
            lastBanned = true;
        }
        boolean otherBanned = false;
        for (int i = 1; i < dissected.size() - 1; i++) {
            if (isBanned(dissected.get(i))) {
                otherBanned = true;
                break;
            }
        }
        if (!otherBanned) {
            if (firstBanned) {
                dissected.remove(0);
            }
            if (lastBanned) {
                dissected.remove(dissected.size() - 1);
            }
        }

        int numRelative = 0;
        for (Result cur : dissected) {
            if (isRelativeUrl(cur.url())) {
                ++numRelative;
            }
        }
        double size = (double) dissected.size();
        List<Result> toRemove = new ArrayList<Result>();
        if ((((double) numRelative) / size) < HALF) {
            for (Result cur : dissected) {
                if (isRelativeUrl(cur.url())) {
                    toRemove.add(cur);
                }
            }
            for (Result cur : toRemove) {
                dissected.remove(cur);
            }
        }
        toRemove = new ArrayList<Result>();
        for (int i = 0; i < dissected.size(); i++) {
            boolean found = true;
            for (int j = 0; j < dissected.size(); j++) {
                if (i != j && !dissected.get(j).url().contains(dissected.get(i).url())) {
                    found = false;
                    break;
                }
            }
            if (found) {
                toRemove.add(dissected.get(i));
            }
        }
        for (Result cur : toRemove) {
            dissected.remove(cur);
        }
        toRemove = new ArrayList<Result>();
        int nullSummary = 0;
        for (Result cur : dissected) {
            if (CommonUtil.isEmpty(cur.summary())) {
                ++nullSummary;
            }
        }
        if (((double) nullSummary) / ((double) dissected.size()) < SIGNIFICANT_RESULTS_RATIO) {
            for (int i = 0; i < dissected.size(); i++) {
                if (CommonUtil.isEmpty(dissected.get(i).summary())) {
                    toRemove.add(dissected.get(i));
                } else {
                    break;
                }
            }
            for (int i = dissected.size() - 1; i >= 0; i--) {
                if (CommonUtil.isEmpty(dissected.get(i).summary())) {
                    toRemove.add(dissected.get(i));
                } else {
                    break;
                }
            }
            for (Result cur : toRemove) {
                dissected.remove(cur);
            }
        }
    }
    if (dissected.size() > CRITICAL_MASS) {
        int oneWordTitles = 0;
        int hashUrls = 0;
        List<Result> toRemoveTitles = new ArrayList<Result>();
        List<Integer> removedTitles = new ArrayList<Integer>();
        List<Integer> keptTitles = new ArrayList<Integer>();
        List<Result> toRemoveUrls = new ArrayList<Result>();
        List<Integer> removedUrls = new ArrayList<Integer>();
        List<Integer> keptUrls = new ArrayList<Integer>();
        int index = 0;
        int firstRemovedTitle = -1;
        int firstRemovedUrl = -1;
        for (Result cur : dissected) {
            if (cur.title() == null || cur.title().indexOf(' ') == -1) {
                ++oneWordTitles;
                toRemoveTitles.add(cur);
                removedTitles.add(index);
                firstRemovedTitle = index;
            } else {
                keptTitles.add(index);
            }
            if (cur.url().indexOf('#') != -1) {
                ++hashUrls;
                toRemoveUrls.add(cur);
                removedUrls.add(index);
                firstRemovedUrl = index;
            } else {
                keptUrls.add(index);
            }
            ++index;
        }
        int numOddTitles = 0;
        int numEvenTitles = 0;
        int numOddUrls = 0;
        int numEvenUrls = 0;
        boolean considerTitles = false;
        boolean considerUrls = false;
        if (oneWordTitles == dissected.size() / 2) {
            for (int i : removedTitles) {
                considerTitles = true;
                if (i % 2 == 0) {
                    ++numEvenTitles;
                } else {
                    ++numOddTitles;
                }
            }
            if (considerTitles && (numOddTitles == 0 || numEvenTitles == 0)) {
                numEvenTitles = 0;
                numOddTitles = 0;
                for (int i : keptTitles) {
                    if (i % 2 == 0) {
                        ++numEvenTitles;
                    } else {
                        ++numOddTitles;
                    }
                }
            } else {
                considerTitles = false;
            }
        }
        if (hashUrls == dissected.size() / 2) {
            for (int i : removedUrls) {
                considerUrls = true;
                if (i % 2 == 0) {
                    ++numEvenUrls;
                } else {
                    ++numOddUrls;
                }
            }
            if (considerUrls && (numOddUrls == 0 || numEvenUrls == 0)) {
                numEvenUrls = 0;
                numOddUrls = 0;
                for (int i : keptUrls) {
                    if (i % 2 == 0) {
                        ++numEvenUrls;
                    } else {
                        ++numOddUrls;
                    }
                }
            } else {
                considerUrls = false;
            }
        }
        int firstRemoved = -1;
        List<Result> toRemoveResults = null;
        if (considerTitles && (numOddTitles == 0 || numEvenTitles == 0)) {
            toRemoveResults = toRemoveTitles;
            firstRemoved = firstRemovedTitle;
        } else if (considerUrls && (numOddUrls == 0 || numEvenUrls == 0)) {
            toRemoveResults = toRemoveUrls;
            firstRemoved = firstRemovedUrl;
        }
        if (toRemoveResults != null) {
            for (Result cur : toRemoveResults) {
                int i = dissected.indexOf(cur);
                i += firstRemoved == 0 ? 1 : -1;
                if (i < dissected.size() && i > -1) {
                    if (!CommonUtil.isEmpty(cur.summary())) {
                        dissected.get(i).summaryMerge(cur.summaryNodes());
                    }
                    if (!CommonUtil.isEmpty(cur.date())) {
                        dissected.get(i).setDate(cur.date());
                    }
                    List<Node> curNodes = cur.getNodes();
                    for (Node curNode : curNodes) {
                        dissected.get(i).addLast(curNode);
                    }
                }
                dissected.remove(cur);
            }
        }
    }
    String[] summaries = new String[dissected.size()];
    int summaryIndex = 0;
    for (Result result : dissected) {
        summaries[summaryIndex++] = result.summary();
    }
    dedupStrings(summaries, true);
    dedupStrings(summaries, false);
    summaryIndex = 0;
    for (Result result : dissected) {
        result.setSummary(summaries[summaryIndex++]);
    }
    Util.trimLargeResults(dissected);
    cache.put(parentHashTrim, dissected);
    return dissected;
}

From source file:org.audiveris.omr.sheet.ScaleBuilder.java

private Integer computeBeam() {
    if (beamEntry != null) {
        return beamEntry.getKey();
    } else {/* ww  w .  java  2  s.  c  o m*/
        if (backPeak != null) {
            logger.info("{}{}", sheet.getLogPrefix(), "No beam peak found, computing a default value");

            return (int) Math.rint(0.7 * backPeak.getKey().best);
        } else {
            return null;
        }
    }
}

From source file:org.audiveris.omr.sheet.ScaleBuilder.java

private Scale.Range computeInterline() {
    if ((forePeak != null) && (backPeak != null)) {
        int min = (int) Math.rint(forePeak.getKey().first + backPeak.getKey().first);
        int best = (int) Math.rint(forePeak.getKey().best + backPeak.getKey().best);
        int max = (int) Math.rint(forePeak.getKey().second + backPeak.getKey().second);

        return new Scale.Range(min, best, max);
    } else {/* w  ww  .  java2  s  .  co m*/
        return null;
    }
}

From source file:com.eucalyptus.crypto.DefaultCryptoProvider.java

@Override
public X509Certificate generateCertificate(KeyPair keys, X500Principal subjectDn, X500Principal signer,
        PrivateKey signingKey, Date notAfter) {
    signer = (signingKey == null ? signer : subjectDn);
    signingKey = (signingKey == null ? keys.getPrivate() : signingKey);
    EventRecord.caller(DefaultCryptoProvider.class, EventType.GENERATE_CERTIFICATE, signer.toString(),
            subjectDn.toString()).info();
    X509V3CertificateGenerator certGen = new X509V3CertificateGenerator();
    certGen.setSerialNumber(BigInteger.valueOf(System.nanoTime()).shiftLeft(4)
            .add(BigInteger.valueOf((long) Math.rint(Math.random() * 1000))));
    certGen.setIssuerDN(signer);//from w w w  . ja  v  a  2s . c  o  m
    certGen.addExtension(X509Extensions.BasicConstraints, true, new BasicConstraints(true));
    try {
        certGen.addExtension(X509Extensions.SubjectKeyIdentifier, false,
                new SubjectKeyIdentifierStructure(keys.getPublic()));
    } catch (InvalidKeyException e) {
        LOG.error("Error adding subject key identifier extension.", e);
    }
    Calendar cal = Calendar.getInstance();
    certGen.setNotBefore(cal.getTime());
    certGen.setNotAfter(notAfter);
    certGen.setSubjectDN(subjectDn);
    certGen.setPublicKey(keys.getPublic());
    certGen.setSignatureAlgorithm(KEY_SIGNING_ALGORITHM);
    try {
        X509Certificate cert = certGen.generate(signingKey, PROVIDER);
        cert.checkValidity();
        return cert;
    } catch (Exception e) {
        LOG.fatal(e, e);
        return null;
    }
}

From source file:org.audiveris.omr.sheet.ScaleBuilder.java

/**
 * Compute the range for line thickness.
 * The computation of line max is key for the rest of the application,
 * since it governs the threshold between horizontal and vertical lags.
 *
 * @return the line range/*w  ww.  j a v a  2  s  .c o  m*/
 */
private Scale.Range computeLine() {
    if (forePeak != null) {
        int min = (int) Math.rint(forePeak.getKey().first);
        int best = (int) Math.rint(forePeak.getKey().best);
        int max = (int) Math.ceil(forePeak.getKey().second);

        return new Scale.Range(min, best, max);
    } else {
        return null;
    }
}

From source file:org.orekit.frames.CIRF2000Frame.java

/** Set the reference points array.
 * @param t offset from J2000.0 epoch in seconds
 *//*  w w w. ja v  a  2s  .  co m*/
private void setReferencePoints(final double t) {

    final int n = xRef.length;
    final int nM12 = (n - 1) / 2;

    // evaluate new location of center interval
    final double newTCenter = h * Math.floor(t / h);

    // shift reusable reference points
    int iMin = 0;
    int iMax = n;
    final int shift = (int) Math.rint((newTCenter - tCenter) / h);
    if (!Double.isNaN(tCenter) && (Math.abs(shift) < n)) {
        if (shift >= 0) {
            System.arraycopy(xRef, shift, xRef, 0, n - shift);
            System.arraycopy(yRef, shift, yRef, 0, n - shift);
            System.arraycopy(sRef, shift, sRef, 0, n - shift);
            iMin = n - shift;
        } else {
            System.arraycopy(xRef, 0, xRef, -shift, n + shift);
            System.arraycopy(yRef, 0, yRef, -shift, n + shift);
            System.arraycopy(sRef, 0, sRef, -shift, n + shift);
            iMax = -shift;
        }
    }

    // compute new reference points
    tCenter = newTCenter;
    for (int i = iMin; i < iMax; ++i) {
        computePoleCoordinates(tCenter + (i - nM12) * h);
        xRef[i] = xCurrent;
        yRef[i] = yCurrent;
        sRef[i] = sCurrent;
    }

}

From source file:org.intermine.modelviewer.swing.ModelViewer.java

/**
 * Display the given class in the main window. This does not
 * change the selection in the class tree.
 * /*from   w ww.j  ava2s .com*/
 * @param modelClass The class to display.
 */
public void displayClass(ModelClass modelClass) {

    graphNodes.clear();

    final int width = 80;
    final int height = 36;
    final int xcentre = 200;
    final int yboundary = 20;
    final int ycentre = 200;

    graphModel.beginUpdate();
    try {
        graphModel.clear();

        //int maxDepth = modelClass.getDepth();

        Object parent = graph.getDefaultParent();

        ModelClass mc = modelClass;
        mxICell mainCell = hierarchyNodes(xcentre, ycentre, mc, width, height, yboundary);

        List<ForeignKey> allRefs = new ArrayList<ForeignKey>(modelClass.getCollections().values());
        allRefs.addAll(modelClass.getReferences().values());

        int refCount = allRefs.size();
        int collectionCount = modelClass.getCollections().size();
        double step, startAngle;
        if (refCount == 1) {
            step = 0;
            startAngle = Math.PI;
        } else if (refCount <= 5) {
            step = Math.PI * 0.9 / (refCount - 1);
            startAngle = Math.PI * 0.55;
        } else {
            step = Math.PI * 1.5 / (refCount - 1);
            startAngle = Math.PI / 4;
        }
        Iterator<ForeignKey> refIter = allRefs.iterator();

        for (int collNo = 0; refIter.hasNext(); collNo++) {
            ForeignKey key = refIter.next();
            boolean isCollection = collNo < collectionCount;

            int x = xcentre + (int) Math.rint(2 * width * Math.sin(startAngle + step * collNo));
            int y = (int) mainCell.getGeometry().getY()
                    - (int) Math.rint(2 * width * Math.cos(startAngle + step * collNo));

            /*
            ModelClass otherClass = modelClasses.get(key.getReferencedType().getName());
            if (modelClass.equals(otherClass)) {
            String style =
                isCollection ? SELF_COLLECTION_EDGE_STYLE : SELF_REFERENCE_EDGE_STYLE;
            graph.insertEdge(parent, null, key.getName(), mainCell, mainCell, style);
            } else {
            */
            mxICell otherCell = (mxICell) graph.createVertex(parent, key.getReferencedType().getName(),
                    key.getReferencedType(), x, y, width, height, null);
            graph.addCell(otherCell);
            graphNodes.put(key.getReferencedType().getName(), otherCell);

            String style = isCollection ? COLLECTION_EDGE_STYLE : REFERENCE_EDGE_STYLE;
            graph.insertEdge(parent, null, key.getName(), mainCell, otherCell, style);
            //}
        }
    } finally {
        graphModel.endUpdate();
    }

    attributeTableModel.setModelClass(modelClass);
    referenceTableModel.setModelClass(modelClass);
    graphComponent.scrollCellToVisible(graphNodes.get(modelClass.getName()));
}

From source file:com.chinamobile.bcbsp.ml.math.DenseDoubleVector.java

/**
 * @return a new vector which has rinted each element.
 *//*from w w  w .j ava  2  s .  c  o  m*/
public DenseDoubleVector rint() {
    DenseDoubleVector v = new DenseDoubleVector(getLength());
    for (int i = 0; i < getLength(); i++) {
        double d = vector[i];
        v.set(i, Math.rint(d));
    }
    return v;
}

From source file:org.audiveris.omr.sheet.ScaleBuilder.java

private Scale.Range computeSecondInterline() {
    if (secondBackPeak != null) {
        int min = (int) Math.rint(forePeak.getKey().first + secondBackPeak.getKey().first);
        int best = (int) Math.rint(forePeak.getKey().best + secondBackPeak.getKey().best);
        int max = (int) Math.rint(forePeak.getKey().second + secondBackPeak.getKey().second);

        return new Scale.Range(min, best, max);
    } else {/*w  ww .j a  v a 2s  .  co m*/
        return null;
    }
}

From source file:sadl.modellearner.rtiplus.SimplePDRTALearner.java

protected NavigableSet<Refinement> getSplitRefs(Transition t, StateColoring sc) {

    final NavigableSet<Refinement> refs = new TreeSet<>();
    //sequential/*w  w  w  .  ja v  a 2  s  . c o  m*/
    final Iterator<Integer> it = t.in.getTails().keySet().iterator();
    if (it.hasNext()) {
        int last = it.next().intValue();
        while (it.hasNext()) {
            final int cur = it.next().intValue();
            int splitTime = -1;
            switch (splitPos) {
            case LEFT:
                splitTime = last;
                break;
            case MIDDLE:
                splitTime = (int) Math.rint(((cur - last) - 1) / 2.0) + last;
                break;
            case RIGHT:
                splitTime = cur - 1;
                break;
            default:
                splitTime = (int) Math.rint(((cur - last) - 1) / 2.0) + last;
                break;
            }
            double score = tester.testSplit(t.source, t.symAlphIdx, splitTime);
            if (mainModel == t.ta) {
                logger.trace("Score: {} (SPLIT {} @ ({},{}))", score, t.source.getIndex(),
                        t.ta.getSymbol(t.symAlphIdx), splitTime);
            }
            if (score < significance && score >= 0) {
                score = (significance - score) / significance;
                final Refinement ref = new Refinement(t.source, t.symAlphIdx, splitTime, score, sc);
                refs.add(ref);
            }
            last = cur;
        }
        //parallel (not yet checked for determinism)
        // final TIntList splitTimes = new TIntArrayList();
        // if (it.hasNext()) {
        // int last = it.next();
        // while (it.hasNext()) {
        // final int cur = it.next();
        // int splitTime = -1;
        // switch (splitPos) {
        // case LEFT:
        // splitTime = last;
        // break;
        // case MIDDLE:
        // splitTime = (int) Math.rint(((cur - last) - 1) / 2.0) + last;
        // break;
        // case RIGHT:
        // splitTime = cur - 1;
        // break;
        // default:
        // splitTime = (int) Math.rint(((cur - last) - 1) / 2.0) + last;
        // break;
        // }
        // splitTimes.add(splitTime);
        // last = cur;
        // }
        // // final NavigableSet<Refinement> safeRefs = Collections.synchronizedNavigableSet(refs);
        // Arrays.stream(splitTimes.toArray()).parallel().forEach(splitTime -> {
        // double score = tester.testSplit(t.source, t.symAlphIdx, splitTime);
        // if (mainModel == t.ta) {
        // logger.trace("Score: {} (SPLIT {} @ ({},{}))", score, t.source.getIndex(), t.ta.getSymbol(t.symAlphIdx), splitTime);
        // }
        // if (score < significance && score >= 0) {
        // score = (significance - score) / significance;
        // final Refinement ref = new Refinement(t.source, t.symAlphIdx, splitTime, score, sc);
        // l2.lock();
        // refs.add(ref);
        // l2.unlock();
        // // safeRefs.add(ref);
        // }
        // });
    }
    return refs;
}