当前位置: 首页>>代码示例>>Java>>正文


Java Pair类代码示例

本文整理汇总了Java中jloda.util.Pair的典型用法代码示例。如果您正苦于以下问题:Java Pair类的具体用法?Java Pair怎么用?Java Pair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Pair类属于jloda.util包,在下文中一共展示了Pair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import jloda.util.Pair; //导入依赖的package包/类
public void apply(NexusStreamParser np) throws Exception {
    np.matchIgnoreCase("changeMapping taxName=");
    String taxonName = np.getWordRespectCase();
    np.matchIgnoreCase("taxId=");
    int taxId = np.getInt();
    np.matchIgnoreCase(";");

    System.err.println("Changing taxon mapping of '" + taxonName + " from " + TaxonomyData.getName2IdMap().get(taxonName) + " to " + taxId);
    TaxonomyData.getName2IdMap().put(taxonName, taxId);
    TaxonomyData.setTaxonomicRank(taxId, (byte) 0);

    Collection<Pair<String, String>> mappingFixes = new LinkedList<>();
    mappingFixes = ProgramProperties.get(MeganProperties.TAXON_MAPPING_CHANGES, mappingFixes);
    boolean found = false;
    for (Pair<String, String> pair : mappingFixes) {
        if (pair.getFirst().equals(taxonName)) {
            pair.setSecond("" + taxId);
            found = true;
            break;
        }
    }
    if (!found)
        mappingFixes.add(new Pair<>(taxonName, "" + taxId));
    ProgramProperties.put(MeganProperties.TAXON_MAPPING_CHANGES, mappingFixes);
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:26,代码来源:ChangeTaxonMappingCommand.java

示例2: setCurrentLabel

import jloda.util.Pair; //导入依赖的package包/类
/**
 * set the label of the current object
 *
 * @param newLabel
 */
public void setCurrentLabel(final String newLabel) {
    final Pair<Integer, Integer> cell = new Pair<>(current.getFirst(), current.getSecond());

    final Runnable runnable = new Runnable() {
        @Override
        public void run() {
            table.getGrid().getRows().get(cell.getFirst()).get(cell.getSecond()).setItem(newLabel);
        }
    };
    if (Platform.isFxApplicationThread())
        runnable.run();
    else
        Platform.runLater(runnable);

}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:21,代码来源:SpreadSheetSearcher.java

示例3: getCountAndPos

import jloda.util.Pair; //导入依赖的package包/类
/**
 * gets the count and pos for the given class in the given classification
 *
 * @param rma2File
 * @param classification
 * @param classId
 * @return (count, pos) or null
 * @throws java.io.IOException
 */
public static Pair<Integer, Long> getCountAndPos(RMA2File rma2File, String classification, int classId) throws IOException {

    try (IInputReader r = rma2File.getClassificationIndexReader(classification)) {
        int size = rma2File.getClassificationSize(classification);
        for (int i = 0; i < size; i++) {
            int id = r.readInt();
            int count = r.readInt();
            if (count < 0) {
                count = r.readInt();
            }
            long pos = r.readLong();
            if (id == classId)
                return new Pair<>(count, pos);
        }
        return null;
    }
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:27,代码来源:ClassificationBlockRMA2.java

示例4: next

import jloda.util.Pair; //导入依赖的package包/类
/**
 * Returns the next element in the iteration.
 *
 * @return the next element in the iteration.
 * @throws java.util.NoSuchElementException iteration has no more elements.
 */
public Pair<Integer, List<Long>> next() {
    try {
        classesProcessed++;
        Integer key = iterator.next();
        long pos = classificationBlockRMA2.getPos(key);
        int count = classificationBlockRMA2.getSum(key);

        classDumpReader.seek(pos);
        List<Long> list = new LinkedList<>();
        for (int i = 0; i < count; i++)
            list.add(classDumpReader.readLong());

        return new Pair<>(key, list);
    } catch (Exception e) {
        Basic.caught(e);
        error = true;
        return null;
    }
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:26,代码来源:ClassReadIdIteratorRMA2.java

示例5: hasNext

import jloda.util.Pair; //导入依赖的package包/类
/**
 * Returns <tt>true</tt> if the iteration has more elements. (In other
 * words, returns <tt>true</tt> if <tt>next</tt> would return an element
 * rather than throwing an exception.)
 *
 * @return <tt>true</tt> if the getLetterCodeIterator has more elements.
 */
public boolean hasNext() {
    if (error || currentClass == null)
        return false;
    if (currentCount < currentClass.getFirst())
        return true;
    currentClass = null;
    while (classes.size() > 0) {
        currentCount = 0;
        Pair<Integer, Long> next = classes.remove(0);
        if (next != null && next.getFirst() > 0 && next.getSecond() >= 0) {
            try {
                classDumpReader.seek(next.getSecond());
            } catch (IOException e) {
                Basic.caught(e);
                return false;
            }
            currentClass = next;
            return true;
        }
    }
    return false;
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:30,代码来源:ReadBlockIteratorRMA2.java

示例6: write

import jloda.util.Pair; //导入依赖的package包/类
/**
 * write the current header data
 *
 * @param writer
 * @return position of beginning of block
 * @throws IOException
 */
public void write(IOutputWriter writer) throws IOException {
    writer.writeInt(RMA2File.MAGIC_NUMBER);
    writer.writeInt(3);
    writer.writeString(getFormatDef());

    FormatDefinition formatDefinition = FormatDefinition.fromString(getFormatDef());
    formatDefinition.startWrite();
    for (Pair<String, FormatDefinition.Type> pair : formatDefinition.getList()) {
        if (pair.getFirst().equals("Creator"))
            formatDefinition.write(writer, "Creator", getCreator());
        else if (pair.getFirst().equals("CreationDate"))
            formatDefinition.write(writer, "CreationDate", getCreationDate());
    }
    formatDefinition.finishWrite();
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:23,代码来源:FileHeaderRMA3.java

示例7: setEnabledSeries

import jloda.util.Pair; //导入依赖的package包/类
public void setEnabledSeries(Collection<String> seriesNames) {
    this.seriesNames.clear();
    this.seriesNames.addAll(seriesNames);

    // need to update the total range of values:
    for (String series : seriesNames) {
        Pair<Number, Number> rangeXd = series2RangeX.get(series);
        Pair<Number, Number> rangeYd = series2RangeY.get(series);
        if (rangeX.get1().doubleValue() == 0 && rangeX.get2().doubleValue() == 0)
            rangeX.set(rangeXd.get1(), rangeXd.get2());
        else
            rangeX.set(Math.min(rangeX.get1().doubleValue(), rangeXd.get1().doubleValue()), Math.max(rangeX.get2().doubleValue(), rangeXd.get2().doubleValue()));
        if (rangeY.get1().doubleValue() == 0 && rangeY.get2().doubleValue() == 0)
            rangeY.set(rangeYd.get1(), rangeYd.get2());
        else
            rangeY.set(Math.min(rangeY.get1().doubleValue(), rangeYd.get1().doubleValue()), Math.max(rangeY.get2().doubleValue(), rangeYd.get2().doubleValue()));
    }
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:19,代码来源:DefaultPlot2DData.java

示例8: setEnabledClassNames

import jloda.util.Pair; //导入依赖的package包/类
public void setEnabledClassNames(Collection<String> classNames) {
    this.classNames.clear();
    this.classNames.addAll(classNames);

    range = null;

    for (String series : seriesNames) {
        double total = 0;
        for (String className : classNames) {
            Number value = getValue(series, className);
            if (value != null) {
                total += value.doubleValue();
                if (range == null) {
                    range = new Pair<>(value, value);
                } else {
                    if (value.doubleValue() < range.get1().doubleValue())
                        range.set1(value);
                    if (value.doubleValue() > range.get2().doubleValue())
                        range.set2(value);
                }
            }
            series2size.put(series, total);
        }
    }
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:26,代码来源:DefaultChartData.java

示例9: setEnabledSeries

import jloda.util.Pair; //导入依赖的package包/类
public void setEnabledSeries(Collection<String> seriesNames) {
    this.seriesNames.clear();
    this.seriesNames.addAll(seriesNames);

    range = null;

    for (String className : classNames) {
        double total = 0;
        for (String series : seriesNames) {
            Number value = getValue(series, className);
            if (value != null) {
                total += value.doubleValue();

                if (range == null) {
                    range = new Pair<>(value, value);
                } else {
                    if (value.doubleValue() < range.get1().doubleValue())
                        range.set1(value);
                    if (value.doubleValue() > range.get2().doubleValue())
                        range.set2(value);
                }
            }
        }
        classes2size.put(className, total);
    }
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:27,代码来源:DefaultChartData.java

示例10: startRemoteSearch

import jloda.util.Pair; //导入依赖的package包/类
/**
 * launch the search
 *
 * @param queries
 * @return request Id
 */
public String startRemoteSearch(Collection<Pair<String, String>> queries) throws IOException {
    if (queries.size() == 0)
        return null;
    final StringBuilder query = new StringBuilder();
    for (Pair<String, String> pair : queries) {
        query.append(">").append(Basic.swallowLeadingGreaterSign(pair.get1().trim())).append("\n").append(pair.get2().trim()).append("\n");
    }
    requestId = null;
    estimatedTime = -1;
    actualTime = -1;
    startTime = System.currentTimeMillis();

    final Map<String, Object> params = new HashMap<>();
    params.put("CMD", "Put");
    params.put("PROGRAM", program.toString());
    params.put("DATABASE", database);
    params.put("QUERY", query.toString());
    final String response = postRequest(baseURL, params);
    requestId = parseRequestId(response);
    if (requestId == null)
        throw new IOException("Failed to obtain valid requestId");
    estimatedTime = parseEstimatedTime(response);

    return requestId;
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:32,代码来源:RemoteBlastClient.java

示例11: getHeaderAndSequence

import jloda.util.Pair; //导入依赖的package包/类
/**
 * gets the header and sequence for a read
 *
 * @param location
 * @return header and sequence
 * @throws IOException
 */
public void getHeaderAndSequence(Location location, Pair<String, String> headerAndSequence) throws IOException {
    String string = getText(location);

    if (string == null) {
        headerAndSequence.setFirst(">Unknown");
        headerAndSequence.setSecond("Unknown");
    } else {
        int eol = string.indexOf('\n'); // header is first line
        if (eol <= 0) {
            headerAndSequence.setFirst(string);
            headerAndSequence.setSecond(null);
        } else {
            headerAndSequence.setFirst(string.substring(0, eol));
            headerAndSequence.setSecond(string.substring(eol + 1, string.length()));
        }
    }
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:25,代码来源:TextStorageReader.java

示例12: getReadBlock

import jloda.util.Pair; //导入依赖的package包/类
/**
 * gets the read block associated with the given uid
 *
 * @param uid or -1, if in streaming mode
 * @return read block or null
 * @throws IOException
 */
@Override
public IReadBlock getReadBlock(long uid) throws IOException {
    if (uid == -1) {
        if (!streamOnly)
            throw new IOException("getReadBlock(uid=" + uid + ") failed: not streamOnly");
    } else {
        if (streamOnly) {
            throw new IOException("getReadBlock(uid=" + uid + ") failed: streamOnly");
        }
        reader.seek(uid);
    }

    if (reader.getPosition() < end) {
        if (uid >= 0) {
            if (streamOnly)
                throw new IOException("getReadBlock(uid=" + uid + ") failed: streamOnly");
        }
        final ReadBlockDAA readBlock = (reuseableReadBlock == null ? new ReadBlockDAA() : reuseableReadBlock);

        final Pair<DAAQueryRecord, DAAMatchRecord[]> pair = daaParser.readQueryAndMatches(reader, refReader, daaMatchRecords.length, inputBuffer, daaMatchRecords, longReads);
        readBlock.setFromQueryAndMatchRecords(pair.get1(), pair.get2(), wantReadSequences, wantMatches, minScore, maxExpected);
        return readBlock;
    }
    return null;
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:33,代码来源:ReadBlockGetterDAA.java

示例13: next

import jloda.util.Pair; //导入依赖的package包/类
@Override
public Pair<byte[], byte[]> next() {
    synchronized (DAAParser.SENTINEL_SAM_ALIGNMENTS) {
        if (next == null || next == DAAParser.SENTINEL_SAM_ALIGNMENTS)
            return null;
        count++;
        Pair<byte[], byte[]> result;
        result = next;
        try {
            next = queue.take();
        } catch (InterruptedException e) {
            Basic.caught(e);
        }
        return result;
    }
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:17,代码来源:DAA2QuerySAMIterator.java

示例14: generateSortedAttribute2taxa2values

import jloda.util.Pair; //导入依赖的package包/类
/**
 * Fills a new sorted map with the sorted set of taxa2values for each
 * attribute.
 */
private void generateSortedAttribute2taxa2values() {
    String[] taxa;
    int[] values;
    for (String att_kind : attribute2taxa2value.keySet()) {
        Map<String, Number> taxa2values = attribute2taxa2value.get(att_kind);
        taxa = new String[taxa2values.size()];
        values = new int[taxa2values.size()];
        int i = 0;
        for (String taxname : taxa2values.keySet()) {
            taxa[i] = taxname;
            values[i] = taxa2values.get(taxname).intValue();
            i++;
        }
        doInsertionSort(taxa, values);
        attribute2SortedTaxValPair.put(att_kind, new Pair<>(taxa, values));
    }
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:22,代码来源:AttributesWindow.java

示例15: next

import jloda.util.Pair; //导入依赖的package包/类
/**
 * gets next fastA record
 *
 * @return header and sequence
 */
public Pair<String, String> next() {
    try {
        currentHeaderPosition = nextHeaderPosition;
        String readHeader = nextLine;
        nextHeaderPosition += readHeader.length() + endOfLineBytes;
        readHeader = ">" + readHeader.substring(1);
        String readSequence = r.readLine();
        nextHeaderPosition += readSequence.length() + endOfLineBytes;
        String comments = r.readLine();
        nextHeaderPosition += comments.length() + endOfLineBytes;
        if (comments.startsWith("+")) {
            String qualityValues = r.readLine();
            nextHeaderPosition += qualityValues.length() + endOfLineBytes;
        }
        nextLine = r.readLine();
        return new Pair<>(readHeader, readSequence);

    } catch (IOException e) {
        Basic.caught(e);
    }
    return null;
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:28,代码来源:FastQAsFastAFileIterator.java


注:本文中的jloda.util.Pair类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。