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.espertech.esper.epl.core.ResultSetProcessorSimple.java

/**
 * Applies the select-clause to the given events returning the selected events. The number of events stays the
 * same, i.e. this method does not filter it just transforms the result set.
 * <p>/* w  w w . j a v  a2s.com*/
 * Also applies a having clause.
 * @param exprProcessor - processes each input event and returns output event
 * @param events - input events
 * @param optionalHavingNode - supplies the having-clause expression
 * @param isNewData - indicates whether we are dealing with new data (istream) or old data (rstream)
 * @param isSynthesize - set to true to indicate that synthetic events are required for an iterator result set
 * @param exprEvaluatorContext context for expression evalauation
 * @return output events, one for each input event
 */
protected static EventBean[] getSelectEventsHaving(SelectExprProcessor exprProcessor,
        Set<MultiKey<EventBean>> events, ExprEvaluator optionalHavingNode, boolean isNewData,
        boolean isSynthesize, ExprEvaluatorContext exprEvaluatorContext) {
    LinkedList<EventBean> result = new LinkedList<EventBean>();

    for (MultiKey<EventBean> key : events) {
        EventBean[] eventsPerStream = key.getArray();

        Boolean passesHaving = (Boolean) optionalHavingNode.evaluate(eventsPerStream, isNewData,
                exprEvaluatorContext);
        if ((passesHaving == null) || (!passesHaving)) {
            continue;
        }

        EventBean resultEvent = exprProcessor.process(eventsPerStream, isNewData, isSynthesize,
                exprEvaluatorContext);
        result.add(resultEvent);
    }

    if (!result.isEmpty()) {
        return result.toArray(new EventBean[result.size()]);
    } else {
        return null;
    }
}

From source file:pivotal.au.se.gemfirexdweb.controller.HistoryController.java

@RequestMapping(value = "/history", method = RequestMethod.GET)
public String showHistory(Model model, HttpServletResponse response, HttpServletRequest request,
        HttpSession session) throws Exception {
    if (session.getAttribute("user_key") == null) {
        logger.debug("user_key is null new Login required");
        response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login");
        return null;
    } else {/*from  w w  w  .  j ava 2s . co m*/
        Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key"));
        if (conn == null) {
            response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login");
            return null;
        } else {
            if (conn.isClosed()) {
                response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login");
                return null;
            }
        }

    }

    logger.debug("Received request to show command history");
    UserPref userPref = (UserPref) session.getAttribute("prefs");

    String histAction = request.getParameter("histAction");

    if (histAction != null) {
        logger.debug("histAction = " + histAction);
        // clear history
        session.setAttribute("history", new LinkedList());

        model.addAttribute("historyremoved", "Succesfully cleared history list");
    }

    LinkedList historyList = (LinkedList) session.getAttribute("history");

    int maxsize = userPref.getHistorySize();

    model.addAttribute("historyList", historyList.toArray());
    model.addAttribute("historysize", historyList.size());

    // This will resolve to /WEB-INF/jsp/history.jsp
    return "history";
}

From source file:at.ac.tuwien.dsg.utility.DesignChart.java

public void chart(LinkedList<String> xValue, LinkedList<String> yValue) throws Exception {

    XYSeries series = new XYSeries("Sensory Data");
    final JFreeChart chart;

    //data assignment in the chart
    {/*  ww  w. j  av  a2s . c  o  m*/
        for (int i = 0; i < xValue.size(); i++) {
            series.add(Double.parseDouble(xValue.get(i)), Double.parseDouble(yValue.get(i)));
        }

        final XYSeriesCollection data = new XYSeriesCollection(series);
        chart = ChartFactory.createXYLineChart("Graph Visualization", "collection_time", "collection_data",
                data, PlotOrientation.VERTICAL, true, true, false);
    }

    //design the plot of the chart
    {
        XYPlot xyPlot = chart.getXYPlot();
        NumberAxis xAxis = (NumberAxis) xyPlot.getDomainAxis();
        NumberAxis yAxis = (NumberAxis) xyPlot.getRangeAxis();

        xAxis.setRange(20, 120);
        xAxis.setTickUnit(new NumberTickUnit(15));
        yAxis.setRange(947, 950);
        yAxis.setTickUnit(new NumberTickUnit(0.5));
    }

    //generation of the image  
    {
        try {

            BufferedImage img = chart.createBufferedImage(300, 200);
            //File outputfile = new File("./example/Sample.png");
            File outputfile = new File(
                    "/Users/dsg/Documents/phd/Big Demo/CloudLyra/Utils/JBPMEngine/example/Sample.png");
            ImageIO.write(img, "png", outputfile);

        } catch (Exception e) {
            System.out.println("exception occured in tomcat: " + e);
        }
    }

}

From source file:edu.umd.cfar.lamp.viper.gui.chronology.ViperChronicleSelectionModel.java

