Example usage for java.util LinkedList isEmpty

List of usage examples for java.util LinkedList isEmpty

Introduction

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

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:org.owasp.dependencycheck.data.lucene.AlphaNumericFilter.java

/**
 * {@inheritDoc}//from   w ww.jav  a  2s .c  o m
 */
@Override
public boolean incrementToken() throws IOException {
    final LinkedList<String> tokens = getTokens();
    final CharTermAttribute termAtt = getTermAtt();
    if (tokens.isEmpty()) {
        String[] parts;
        skipCounter = 0;
        while (input.incrementToken()) {
            final String text = new String(termAtt.buffer(), 0, termAtt.length());
            if (text.isEmpty()) {
                return true;
            }
            parts = text.split("[^a-zA-Z0-9]");
            if (parts.length == 0) {
                skipCounter += posIncrAttribute.getPositionIncrement();
            } else {
                if (skipCounter != 0) {
                    posIncrAttribute
                            .setPositionIncrement(posIncrAttribute.getPositionIncrement() + skipCounter);
                }
                for (String part : parts) {
                    if (!part.isEmpty()) {
                        tokens.add(part);
                    }
                }
                break;
            }
        }
    }
    return addTerm();
}

From source file:it.cnr.istc.iloc.gui.TimelinesChart.java

@Override
public void currentNode(Solver.Node n) {
    final CombinedDomainXYPlot combined_plot = new CombinedDomainXYPlot(new DateAxis("Time"));
    combined_plot.setGap(3.0);/*from w  w  w .jav  a  2  s . c  om*/
    combined_plot.setOrientation(PlotOrientation.VERTICAL);

    Set<Type> c_types = new HashSet<>();
    LinkedList<Type> queue = new LinkedList<>();
    queue.addAll(solver.getTypes());
    while (!queue.isEmpty()) {
        Type c_type = queue.pollFirst();
        if (!c_types.contains(c_type)) {
            c_types.add(c_type);
            queue.addAll(c_type.getTypes());
        }
    }
    for (Type type : c_types) {
        if (visualizers.containsKey(type.getClass())) {
            for (XYPlot plot : visualizers.get(type.getClass()).getPlots(type)) {
                TextTitle title = new TextTitle(type.name, new Font("SansSerif", Font.PLAIN, 11), Color.BLACK,
                        RectangleEdge.TOP, HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM,
                        new RectangleInsets(4, 4, 4, 4));
                XYTitleAnnotation titleAnn = new XYTitleAnnotation(0.01, 1, title, RectangleAnchor.TOP_LEFT);
                plot.addAnnotation(titleAnn);
                combined_plot.add(plot, 1);
            }
        }
    }
    setChart(new JFreeChart("", new Font("SansSerif", Font.BOLD, 14), combined_plot, false));
    setBorder(BorderFactory.createEtchedBorder());
}

From source file:org.fusesource.mop.support.CommandDefinition.java

/**
 * Lets split the argument list into the artifact(s) strings then the remaining arguments
 *//*from  w  ww. j  av a 2s  .  c o m*/
protected void splitArgumentList(LinkedList<String> argList, LinkedList<String> artifacts,
        LinkedList<String> remainingArgs) {
    if (argList.isEmpty()) {
        return;
    }
    artifacts.add(argList.removeFirst());
    while (!argList.isEmpty()) {
        String arg = argList.removeFirst();
        if (mop.isAnotherArtifactId(arg)) {
            artifacts.add(arg);
        } else {
            remainingArgs.add(arg);
            remainingArgs.addAll(argList);
            break;
        }
    }

}

From source file:com.heliosdecompiler.helios.tasks.AddFilesTask.java

private void handleDirectory(File file) throws IOException {
    LinkedList<File> filesToProcess = new LinkedList<>();
    filesToProcess.add(file);/*from   w ww.j  av  a 2s .  com*/
    Set<String> filesProcessed = new HashSet<>();

    while (!filesToProcess.isEmpty()) {
        File current = filesToProcess.pop();
        if (current.isFile() && filesProcessed.add(current.getCanonicalPath())) {
            handle(current);
        } else {
            File[] listFiles = current.listFiles();
            if (listFiles != null) {
                filesToProcess.addAll(Arrays.asList(listFiles));
            }
        }
    }
}

From source file:BasicPriorityLinkedList.java

public Object peekFirst() {
    Object obj = null;/* w  w w .j  a v a2 s.com*/

    // Initially we are just using a simple prioritization algorithm:
    // Highest priority refs always get returned first.
    // This could cause starvation of lower priority refs.

    // TODO - A better prioritization algorithm

    for (int i = priorities - 1; i >= 0; i--) {
        LinkedList ll = linkedLists[i];
        if (!ll.isEmpty()) {
            obj = ll.getFirst();
        }
        if (obj != null) {
            break;
        }
    }

    return obj;
}

