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:fitnesse.authentication.PasswordFile.java

private void loadCipher(LinkedList<String> lines) {
    if (lines.size() > 0) {
        String firstLine = lines.getFirst();
        if (firstLine.startsWith("!")) {
            String cipherClassName = firstLine.substring(1);
            instantiateCipher(cipherClassName);
            lines.removeFirst();/*from   w  ww. j ava  2s. c o m*/
        }
    }
}

From source file:org.cocos2dx.lib.Cocos2dxBitmap.java

private static String[] splitString(String content, int maxHeight, int maxWidth, Paint paint) {
    String[] lines = content.split("\\n");
    String[] ret = null;/* w w w . ja v  a 2s  .  c om*/
    FontMetricsInt fm = paint.getFontMetricsInt();
    int heightPerLine = (int) Math.ceil(fm.bottom - fm.top);
    int maxLines = maxHeight / heightPerLine;

    if (maxWidth != 0) {
        LinkedList<String> strList = new LinkedList<String>();
        for (String line : lines) {
            /*
             * The width of line is exceed maxWidth, should divide it into
             * two or more lines.
             */
            int lineWidth = (int) Math.ceil(paint.measureText(line));
            if (lineWidth > maxWidth) {
                strList.addAll(divideStringWithMaxWidth(paint, line, maxWidth));
            } else {
                strList.add(line);
            }

            /*
             * Should not exceed the max height;
             */
            if (maxLines > 0 && strList.size() >= maxLines) {
                break;
            }
        }

        /*
         * Remove exceeding lines
         */
        if (maxLines > 0 && strList.size() > maxLines) {
            while (strList.size() > maxLines) {
                strList.removeLast();
            }
        }

        ret = new String[strList.size()];
        strList.toArray(ret);
    } else if (maxHeight != 0 && lines.length > maxLines) {
        /*
         * Remove exceeding lines
         */
        LinkedList<String> strList = new LinkedList<String>();
        for (int i = 0; i < maxLines; i++) {
            strList.add(lines[i]);
        }
        ret = new String[strList.size()];
        strList.toArray(ret);
    } else {
        ret = lines;
    }

    return ret;
}

From source file:cso.AdvancedBox.java

public void setToApplicantBox() {
    String[] dataformats = { "asdp", "jpeg" };
    LinkedList<File> j = (LinkedList<File>) FileUtils.listFiles(new File("applicants"), dataformats, false);
    String[] al = new String[j.size()];
    for (int i = 0; i < j.size(); i++) {
        al[i] = (j.get(i).getName().toString().replace(".asdp", ""));
    }/*from  ww  w  .j av a  2 s  .c  om*/
    this.setModel(new javax.swing.DefaultComboBoxModel(al));
    type = "applicant";
}

From source file:hr.fer.zemris.vhdllab.service.extractor.automaton.AutomatonMetadataExtractor.java

private boolean provjera(LinkedList<Stanje> stanja, AUTPodatci podatci) {
    if (stanja.size() == 0 || podatci.pocetnoStanje.equals(""))
        return false;
    return true;/*from  w  w  w  .ja  v a  2  s  .c om*/
}

From source file:gr.abiss.calipso.jpasearch.specifications.GenericSpecifications.java

@Deprecated
protected static Predicate getPredicate(final Class clazz, final Restriction searchTerms,
        Root<Persistable> root, CriteriaBuilder cb) {
    LinkedList<Predicate> predicates = new LinkedList<Predicate>();
    Predicate predicate;//from w  w  w  .  j  av  a  2s. c o  m
    // process child restrictions
    if (!CollectionUtils.isEmpty(searchTerms.getRestrictions())) {
        for (Restriction restriction : searchTerms.getRestrictions()) {
            predicates.add(getPredicate(clazz, restriction, root, cb));
        }
    }
    // process main restriction
    if (StringUtils.isNotBlank(searchTerms.getField())) {
        String propertyName = searchTerms.getField();
        addPredicate(clazz, root, cb, predicates,
                searchTerms.getValues().toArray(new String[searchTerms.getValues().size()]), propertyName);
    }
    if (searchTerms.getJunction().equals(Restriction.Junction.OR)) {
        predicate = cb.or(predicates.toArray(new Predicate[predicates.size()]));
    } else {
        predicate = cb.and(predicates.toArray(new Predicate[predicates.size()]));
    }
    return predicate;
}