public TemporalRange getSelectedTime() {
    if (nodeWhoseTimeToSelect instanceof TemporalNode) {
        return ((TemporalNode) nodeWhoseTimeToSelect).getRange();
    } else if (nodeWhoseTimeToSelect instanceof Config) {
        Sourcefile sf = mediator.getCurrFile();
        if (sf != null) {
            Iterator iter = sf.getDescriptorsBy((Config) nodeWhoseTimeToSelect);
            if (iter.hasNext()) {
                LinkedList ll = new LinkedList();
                while (iter.hasNext()) {
                    ll.add(((Descriptor) iter.next()).getRange());
                }/* ww  w. j  a  v a  2s  .  c o  m*/
                TemporalRange[] R = new TemporalRange[ll.size()];
                ll.toArray(R);
                return new MultipleRange(R);
            }
        }
    }
    return null;
}

From source file:com.frostwire.android.MediaScanner.java

private static void scanFiles(final Context context, List<String> paths, int retries) {
    if (paths.size() == 0) {
        return;/*from   www .j  a va  2  s. c om*/
    }

    LOG.info("About to scan files n: " + paths.size() + ", retries: " + retries);

    final LinkedList<String> failedPaths = new LinkedList<>();

    final CountDownLatch finishSignal = new CountDownLatch(paths.size());

    MediaScannerConnection.scanFile(context, paths.toArray(new String[0]), null, (path, uri) -> {
        try {
            boolean success = true;
            if (uri == null) {
                success = false;
                failedPaths.add(path);
            } else {
                // verify the stored size four faulty scan
                long size = getSize(context, uri);
                if (size == 0) {
                    LOG.warn("Scan returned an uri but stored size is 0, path: " + path + ", uri:" + uri);
                    success = false;
                    failedPaths.add(path);
                }
            }
            if (!success) {
                LOG.info("Scan failed for path: " + path + ", uri: " + uri);
            }
        } finally {
            finishSignal.countDown();
        }
    });

    try {
        finishSignal.await(10, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        // ignore
    }

    if (failedPaths.size() > 0 && retries > 0) {
        // didn't want to do this, but there is a serious timing issue with the SD
        // and storage in general
        SystemClock.sleep(2000);
        scanFiles(context, failedPaths, retries - 1);
    }
}

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

public void parallelDispatch(LinkedList<String> list) {
    List<Callable<Long>> tasks = new ArrayList<Callable<Long>>();
    List<Future<Long>> futureList = new ArrayList<Future<Long>>();
    int startPosition = 0;
    Pair<Integer, Integer> pair = calculateBlocks(list.size(), list.size());
    int numberOfThreads = pair.getRight();
    int blocks = pair.getLeft();

    barrier = new CyclicBarrier(numberOfThreads);

    for (int i = 0; i < numberOfThreads; i++) {
        String[] task = new String[blocks];
        System.arraycopy(list.toArray(), startPosition, task, 0, blocks);
        tasks.add(new AckMessageTask(barrier, task));
        startPosition += blocks;//w  w w. j a v  a  2s .  c o  m
    }

    ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads);
    try {
        futureList = executor.invokeAll(tasks);
    } catch (InterruptedException ex) {
        Logger.getLogger(AckMessageCache.class.getName()).log(Level.SEVERE, null, ex);
    }

    for (Future<Long> longFuture : futureList) {
        try {
            succTaskCount += longFuture.get();
        } catch (InterruptedException ex) {
            Logger.getLogger(AckMessageCache.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ExecutionException ex) {
            Logger.getLogger(AckMessageCache.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.commander4j.sys.JHostList.java

public void disconnectAll() {
    LinkedList<JHost> hl = new LinkedList<JHost>();
    hl = getHosts();/* w ww .j a v a2  s. c o  m*/

    if (hl.size() > 0) {
        for (int x = 0; x < hl.size(); x++) {
            String siteID = hl.get(x).getSiteNumber();

            if (Common.hostList.getHost(siteID).getConnectionCount() > 0) {
                Common.hostList.getHost(siteID).disconnectAll();
            }
        }
    }
}

From source file:de.ks.activity.initialization.ActivityInitialization.java

public Node getViewForController(Class<?> targetController) {
    if (!controllers.containsKey(targetController)) {
        throw new IllegalArgumentException("Controller " + targetController.getName()
                + " is not registered. Registered are " + controllers.keySet());
    }//w ww.  ja  v a  2  s.  com
    LinkedList<Pair<Object, Node>> ctrls = controllers.get(targetController);
    if (ctrls.isEmpty()) {
        return null;
    } else if (ctrls.size() == 1) {
        return ctrls.get(0).getRight();
    } else {
        throw new IllegalArgumentException(
                "There are " + ctrls.size() + " instances registered for the given controller");
    }
}

From source file:de.ks.activity.initialization.ActivityInitialization.java

@SuppressWarnings("unchecked")
public <T> T getControllerInstance(Class<T> targetController) {
    if (!controllers.containsKey(targetController)) {
        throw new IllegalArgumentException("Controller " + targetController
                + " is not registered. Registered are " + controllers.keySet());
    }/*from   ww  w .j  a v a2s. co m*/
    LinkedList<Pair<Object, Node>> ctrls = controllers.get(targetController);
    if (ctrls.isEmpty()) {
        return null;
    } else if (ctrls.size() == 1) {
        return (T) ctrls.get(0).getLeft();
    } else {
        throw new IllegalArgumentException(
                "There are " + ctrls.size() + " instances registered for the given controller");
    }
}