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:amie.keys.CombinationsExplorationNew.java

private static List<Rule> getAllProperSubconditions(Rule conditionRule) {
    int numberOfConditions = conditionRule.getLength();
    List<Rule> results = new ArrayList<>();
    for (int size = 1; size < numberOfConditions; ++size) {
        List<int[]> combinations = telecom.util.collections.Collections.subsetsOfSize(numberOfConditions, size);
        for (int[] combination : combinations) {
            List<ByteString[]> atoms = new ArrayList<>();
            for (int idx : combination) {
                atoms.add(conditionRule.getTriples().get(idx));
            }/* ww  w  .  j  a v  a  2s .  c  o m*/
            Rule newRule = null;
            long card = kb.countDistinct(atoms.get(0)[0], atoms);
            if (atoms.size() > 1) {
                newRule = new Rule(atoms.get(0), atoms.subList(1, atoms.size()), card);
            } else {
                newRule = new Rule(atoms.get(0), card);
            }
            results.add(newRule);
        }
    }
    return results;
}

From source file:com.act.lcms.db.model.BaseDBModel.java

protected List<String> makeInsertUpdateFields() {
    List<String> allFields = getAllFields();
    return Collections.unmodifiableList(allFields.subList(1, allFields.size()));
}

From source file:com.banyou.backend.web.front.HomepageController.java

@RequestMapping(value = { "/", "index", "" }, method = RequestMethod.GET)
public String index(HttpSession session, Model model) {
    String lunboCode = "INDEX_LUNBO";
    Long[] ids = (Long[]) session.getAttribute(DEST_CODE);

    if (!ArrayUtils.isEmpty(ids)) {
        model.addAttribute("dests", destService.findDests(ids));
    }/*  ww w . j av a2s .c  o  m*/
    List<AdContent> lunboAD = adService.getAdPositionByCode(lunboCode).getContent();
    int lunboMax = 1;
    if (!lunboAD.isEmpty()) {
        model.addAttribute("lunboAd", lunboAD.subList(0, Math.min(lunboAD.size(), lunboMax)));
    }

    destService.findDests(ids);
    return "front/index";
}

From source file:org.jtalks.common.security.acl.ExtendedMutableAclTest.java

@Test(dataProvider = "extendedMutableAclAndWrappedMock", description = "Checks what happens when there are no such elements in the Acl#getEntries()")
public void testDeleteList_withNoSuchEntries(ExtendedMutableAcl extendedMutableAcl, MutableAcl wrappedMock) {
    List<AccessControlEntry> entries = createEntries(wrappedMock);
    when(wrappedMock.getEntries()).thenReturn(entries.subList(0, 2));

    extendedMutableAcl.delete(entries.subList(1, 3));
    verify(wrappedMock).deleteAce(1);//from   ww w . ja v  a  2  s .  com
}

From source file:edu.toronto.cs.phenotips.hpoa.PhenotypeMappingScriptService.java

public List<SearchResult> getMatches(Collection<String> phenotypes, int limit) {
    List<SearchResult> results = this.predictor.getMatches(phenotypes);
    if (limit < results.size()) {
        return results.subList(0, limit);
    }//from  ww  w. j av a 2s .c  o  m
    return results;
}

From source file:jp.xet.uncommons.wicket.spring.AbstractSpringDataProvider.java

@Override
public Iterator<? extends T> iterator(int first, int count) {
    Pageable request = newPageable(first, count);
    Page<T> page = find(request);//from  ww  w .  j  ava 2s  .  c om
    List<T> content = page.getContent();
    if (content.size() > count) {
        content = content.subList(0, count);
    }
    return content.iterator();
}

From source file:com.dams.controller.client.ClientController.java

@RequestMapping("/client")
public String welcome(@ModelAttribute("contact") Contact contact, Model model) {
    List<Doctor> doctors = doctorService.getAll();
    if (doctors.size() > 2) {
        doctors = doctors.subList(0, 3);
    }/*  w ww .  j  a va 2  s.  c o m*/
    model.addAttribute("doctors", doctors);
    model.addAttribute("sliders", sliderService.getAll());

    return "home";
}

From source file:com.hp.octane.integrations.uft.UftTestDispatchUtils.java

private static boolean updateScmResources(EntitiesService entitiesService,
        List<ScmResourceFile> updatedResourceFiles, String workspaceId) {
    try {/*ww w.  jav a2 s  .c  o m*/
        //CONVERT TO DTO
        List<Entity> entitiesForUpdate = new ArrayList<>(updatedResourceFiles.size());
        for (ScmResourceFile resource : updatedResourceFiles) {
            Entity entity = dtoFactory.newDTO(Entity.class).setType(EntityConstants.ScmResourceFile.ENTITY_NAME)
                    .setName(resource.getName()).setId(resource.getId())
                    .setField(EntityConstants.ScmResourceFile.RELATIVE_PATH_FIELD, resource.getRelativePath());
            entitiesForUpdate.add(entity);
        }

        if (!updatedResourceFiles.isEmpty()) {
            for (int i = 0; i < updatedResourceFiles.size(); i += POST_BULK_SIZE) {
                List<Entity> data = entitiesForUpdate.subList(i,
                        Math.min(i + POST_BULK_SIZE, entitiesForUpdate.size()));
                entitiesService.updateEntities(Long.parseLong(workspaceId),
                        EntityConstants.ScmResourceFile.COLLECTION_NAME, data);
            }
        }

        return true;
    } catch (Exception e) {
        logger.error("Failed to update data tables : " + e.getMessage());
        return false;
    }
}

From source file:com.mapr.synth.drive.DriveTest.java

@Test
public void testCrazyPlan() {
    Random rand = new Random(3);
    GeoPoint start = new GeoPoint(new Vector3D(0.84338521, 0.40330691, 0.35502805));
    GeoPoint end = new GeoPoint(new Vector3D(0.84293820, 0.40512281, 0.35402076));
    for (int i = 0; i < 100000; i++) {
        List<Car.Segment> plan = Car.plan(start, end, rand);
        GeoPoint old = start;//  w  ww  . jav a 2 s.c  om
        for (Car.Segment segment : plan.subList(1, plan.size())) {
            double distance = old.distance(segment.getEnd());
            if (distance > 100 || Double.isNaN(distance)) {
                Assert.fail("Got bad distance");
            }
            old = segment.getEnd();
        }
    }
}

From source file:eu.cloud4soa.frontend.commons.server.semanticdao.BaseRepository.java

private <A> List<A> page(List<A> li, int offset, int limit) {
    return new ArrayList<A>(li.subList(Math.min(offset, li.size()), Math.min(offset + limit, li.size())));

}