Example usage for java.util LinkedList size

List of usage examples for java.util LinkedList size

Introduction

In this page you can find the example usage for java.util LinkedList size.

Prototype

int size

To view the source code for java.util LinkedList size.

Click Source Link

Usage

From source file:com.insightml.utils.Collections.java

public static <T, N extends Number> LinkedList<Pair<T, N>> getMax(final Iterable<Pair<T, N>> map) {
    LinkedList<Pair<T, N>> maxEntry = new LinkedList<>();
    for (final Pair<T, N> entry : map) {
        if (maxEntry.size() == 0
                || entry.getSecond().doubleValue() > maxEntry.getFirst().getSecond().doubleValue()) {
            maxEntry = new LinkedList<>();
            maxEntry.add(entry);//from   w w  w  .j a v  a  2  s .com
        } else if (entry.getSecond().doubleValue() == maxEntry.getFirst().getSecond().doubleValue()) {
            maxEntry.add(entry);
        }
    }
    return maxEntry;
}

From source file:Main.java

public static String[] getChildrenText(Element parentElement, String childrenName) {
    NodeList nl = parentElement.getChildNodes();
    int max = nl.getLength();
    LinkedList<String> list = new LinkedList<String>();
    for (int i = 0; i < max; i++) {
        Node n = nl.item(i);//w  w  w . j ava 2 s. co  m
        if (n.getNodeType() == Node.ELEMENT_NODE && n.getNodeName().equals(childrenName)) {
            list.add(getText((Element) n));
        }
    }
    return list.toArray(new String[list.size()]);
}

From source file:de.cubeisland.engine.core.util.McUUID.java

private static List<Profile> getUUIDForNames0(Collection<String> playernames) {
    LinkedList<String> players = new LinkedList<>();
    List<Profile> profiles = new ArrayList<>();
    for (String playername : new HashSet<>(playernames)) {
        players.add(playername);/* www  .ja v  a2 s. co  m*/
        if (players.size() >= 20) {
            getProfiles(profiles, players);
            CubeEngine.getLog().info(profiles.size() + "/" + playernames.size());
        }
    }
    getProfiles(profiles, players);
    CubeEngine.getLog().info("Getting UUIDs done!", playernames.size());
    return profiles;
}

From source file:de.undercouch.citeproc.helper.Levenshtein.java

/**
 * Searches the given collection of strings and returns a collection of at
 * most <code>n</code> strings that have the lowest Levenshtein distance
 * to a given string <code>t</code>. The returned collection will be
 * sorted according to the distance with the string with the lowest
 * distance at the first position./*from  w ww .j av  a 2s  . com*/
 * @param <T> the type of the strings in the given collection
 * @param ss the collection to search
 * @param t the string to compare to
 * @param n the maximum number of strings to return
 * @param threshold a threshold for individual item distances. Only items
 * with a distance below this threshold will be included in the result.
 * @return the strings with the lowest Levenshtein distance
 */
public static <T extends CharSequence> Collection<T> findMinimum(Collection<T> ss, CharSequence t, int n,
        int threshold) {
    LinkedList<Item<T>> result = new LinkedList<Item<T>>();
    for (T s : ss) {
        int d = StringUtils.getLevenshteinDistance(s, t);
        if (d < threshold) {
            result.offer(new Item<T>(s, d));

            if (result.size() > n + 10) {
                //resort, but not too often
                Collections.sort(result);
                while (result.size() > n)
                    result.removeLast();
            }
        }
    }

    Collections.sort(result);
    while (result.size() > n)
        result.removeLast();

    List<T> arr = new ArrayList<T>(n);
    for (Item<T> i : result) {
        arr.add(i.str);
    }
    return arr;
}

From source file:Main.java

public static Element[] getChildrenByName(Element element, String paramString) {
    NodeList localNodeList = element.getChildNodes();
    int i = localNodeList.getLength();
    LinkedList<Node> nodes = new LinkedList<Node>();
    for (int j = 0; j < i; ++j) {
        Node localNode = localNodeList.item(j);
        if ((localNode.getNodeType() != 1) || (!localNode.getNodeName().equals(paramString)))
            continue;
        nodes.add(localNode);// www. ja  v a  2 s  . c om
    }
    return (Element[]) nodes.toArray(new Element[nodes.size()]);
}

From source file:com.bwc.ora.OraUtils.java

