List of usage examples for java.util LinkedList size
int size
To view the source code for java.util LinkedList size.
Click Source Link
From source file:com.mchp.android.PIC32_BTSK.TemperatureFragment.java
void setGraphViewData(LinkedList<Integer> l) { int i;/* ww w . j ava 2 s . c o m*/ for (i = 0; i < l.size(); i++) { graphViewData[i] = new GraphViewData(i, l.get(i)); } }
From source file:com.example.app.support.service.AppUtil.java
/** * Get a valid source component from the component path. This is similar to * {@link ApplicationRegistry#getValidSourceComponent(Component)} but is able to find the source component even * when a pesky dialog is in the in way as long as the dialog had {@link #recordDialogsAncestorComponent(Dialog, Component)} * call on it.//ww w .j ava 2 s .c o m * * @param component the component to start the search on * * @return a valid source component that has an ApplicationFunction annotation. * * @throws IllegalArgumentException if a valid source component could not be found. */ @Nonnull public static Component getValidSourceComponentAcrossDialogs(Component component) { LinkedList<Component> path = new LinkedList<>(); do { path.add(component); if (component.getClientProperty(CLIENT_PROP_DIALOGS_ANCESTRY) instanceof Component) component = (Component) component.getClientProperty(CLIENT_PROP_DIALOGS_ANCESTRY); else component = component.getParent(); } while (component != null); final ListIterator<Component> listIterator = path.listIterator(path.size()); while (listIterator.hasPrevious()) { final Component previous = listIterator.previous(); if (previous.getClass().isAnnotationPresent(ApplicationFunction.class)) return previous; } throw new IllegalArgumentException("Component path does not contain an application function."); }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
public View getView(int position, View convertView, ViewGroup parent) { Slot slot = listOfSlot.get(position); convertView = inflater.inflate(R.layout.meteogram_layout, null); LinearLayout linear = (LinearLayout) convertView.findViewById(R.id.meteogram); LinkedList<Row> rows = slot.getListOfRows(); for (int i = 0; i < rows.size(); i++) linear = getRow(rows.get(i), linear); return convertView; }
From source file:com.erudika.para.rest.RestUtils.java
/** * Batch create response as JSON/*www.ja v a 2s .c o m*/ * @param app the current App object * @param is entity input stream * @return a status code 200 or 400 */ public static Response getBatchCreateResponse(final App app, InputStream is) { final LinkedList<ParaObject> objects = new LinkedList<ParaObject>(); Response entityRes = getEntity(is, List.class); if (entityRes.getStatusInfo() == Response.Status.OK) { List<Map<String, Object>> items = (List<Map<String, Object>>) entityRes.getEntity(); for (Map<String, Object> object : items) { ParaObject pobj = ParaObjectUtils.setAnnotatedFields(object); if (pobj != null && ValidationUtils.isValidObject(pobj)) { pobj.setAppid(app.getAppIdentifier()); objects.add(pobj); } } Para.getDAO().createAll(app.getAppIdentifier(), objects); Para.asyncExecute(new Runnable() { public void run() { int typesCount = app.getDatatypes().size(); app.addDatatypes(objects.toArray(new ParaObject[objects.size()])); if (typesCount < app.getDatatypes().size()) { app.update(); } } }); } else { return entityRes; } return Response.ok(objects).build(); }
From source file:com.swordlord.gozer.databinding.DataBindingMember.java
private String resolveTableName(LinkedList<DataBindingElement> elements, String strTableName) { // if there are no elements or only one, then this element must be the table name if ((elements == null) || (elements.size() <= 1)) { return strTableName; }/*w w w .j a v a 2 s .c o m*/ // otherwise walk the references to find the table ObjEntity parentTable = DBConnection.instance().getObjectContext().getEntityResolver() .getObjEntity(strTableName); for (DataBindingElement element : elements) { if (!element.isField()) { String strPathElement = element.getPathElement(); LOG.debug("TableName/PatheElement=" + strTableName + "/" + strPathElement); // ignore the same level if (strPathElement.compareToIgnoreCase(strTableName) != 0) { ObjRelationship rel = (ObjRelationship) parentTable.getRelationship(strPathElement); parentTable = (ObjEntity) rel.getTargetEntity(); } } } return parentTable.getName(); }
From source file:io.mapzone.controller.vm.provisions.MaxProcesses.java
@Override public Status execute() throws Exception { checked.set(this); assert process .isPresent() : "No process in context. Make sure that MaxProcesses executes after ProcessStarted."; HostRecord host = process.get().instance.get().host.get(); if (host.statistics.get() == null || host.statistics.get().olderThan(10, TimeUnit.SECONDS)) { host.updateStatistics();/* w w w.ja v a 2s . c o m*/ // lowest start time (oldest) first LinkedList<ProcessRecord> sortedProcesses = host.instances.stream().filter(i -> i.process.get() != null) .map(i -> i.process.get()).sorted((p1, p2) -> p1.started.get().compareTo(p2.started.get())) .collect(Collectors.toCollection(LinkedList::new)); log.info(" PROCESSES RUNNING: " + sortedProcesses.size() + " (" + host.statistics.get().lastChecked.get() + ")"); // stop processes, oldest first while (sortedProcesses.size() > MAX_PROCESSES) { ProcessRecord p = sortedProcesses.remove(0); log.info(" stopping process: " + p.instance.get().project.get() + " -- started at " + p.started.get()); StopProcessOperation op = new StopProcessOperation(); op.process.set(p); op.vmUow.set(vmUow()); op.execute(null, null); } } return OK_STATUS; }
From source file:com.pavikumbhar.javaheart.util.PasswordGenerator.java
private String generatePassword(int length) { int count = c.length; LinkedList<Character> s = new LinkedList<Character>(); LinkedList<Character> s1 = new LinkedList<Character>(); Collections.addAll(s, c);// w ww .j a va2s . c om while (count > 0) { long n = generateRandomNumber(); int position = (int) (n % count); s1.add(s.remove(position)); count--; } String pwd = null; //System.out.println(">>"+s1.toString()); Character[] c1 = new Character[s1.size()]; c1 = s1.toArray(c1); String s2 = new String(f1(c1)); //System.out.println(">>"+s2); return RandomStringUtils.random(length, s2); }
From source file:com.asakusafw.directio.tools.DirectIoList.java
@Override public int run(String[] args) throws Exception { LinkedList<String> argList = new LinkedList<>(); Collections.addAll(argList, args); while (argList.isEmpty() == false) { String arg = argList.removeFirst(); if (arg.equals("--")) { //$NON-NLS-1$ break; } else {//from ww w .j a va 2 s. co m argList.addFirst(arg); break; } } if (argList.size() < 2) { LOG.error(MessageFormat.format("Invalid arguments: {0}", Arrays.toString(args))); System.err.println(MessageFormat.format( "Usage: hadoop {0} -conf <datasource-conf.xml> base-path resource-pattern [resource-pattern [...]]", getClass().getName())); return 1; } String path = argList.removeFirst(); List<FilePattern> patterns = new ArrayList<>(); for (String arg : argList) { patterns.add(FilePattern.compile(arg)); } if (repository == null) { repository = HadoopDataSourceUtil.loadRepository(getConf()); } String basePath = repository.getComponentPath(path); DirectDataSource source = repository.getRelatedDataSource(path); for (FilePattern pattern : patterns) { List<ResourceInfo> list = source.list(basePath, pattern, new Counter()); for (ResourceInfo info : list) { System.out.println(info.getPath()); } } return 0; }
From source file:aiai.ai.core.ExecProcessService.java
private String readLastLines(int maxSize, File consoleLogFile) throws IOException { LinkedList<String> lines = new LinkedList<>(); String inputLine;// ww w . j a va 2s . c o m try (FileReader fileReader = new FileReader(consoleLogFile); BufferedReader in = new BufferedReader(fileReader)) { while ((inputLine = in.readLine()) != null) { inputLine = inputLine.trim(); if (lines.size() == maxSize) { lines.removeFirst(); } lines.add(inputLine); } } StringBuilder sb = new StringBuilder(); for (String line : lines) { sb.append(line).append('\n'); } return sb.toString(); }
From source file:gr.aueb.cs.nlp.wordtagger.data.structure.features.FeatureBuilder.java
/** * generate features for embedding for a single word without lookarounds. * @param set//from w ww. java 2 s . co m * @param gwv */ public void generateFeats(LinkedList<Word> set, Embeddings gwv) { for (int i = 0; i < set.size(); i++) { Word w = set.get(i); double[] word2VecFeats = new double[0]; int lookBehind = 0; // get the feaure vecs of previous words for (int j = 1; j <= lookBehind; j++) { if (i - j < 0) { // if the previous words are out of index, we ll generate // some random word2Vecs vecs word2VecFeats = ArrayUtils.addAll(word2VecFeats, embeddingFeats(new Word("beginStringRandomGen" + Integer.toString(j)), gwv)); } else { word2VecFeats = ArrayUtils.addAll(word2VecFeats, embeddingFeats(set.get((i - j)), gwv)); } } // get the feature vecs of next words int lookAhead = 0; for (int j = 1; j <= lookAhead; j++) { if (i + j >= set.size()) { // if the next words are out of index, we ll generate some // random word2Vecs vecs word2VecFeats = ArrayUtils.addAll(word2VecFeats, embeddingFeats(new Word("finishStringRAndomGen" + Integer.toString(j)), gwv)); } else { word2VecFeats = ArrayUtils.addAll(word2VecFeats, embeddingFeats(set.get((i + j)), gwv)); } } word2VecFeats = ArrayUtils.addAll(word2VecFeats, embeddingFeats(w, gwv)); // System.out.println("size " + word2VecFeats.length); if (w.getFeatureVec() == null) { w.setFeatureVec(new FeatureVector(word2VecFeats)); } else { w.setFeatureVec(new FeatureVector(ArrayUtils.addAll(w.getFeatureVec().getValues(), word2VecFeats))); } } System.out.println("current vec size " + set.get(3).getFeatureVec().getValues().length); }