Example usage for java.util List subList

List of usage examples for java.util List subList

Introduction

In this page you can find the example usage for java.util List subList.

Prototype

List<E> subList(int fromIndex, int toIndex);

Source Link

Document

Returns a view of the portion of this list between the specified fromIndex , inclusive, and toIndex , exclusive.

Usage

From source file:com.mapr.synth.samplers.SsnSampler.java

public SsnSampler() {
    Splitter onComma = Splitter.on(",").trimResults();
    try {//from   w  w  w  .j  av  a2 s .  co  m
        names = null;
        for (String line : Resources.readLines(Resources.getResource("ssn-seeds"), Charsets.UTF_8)) {
            if (line.startsWith("#")) {
                // last comment line contains actual field names
                names = Lists.newArrayList(onComma.split(line.substring(1)));
            } else {
                Preconditions.checkState(names != null);
                assert names != null;

                List<String> fields = Lists.newArrayList(onComma.split(line));
                for (int i = Integer.parseInt(fields.get(1)); i <= Integer.parseInt(fields.get(1)); i++) {
                    String key = String.format("%03d", i);
                    values.put(key, fields.subList(2, fields.size()));
                    codes.add(key);
                }

            }
        }
        assert names != null;
        names = names.subList(2, names.size());
    } catch (IOException e) {
        throw new RuntimeException("Couldn't read built-in resource", e);
    }
}

From source file:com.blackducksoftware.integration.hub.detect.detector.pear.PearParser.java

DependencyGraph createPearDependencyGraphFromList(final List<String> dependencyList,
        final List<String> dependencyNames) {
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();

    if (dependencyList.size() > 3) {
        final List<String> listing = dependencyList.subList(3, dependencyList.size() - 1);
        listing.forEach(line -> {/*from w  w  w  .  j  ava  2  s .  co m*/
            final String[] dependencyInfo = splitIgnoringWhitespace(line, " ");

            final String packageName = dependencyInfo[0].trim();
            final String packageVersion = dependencyInfo[1].trim();

            if (dependencyInfo.length > 0 && dependencyNames.contains(packageName)) {
                final Dependency child = new Dependency(packageName, packageVersion,
                        externalIdFactory.createNameVersionExternalId(Forge.PEAR, packageName, packageVersion));

                graph.addChildToRoot(child);
            }
        });
    }

    return graph;
}

From source file:au.org.ala.delta.intkey.WriteOnceIntkeyItemsFile.java

public void writeHeader() {

    int part2 = nextAvailableRecord();
    _header.setRpNext(part2);/*from   w  ww.ja va 2 s .c o  m*/
    List<Integer> header = _header.toInts();
    overwriteRecord(1, header.subList(0, RECORD_LENGTH_INTEGERS));

    List<Integer> headerPart2 = header.subList(RECORD_LENGTH_INTEGERS, header.size());
    writeToRecord(part2, headerPart2);
}

From source file:edu.sampleu.admin.EdocLiteXmlIngesterBase.java

/**
 * Divides fileUploadList from resources into sublists to match the maximum number of file
 * upload components available on XML Ingester Screen
 *
 *//* w w w  .jav a2s .c o  m*/
private List<List<File>> getSubListsForFile(List<File> fileList, final int L) {
    List<List<File>> subLists = new ArrayList<List<File>>();
    final int N = fileList.size();
    for (int i = 0; i < N; i += L) {
        subLists.add(new ArrayList<File>(fileList.subList(i, Math.min(N, i + L))));
    }

    return subLists;
}

From source file:com.cloudera.branchreduce.impl.distributed.Worker.java

@Override
protected void run() throws Exception {
    while (true) {
        T task = tasks.poll();//from  w  ww.ja  v  a2s  . c  om
        if (task == null) {
            // Wait for some work to show up.
            List<T> moreWork = taskMaster.getWork(workerId, context.readGlobalState());
            if (moreWork.isEmpty()) {
                // If nothing comes back, we're done.
                stop();
                break;
            }
            tasks.addAll(moreWork.subList(1, moreWork.size()));
            task = moreWork.get(0);
        }
        LOG.info("Now processing task = " + task);
        processor.execute(task, context);
    }
}

From source file:com.insightml.nlp.analysis.LanguageAnalysisProducer.java