public static void setLrpsForAnalysis() {
    Lrp fovealLrp = lrpCollection.getFovealLrp();
    if (fovealLrp == null) {
        return;/*from  w ww .  j  ava 2 s  .  c o  m*/
    }

    LrpSettings lrpSettings = ModelsCollection.getInstance().getLrpSettings();
    int octWidth = Oct.getInstance().getImageWidth();
    int distanceBetweenLrps = lrpSettings.getLrpSeperationDistanceInPixels();
    int numberOfLrpTotal = lrpSettings.getNumberOfLrp();
    int lrpPosToLeftOfFovea = fovealLrp.getLrpCenterXPosition();
    int lrpPosToRightOfFovea = fovealLrp.getLrpCenterXPosition();
    LinkedList<Lrp> lrps = new LinkedList<>();
    lrps.add(fovealLrp);
    while (lrps.size() < numberOfLrpTotal) {
        lrpPosToLeftOfFovea -= distanceBetweenLrps;
        lrps.push(new Lrp("Left " + ((lrps.size() + 1) / 2), lrpPosToLeftOfFovea,
                fovealLrp.getLrpCenterYPosition(), lrpSettings.getLrpWidth(), lrpSettings.getLrpHeight(),
                LrpType.PERIPHERAL));

        lrpPosToRightOfFovea += distanceBetweenLrps;
        if (lrps.size() < numberOfLrpTotal) {
            lrps.add(new Lrp("Right " + (lrps.size() / 2), lrpPosToRightOfFovea,
                    fovealLrp.getLrpCenterYPosition(), lrpSettings.getLrpWidth(), lrpSettings.getLrpHeight(),
                    LrpType.PERIPHERAL));
        }
    }

    boolean illegalPositionLrps = lrps.stream()
            .anyMatch(lrp -> lrp.getLrpCenterXPosition() - ((lrpSettings.getLrpWidth() - 1) / 2) < 0
                    || lrp.getLrpCenterXPosition() + ((lrpSettings.getLrpWidth() - 1) / 2) >= octWidth);

    if (illegalPositionLrps) {
        throw new IllegalArgumentException("Combination of LRP width, the number of LRPs and LRP "
                + "separation distance cannot fit within the bounds of the OCT.");
    }
    lrpCollection.setLrps(lrps);
}

From source file:org.zywx.wbpalmstar.plugin.uexiconlist.utils.IconListUtils.java

public static int indexOfIconBeans(IconBean iconBean, LinkedList<IconBean> list) {
    int index = -1;
    for (int i = 0; i < list.size(); i++) {
        if (iconBean.getIconId().equals(list.get(i).getIconId())) {
            index = i;/* www.  ja v  a2 s  .c o m*/
            break;
        }
    }
    return index;
}

From source file:org.zywx.wbpalmstar.plugin.uexiconlist.utils.IconListUtils.java

public static boolean isIconExist(IconBean iconBean, LinkedList<IconBean> list) {
    boolean isExist = false;
    for (int i = 0; i < list.size(); i++) {
        if (iconBean.getIconId().equals(list.get(i).getIconId())) {
            isExist = true;/*from   ww w. j a va2s  .  co  m*/
            break;
        }
    }
    return isExist;
}

From source file:org.dswarm.common.model.util.AttributePathUtil.java

public static String generateAttributePath(final LinkedList<Attribute> attributes) {

    if (attributes == null || attributes.isEmpty()) {

        return null;
    }/*from  w w w .  java  2 s .com*/

    final StringBuilder sb = new StringBuilder();

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

        sb.append(attributes.get(i));

        if (i < (attributes.size() - 1)) {

            sb.append(DMPStatics.ATTRIBUTE_DELIMITER);
        }
    }

    return sb.toString();
}

From source file:cascading.ComparePlatformsTest.java

private static void createComparisons(String comparison, File lhsRoot, File rhsRoot, TestSuite suite) {
    LOG.info("comparing directory: {}, with: {}", lhsRoot, rhsRoot);

    LinkedList<File> lhsFiles = new LinkedList<File>(
            FileUtils.listFiles(lhsRoot, new RegexFileFilter("^[\\w-]+"), TrueFileFilter.INSTANCE));
    LinkedList<File> rhsFiles = new LinkedList<File>();

    LOG.info("found lhs files: {}", lhsFiles.size());

    int rootLength = lhsRoot.toString().length() + 1;

    ListIterator<File> iterator = lhsFiles.listIterator();
    while (iterator.hasNext()) {
        File localFile = iterator.next();
        File file = new File(rhsRoot, localFile.toString().substring(rootLength));

        if (localFile.toString().endsWith(NONDETERMINISTIC))
            iterator.remove();//from  w w  w. jav a  2s.  c o  m
        else if (file.exists())
            rhsFiles.add(file);
        else
            iterator.remove();
    }

    LOG.info("running {} comparisons", lhsFiles.size());

    for (int i = 0; i < lhsFiles.size(); i++) {
        File localFile = lhsFiles.get(i);
        File hadoopFile = rhsFiles.get(i);

        suite.addTest(new CompareTestCase(comparison, localFile, hadoopFile));
    }
}