List of usage examples for java.util LinkedList listIterator
ListIterator<E> listIterator();
From source file:Main.java
public static void main(String[] args) { LinkedList<String> lList = new LinkedList<String>(); lList.add("1"); lList.add("2"); lList.add("3"); lList.add("4"); lList.add("5"); ListIterator itr = lList.listIterator(); System.out.println("forward direction"); while (itr.hasNext()) { System.out.println(itr.next()); }/*from w ww . jav a 2 s . c o m*/ System.out.println("reverse direction"); while (itr.hasPrevious()) { System.out.println(itr.previous()); } }
From source file:base.Engine.java
public static LinkedList<PatternInstance> cleanList(LinkedList<PatternInstance> toClean) { PatternInstance nowPatternInstance = null; for (ListIterator<PatternInstance> li = toClean.listIterator(); li.hasNext();) { nowPatternInstance = li.next();/*from www. j av a 2s .co m*/ if (nowPatternInstance.getEntry().equals(nullPattern)) { li.remove(); } } return toClean; }
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 ww w. j a v 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)); } }
From source file:base.Engine.java
static LinkedList<PatternInstance> massMerge(Set<TreeSet<PatternInstance>> collisions, LinkedList<PatternInstance> instances, ReferenceMap<PatternWrapper, PatternEntry> knownPatterns, Ruleset rule) {/*from w ww .j av a2s . c om*/ PatternInstance currentInstances = null; for (ListIterator<PatternInstance> i = instances.listIterator(); i.hasNext();) { currentInstances = i.next(); boolean shouldRemove = false; for (TreeSet<PatternInstance> groups : collisions) { if (groups.contains(currentInstances)) { shouldRemove = true; break; } } if (shouldRemove) i.remove(); } for (TreeSet<PatternInstance> group : collisions) { TreeSet<PatternInstance> runningParts = group; boolean stillFindingParts = true; while (stillFindingParts) { stillFindingParts = false; eachMatchLoop: for (PatternInstance part1 : runningParts) for (PatternInstance part2 : runningParts) if (part1 != part2 && part1.collides(rule, part2)) { stillFindingParts = true; runningParts.remove(part1); runningParts.remove(part2); runningParts.add(part1.merge(knownPatterns, part2)); break eachMatchLoop; } } for (PatternInstance part : runningParts) { instances.add(part); } } return instances; }
From source file:msearch.filmeSuchen.sender.MediathekReader.java
boolean istInListe(LinkedList<String> liste, String str) { boolean ret = false; Iterator<String> it = liste.listIterator(); while (it.hasNext()) { if (it.next().equals(str)) { ret = true;/* www. j a v a2s .c o m*/ break; } } return ret; }
From source file:msearch.filmeSuchen.sender.MediathekReader.java
boolean istInListe(LinkedList<String[]> liste, String str, int nr) { boolean ret = false; Iterator<String[]> it = liste.listIterator(); while (it.hasNext()) { if (it.next()[nr].equals(str)) { ret = true;//from w ww. java 2 s . c om break; } } return ret; }
From source file:com.wsl.marketconsolescraper.logic.Scraper.java
/** * Performs a scrape./*from ww w . j a v a 2s . c om*/ * @return scraped application data */ public Collection<AndroidMarketListing> scrape() { log("Scraper starting."); final HtmlPage signedInPage = getMarketPage(); log("Market page title: " + signedInPage.getTitleText()); String pageAsText = signedInPage.asText(); log("Market page text: " + pageAsText); LinkedList<AndroidMarketListing> applicationInfo = new LinkedList<AndroidMarketListing>(); for (ListingDataItemRetriever item : mappings) { ListIterator<AndroidMarketListing> appInfoIterator = applicationInfo.listIterator(); item.retrieveAppInfoItems(signedInPage, appInfoIterator); } log("Application info map: " + applicationInfo); return applicationInfo; }
From source file:edu.ehu.galan.lite.algorithms.unranked.supervised.shallowParsingGrammar.cg3.ShallowParsingGrammarAlgortithm.java
@Override public void runAlgorithm() { generateTempFolders();//from www. ja va2s . c o m List<String> candidateList; // StringBuilder sb = new StringBuilder(); PlainTextDocumentReaderFreeLingEn en = new PlainTextDocumentReaderFreeLingEn(propsDir); // for (Iterator<Document> it = corpus.getIterator(); it.hasNext();) { // Document doc = it.next(); en.readSource(doc.getPath()); StringBuilder docr = new StringBuilder(); //int i = 0; List<LinkedList<Token>> tokenList = en.getTokenizedSentenceList(); //TODO, cheap identifier to process all the grammar in one CG3 service call docr.append("@@@@@new_sentence@@@@@ @@@@@new_sentence@@@@@ @@@@@new_sentence@@@@@") .append(System.getProperty("line.separator")); // long start = System.currentTimeMillis(); for (LinkedList<Token> token : tokenList) { for (ListIterator<Token> itr = token.listIterator(); itr.hasNext();) { Token tok = itr.next(); // sb.append(tok.getWordForm()).append(" ").append(tok.getLemma()).append(" ").append(tok.getPosTag()).append(System.getProperty("line.separator")); docr.append(tok.getWordForm()).append(" ").append(tok.getLemma()).append(" ") .append(tok.getPosTag()).append(System.getProperty("line.separator")); } // String result = processSentence(sb); // if (result != null) { //// System.out.println(result); // candidateList.add(result + i); // } docr.append("@@@@@new_sentence@@@@@ @@@@@new_sentence@@@@@ @@@@@new_sentence@@@@@") .append(System.getProperty("line.separator")); // sb = new StringBuilder(); // i++; } // long end = System.currentTimeMillis(); //System.out.println("Execution time was " + (end - start) + " ms."); //start = System.currentTimeMillis(); candidateList = processDocument(docr); //end = System.currentTimeMillis(); //System.out.println("Execution time was " + (end - start) + " ms."); // } // for (String string : candidateList) { // System.out.println(string); // } TopicExtractorEnglish topic = new TopicExtractorEnglish(doc, propsDir); topic.loadCandidates(candidateList); topic.extractTopics(); topic.cleanTopics(); List<String> list = topic.getTopics(); List<Term> terms = list.stream().map(s -> new Term(s)).collect(Collectors.toList()); doc.addListTerm(new ListTerm(this.getName(), terms)); super.setTermList(terms); // super.saveToTmp(); // termList.clear(); if (commande != null) { commande.closeStreams(); } // saveToTmp(); }
From source file:com.sun.portal.rssportlet.SettingsHandler.java
private LinkedList stripDelimiter(LinkedList feeds) { LinkedList stripFeeds = new LinkedList(); Iterator it = feeds.listIterator(); while (it.hasNext()) { String feed = (String) it.next(); String[] delimFeed = feed.split(":dlm:"); if (delimFeed != null && delimFeed.length != 0) { System.out.println("SettingsHandler delim Feeds[:dlm:] LinkedList***********" + delimFeed[delimFeed.length - 1]); stripFeeds.add(delimFeed[delimFeed.length - 1]); }/*from w ww . jav a 2s. c o m*/ } return stripFeeds; }
From source file:com.sun.portal.rssportlet.SettingsHandler.java
/** Set the feed titles for list of feeds. * if title is missing it's set to feed URL */// w ww. ja v a 2 s . c om private void setFeedTitleList(LinkedList feeds) { LinkedList titleList = new LinkedList(); LinkedList feedList = new LinkedList(); Iterator it = feeds.listIterator(); while (it.hasNext()) { String feed = (String) it.next(); String title = null; try { SyndFeed syndfeed = FeedHelper.getInstance().getFeed(getSettingsBean(), feed); if (syndfeed != null) { title = syndfeed.getTitle(); } } catch (FeedException fe) { log.info("setFeedTitleList: could not add feed FeedException " + feed + ":" + fe.getMessage()); getPortletConfig().getPortletContext().log("could not add feed FeedException:" + feed, fe); } catch (IOException ioe) { log.info("setFeedTitleList: could not add feed IOException " + feed + ":" + ioe.getMessage()); getPortletConfig().getPortletContext().log("could not add feed IOException:" + feed, ioe); } catch (Exception ex) { log.info("setFeedTitleList: could not add feed Exception " + feed + ":" + ex.getMessage()); getPortletConfig().getPortletContext().log("could not add feed Exception:" + feed, ex); } if (title == null || title.length() == 0) { title = feed; } titleList.add(title); } //set feed titles list getSettingsBean().setTitleList(titleList); }