public final List<Triple<R, Double, Integer>> correlation(final ISamples<? extends ITextSample, ?> instances,
        final LanguagePipeline pipeline, final int minOccurrences, final double minAbsCorrelation,
        final double minCorrelation, final double maxCorrelation, final int maxResults, final int labelIndex) {
    final List<Triple<R, Double, Integer>> tokens = bla(instances, pipeline, minOccurrences, minAbsCorrelation,
            minCorrelation, maxCorrelation, labelIndex);
    Collections.sort(tokens,//w  w  w .  j a v a  2s.  co m
            (o1, o2) -> Double.valueOf(Math.abs(o2.getSecond())).compareTo(Math.abs(o1.getSecond())));
    return tokens.subList(0, Math.min(maxResults, tokens.size()));
}

From source file:au.edu.anu.metadatastores.service.search.SearchOptions.java

/**
 * Search metadata stores for the value/*  w w w  .ja va  2 s.  com*/
 * 
 * @param searchValue The value to search for
 * @return The model
 */
public Map<String, Object> search(String searchValue, int offset, int rows) {
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("rows", getRows(rows));
    if (searchValue != null && searchValue.length() > 0) {
        SearchService itemService = SearchService.getSingleton();
        List<ItemDTO> items = itemService.queryItems(searchValue);
        items = permissionService.filterItems(items);
        model.put("numItems", items.size());
        if (rows > 0) {
            items = items.subList(offset, Math.min(items.size(), offset + rows));
        }
        model.put("items", items);
    }

    return model;
}

From source file:com.cognifide.aet.job.common.comparators.source.diff.DiffParser.java

private ResultDelta prepareNoChangeResultDelta(List<String> originalList, List<String> revisedList,
        int lastPositionOriginal, int lastPositionRevised) {
    int originalListSize = originalList.size();
    int revisedListSize = revisedList.size();
    List<String> originalSubList = originalList.subList(lastPositionOriginal, originalListSize);
    ResultChunk originalChunk = getNoChangesResultChunk(originalSubList, lastPositionOriginal);
    List<String> revisedSubList = revisedList.subList(lastPositionRevised, revisedListSize);
    ResultChunk revisedChunk = getNoChangesResultChunk(revisedSubList, lastPositionRevised);
    return new ResultDelta(TYPE.NO_CHANGE, originalChunk, revisedChunk);
}

From source file:com.abixen.platform.service.businessintelligence.multivisualization.service.impl.AbstractDatabaseService.java

public List<Map<String, DataValueWeb>> getDataSourcePreview(Connection connection,
        DatabaseDataSource databaseDataSource) {
    Set<String> dataSourceColumnsSet = new HashSet<>();

    databaseDataSource.getColumns().forEach(column -> {
        dataSourceColumnsSet.add(column.getName());
    });/* w  ww .  ja  v a 2  s .  c  o m*/

    if (dataSourceColumnsSet.isEmpty()) {
        return new ArrayList<>();
    }
    //FixMe
    List<Map<String, DataValueWeb>> data = getData(connection, databaseDataSource, dataSourceColumnsSet, null);
    return data.subList(0, data.size() < datasourceLimit ? data.size() : datasourceLimit);
}

From source file:org.wallerlab.yoink.regionizer.service.SizeConsistentRegionizer.java

private void checkCriteria(Region qmAdaptiveRegion, Region bufferRegion,
        Map<Molecule, Double> distanceAndMoleculeSequence, int qmNumber, double distance_s_qm_in,
        double distance_t_qm_out) {

    List<Molecule> moleculeSequence = new ArrayList<Molecule>(distanceAndMoleculeSequence.keySet());
    List<Double> distanceSequence = new ArrayList<Double>(distanceAndMoleculeSequence.values());

    // take the first n number of molecules as adaptive qm
    List<Molecule> adaptiveQMMolecules = moleculeSequence.subList(0, qmNumber);
    for (Molecule molecule : adaptiveQMMolecules) {
        qmAdaptiveRegion.addMolecule(molecule, molecule.getIndex());
    }//from w  ww  . java 2s .c om

    int endIndexBuffer = 0;

    for (int i = 0; i < distanceSequence.size(); i++) {

        if (distanceSequence.get(i) > distance_t_qm_out) {
            endIndexBuffer = i + 1;

            break;

        }
    }

    List<Molecule> bufferMolecules = moleculeSequence.subList(qmNumber, endIndexBuffer);

    for (Molecule molecule : bufferMolecules) {
        bufferRegion.addMolecule(molecule, molecule.getIndex());
    }

}