From source file:assistive.com.scanme.com.googlecode.eyesfree.utils.AccessibilityNodeInfoUtils.java

/**
 * Returns the result of applying a filter using breadth-first traversal.
 *
 * @param context The parent context./*from  w  w  w.  j a  va 2s .  c om*/
 * @param node The root node to traverse from.
 * @param filter The filter to satisfy.
 * @return The first node reached via BFS traversal that satisfies the
 *         filter.
 */
public static AccessibilityNodeInfoCompat searchFromBfs(Context context, AccessibilityNodeInfoCompat node,
        NodeFilter filter) {
    if (node == null) {
        return null;
    }

    final LinkedList<AccessibilityNodeInfoCompat> queue = new LinkedList<AccessibilityNodeInfoCompat>();

    queue.add(AccessibilityNodeInfoCompat.obtain(node));

    while (!queue.isEmpty()) {
        final AccessibilityNodeInfoCompat item = queue.removeFirst();

        if (filter.accept(context, item)) {
            return AccessibilityNodeInfoCompat.obtain(item);
        }

        final int childCount = item.getChildCount();

        for (int i = 0; i < childCount; i++) {
            final AccessibilityNodeInfoCompat child = item.getChild(i);

            if (child != null) {
                queue.addLast(child);
            }
        }
    }

    return null;
}

From source file:BasicPriorityLinkedList.java

public Object removeLast() {
    Object obj = null;// ww  w .  j av  a 2  s  .  c om

    // Initially we are just using a simple prioritization algorithm:
    // Lowest priority refs always get returned first.

    // TODO - A better prioritization algorithm

    for (int i = 0; i < priorities; i++) {
        LinkedList ll = linkedLists[i];
        if (!ll.isEmpty()) {
            obj = ll.removeLast();
        }
        if (obj != null) {
            break;
        }
    }

    if (obj != null) {
        size--;
    }

    return obj;
}

From source file:assistive.com.scanme.com.googlecode.eyesfree.utils.AccessibilityNodeInfoUtils.java

/**
 * Returns the result of applying a filter using breadth-first traversal.
 *
 * @param context The parent context./*from w w  w . jav a  2s . co m*/
 * @param node The root node to traverse from.
 * @param filter The filter to satisfy.
 * @param maxResults The number of results to stop searching after
 * @return The first n nodes reached via BFS traversal that satisfies the
 *         filter.
 */
public static List<AccessibilityNodeInfoCompat> searchAllFromBfs(Context context,
        AccessibilityNodeInfoCompat node, NodeFilter filter, int maxResults) {
    if (node == null) {
        return null;
    }

    final List<AccessibilityNodeInfoCompat> toReturn = new ArrayList<AccessibilityNodeInfoCompat>();
    final LinkedList<AccessibilityNodeInfoCompat> queue = new LinkedList<AccessibilityNodeInfoCompat>();

    queue.add(AccessibilityNodeInfoCompat.obtain(node));

    while (!queue.isEmpty() && toReturn.size() < maxResults) {
        final AccessibilityNodeInfoCompat item = queue.removeFirst();

        if (filter.accept(context, item)) {
            toReturn.add(AccessibilityNodeInfoCompat.obtain(item));
        }

        final int childCount = item.getChildCount();

        for (int i = 0; i < childCount; i++) {
            final AccessibilityNodeInfoCompat child = item.getChild(i);

            if (child != null) {
                queue.addLast(child);
            }
        }
    }

    return toReturn;
}

From source file:BasicPriorityLinkedList.java

public Object removeFirst() {
    Object obj = null;//  w  ww .  ja  va  2 s  . c o m

    // Initially we are just using a simple prioritization algorithm:
    // Highest priority refs always get returned first.
    // This could cause starvation of lower priority refs.

    // TODO - A better prioritization algorithm

    for (int i = priorities - 1; i >= 0; i--) {
        LinkedList ll = linkedLists[i];

        if (!ll.isEmpty()) {
            obj = ll.removeFirst();
            break;
        }

    }

    if (obj != null) {
        size--;
    }

    return obj;
}

From source file:org.commonjava.util.partyline.FileTreeTest.java

private File createStructure(String path, boolean writeTestFile) throws IOException {
    LinkedList<String> parts = new LinkedList<>(Arrays.asList(path.split("/")));
    String fname = parts.removeLast();

    File current = temp.newFolder();
    while (!parts.isEmpty()) {
        current = new File(current, parts.removeFirst());
    }/*w ww.ja  v  a  2s.c o  m*/

    current = new File(current, fname);
    if (writeTestFile) {
        current.getParentFile().mkdirs();
        FileUtils.write(current, "This is a test");
    } else {
        current.mkdirs();
    }

    return current;
}