From source file:com.tnc.android.graphite.activities.SavedActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.saved_graphs);

    ArrayList<String> savedGraphs = new ArrayList<String>();
    try {/*  w  w  w  . java 2 s.c  om*/
        LinkedList<GraphData> graphs = GraphStorage.getInstance().getGraphs();
        for (int i = 0; i < graphs.size(); ++i) {
            savedGraphs.add(graphs.get(i).getName());
        }

        SavedGraphsFragment fragment = (SavedGraphsFragment) getSupportFragmentManager()
                .findFragmentById(R.id.savedFragment);

        if (fragment != null && fragment.isInLayout()) {
            fragment.setContent(savedGraphs);
        }
    } catch (Exception e) {
        e.printStackTrace();
        UserNotification.displayRaw(this, e.toString());
        finish();
    }
}

From source file:org.lightframework.mvc.plugin.spring.TestSpringPlugin.java

public void testPluginRegister() throws Throwable {
    LinkedList<Plugin> plugins = PluginManager.getPlugins();
    assertEquals(2, plugins.size());

    PluginRegistry registry = spring.getBean(PluginRegistry.class);
    assertEquals(2, registry.getPlugins().size());
}

From source file:com.twitter.distributedlog.service.balancer.CountBasedStreamChooser.java

@Override
public synchronized String choose() {
    // reach the pivot
    if (next == pivot) {
        if (streamsDistribution.get(next - 1).getRight().size() > pivotCount) {
            next = 0;/*  w  w w.j  a  va  2  s .c  om*/
        } else if (pivotCount == 0) { // the streams are empty now
            return null;
        } else {
            findNextPivot();
            next = 0;
        }
    }

    // get stream count that next host to choose from
    LinkedList<String> nextStreams = streamsDistribution.get(next).getRight();
    if (nextStreams.size() == 0) {
        return null;
    }

    String chosenStream = nextStreams.remove();
    ++next;
    return chosenStream;
}

From source file:de.vandermeer.asciitable.CWC_LongestLine.java

@Override
public int[] calculateColumnWidths(LinkedList<AT_Row> rows, int colNumbers, int tableWidth) {
    Validate.notNull(rows);// w w w .j  a v  a2  s . co m

    int[] resultWidths = new int[colNumbers];

    // apply min width settings
    System.arraycopy(minWidths, 0, resultWidths, 0,
            minWidths.length > colNumbers ? colNumbers : minWidths.length);

    // iterate over all rows
    for (AT_Row row : rows) {
        if (row.getType() == TableRowType.CONTENT) {
            LinkedList<AT_Cell> cells = row.getCells();

            for (int i = 0; i < cells.size(); i++) {
                if (cells.get(i).getContent() != null) {
                    String[] lines = String_To_ConditionalBreak
                            .convert(Object_To_StrBuilder.convert(cells.get(i).getContent()).toString());

                    // measuring the width of each line within a cell
                    for (String line : lines) {
                        int lineWidth = line.length() + cells.get(i).getContext().getPaddingLeft()
                                + cells.get(i).getContext().getPaddingRight();
                        if (lineWidth > resultWidths[i]) {
                            int maxWidth = (maxWidths.length > i) ? maxWidths[i] : 0;
                            if (maxWidth < 1 || lineWidth < maxWidth) {
                                resultWidths[i] = lineWidth;
                            } else {
                                resultWidths[i] = maxWidth;
                            }
                        }
                    }
                }
            }
        }
    }
    return resultWidths;
}

From source file:com.newlandframework.avatarmq.core.MessageCache.java

private void commitMessage(ConcurrentLinkedQueue<T> messages) {

    LinkedList<T> list = new LinkedList<T>();

    list.addAll(messages);//from   ww w .j a va2  s  . co m
    cache.clear();

    if (list != null && list.size() > 0) {
        parallelDispatch(list);
        list.clear();
    }
}