List of usage examples for java.util ListIterator hasNext
boolean hasNext();
From source file:com.offbynull.peernetic.playground.chorddht.model.FingerTable.java
/** * Searches the finger table for {@code id}. * @param id id to search for/*from w w w. j a v a2 s. c o m*/ * @return {@code true} if found, {@code false} otherwise * @throws NullPointerException if any arguments are {@code null} * @throws IllegalArgumentException if {@code id} has a different limit bit size than the base pointer's id */ public boolean contains(Id id) { Validate.notNull(id); Validate.isTrue(IdUtils.getBitLength(id) == bitCount); ListIterator<InternalEntry> lit = table.listIterator(); while (lit.hasNext()) { InternalEntry ie = lit.next(); if (ie.pointer.getId().equals(id)) { return true; } } return false; }
From source file:com.offbynull.peernetic.playground.chorddht.model.FingerTable.java
/** * Searches the finger table for the left-most occurrence of {@code ptr}. * @param ptr pointer to search for/*from ww w . j a v a 2 s . c o m*/ * @return index of occurrence, or -1 if not found * @throws NullPointerException if any arguments are {@code null} * @throws IllegalArgumentException if {@code ptr}'s id has a different limit bit size than the base pointer's id */ public int getMinimumIndex(Pointer ptr) { Validate.notNull(ptr); Validate.isTrue(IdUtils.getBitLength(ptr.getId()) == bitCount); Id id = ptr.getId(); Validate.isTrue(IdUtils.getBitLength(id) == bitCount); ListIterator<InternalEntry> lit = table.listIterator(); while (lit.hasNext()) { InternalEntry ie = lit.next(); if (ie.pointer.equals(ptr)) { return lit.nextIndex() - 1; } } return -1; }
From source file:playground.christoph.evacuation.analysis.EvacuationTimePictureWriter.java
private void histogramToKMZ(String transportMode, BasicLocation location, List<Double> listWithoutNaN) throws IOException { String filename = createFilenameFromLocation(location, "_" + transportMode + HISTOGRAM); if (filename == null) return;// w w w . ja va2 s . com double[] array = new double[listWithoutNaN.size()]; int i = 0; ListIterator<Double> iter = listWithoutNaN.listIterator(); while (iter.hasNext()) { array[i] = iter.next(); i++; } // if no valid travel times exist -> create an empty histogram if (array.length == 0) { array = new double[1]; array[0] = 0.0; } writeChartToKmz(filename, createHistogramChart(transportMode, array), HISTOGRAMWIDTH, HISTOGRAMHEIGHT); }
From source file:com.offbynull.peernetic.playground.chorddht.model.FingerTable.java
/** * Removes all fingers after {@code id} (does not remove {@code id} itself). * @param id id of which all fingers after it will be removed * @return number of fingers that were cleared * @throws NullPointerException if any arguments are {@code null} * @throws IllegalArgumentException if {@code id} has a different limit bit size than base pointer's id *///from w w w .j a v a 2s. c o m public int clearAfter(Id id) { Validate.notNull(id); Validate.isTrue(IdUtils.getBitLength(id) == bitCount); Id baseId = basePtr.getId(); ListIterator<InternalEntry> lit = table.listIterator(); while (lit.hasNext()) { InternalEntry ie = lit.next(); Pointer testPtr = ie.pointer; Id testId = testPtr.getId(); if (Id.comparePosition(baseId, id, testId) < 0) { int position = lit.nextIndex() - 1; clearAfter(position); return bitCount - position; } } return 0; }
From source file:gobblin.salesforce.SalesforceExtractor.java
public String buildUrl(String path, List<NameValuePair> qparams) throws RestApiClientException { URIBuilder builder = new URIBuilder(); builder.setPath(path);/* w ww .j ava2 s. c o m*/ ListIterator<NameValuePair> i = qparams.listIterator(); while (i.hasNext()) { NameValuePair keyValue = i.next(); builder.setParameter(keyValue.getName(), keyValue.getValue()); } URI uri; try { uri = builder.build(); } catch (Exception e) { throw new RestApiClientException("Failed to build url; error - " + e.getMessage(), e); } return new HttpGet(uri).getURI().toString(); }
From source file:mp.teardrop.SongTimeline.java
/** * Remove the song with the given id from the timeline. * * @param id The MediaStore id of the song to remove. *//*from w ww .j a v a 2 s. com*/ public void removeSong(long id) { synchronized (this) { saveActiveSongs(); ArrayList<Song> songs = mSongs; ListIterator<Song> it = songs.listIterator(); while (it.hasNext()) { int i = it.nextIndex(); if (Song.getId(it.next()) == id) { if (i < mCurrentPos) --mCurrentPos; it.remove(); } } broadcastChangedSongs(); } changed(); }
From source file:vteaexploration.plottools.panels.XYExplorationPanel.java
@Override public boolean isMade(int x, int y, int l, int size) { ListIterator<ArrayList> itr = ExplorationItems.listIterator(); String test;//from ww w . j a v a 2 s .c om String key = x + "_" + y + "_" + l + "_" + size; while (itr.hasNext()) { test = itr.next().get(0).toString(); if (key.equals(test)) { return true; } } return false; }
From source file:com.netflix.config.ConcurrentCompositeConfiguration.java
/** * Get a List of objects associated with the given configuration key. * If the key doesn't map to an existing object, the default value * is returned./*w w w .ja v a2 s .co m*/ * * @param key The configuration key. * @param defaultValue The default value. * @return The associated List of value. * */ @Override public List getList(String key, List defaultValue) { List<Object> list = new ArrayList<Object>(); // add all elements from the first configuration containing the requested key Iterator<AbstractConfiguration> it = configList.iterator(); if (overrideProperties.containsKey(key)) { appendListProperty(list, overrideProperties, key); } while (it.hasNext() && list.isEmpty()) { Configuration config = it.next(); if ((config != containerConfiguration || containerConfigurationChanged) && config.containsKey(key)) { appendListProperty(list, config, key); } } // add all elements from the in memory configuration if (list.isEmpty()) { appendListProperty(list, containerConfiguration, key); } if (list.isEmpty()) { return defaultValue; } ListIterator<Object> lit = list.listIterator(); while (lit.hasNext()) { lit.set(interpolate(lit.next())); } return list; }
From source file:com.xmobileapp.rockplayer.LastFmEventImporter.java
/********************************************* * /*from ww w.ja v a2s .c o m*/ * insertElementInFullList * *********************************************/ public void insertElementInFullList(ArtistEvent artistEvent) { /* * First Element */ if (artistEventList.isEmpty()) artistEventList.add(artistEvent); else { Log.i("STARTCMP", "starting"); ArtistEvent artistEventItem; ListIterator<ArtistEvent> artistEventListIterator = artistEventList.listIterator(); while (artistEventListIterator.hasNext()) { artistEventItem = artistEventListIterator.next(); Log.i("CMPTIME", artistEvent.dateInMillis + "<" + artistEventItem.dateInMillis); if (artistEvent.dateInMillis < artistEventItem.dateInMillis) { artistEventList.add(artistEventListIterator.nextIndex() - 1, artistEvent); return; } } artistEventList.add(artistEventList.size(), artistEvent); } }
From source file:com.danielme.android.webviewdemo.WebViewDemoActivity.java
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" }) @Override/* w ww . j av a2s . c o m*/ public void onCreate(Bundle savedInstanceState) { setTitle("?"); AndroidUtil.removeStrict(); super.onCreate(savedInstanceState); setContentView(R.layout.main); historyStack = new LinkedList<Link>(); webview = (WebView) findViewById(R.id.webkit); faviconImageView = (ImageView) findViewById(R.id.favicon); urlEditText = (EditText) findViewById(R.id.url); progressBar = (ProgressBar) findViewById(R.id.progressbar); stopButton = ((Button) findViewById(R.id.stopButton)); //favicon, deprecated since Android 4.3 but it's still necesary O_O ? WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath()); freeQuotaSwitch = (Switch) findViewById(R.id.freeQuotaSwitch); leftQuotaText = (TextView) findViewById(R.id.leftQuota); SharedPreferences settings = getSharedPreferences("setting", 0); userid = settings.getString("userid", "123"); tenantid = Integer.parseInt(settings.getString("tenantid", "3")); // check balance long balance = updateLeftQuota(); freeQuotaSwitch.setChecked(balance > 0); tmMgr = new TMManager(); // javascript and zoom webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setBuiltInZoomControls(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { webview.getSettings().setPluginState(PluginState.ON); } else { //IMPORTANT!! this method is no longer available since Android 4.3 //so the code doesn't compile anymore //webview.getSettings().setPluginsEnabled(true); } // downloads // webview.setDownloadListener(new CustomDownloadListener()); webview.setWebViewClient(new CustomWebViewClient()); webview.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { progressBar.setProgress(0); FrameLayout progressBarLayout = (FrameLayout) findViewById(R.id.progressBarLayout); progressBarLayout.setVisibility(View.VISIBLE); WebViewDemoActivity.this.setProgress(progress * 1000); TextView progressStatus = (TextView) findViewById(R.id.progressStatus); progressStatus.setText(progress + " %"); progressBar.incrementProgressBy(progress); if (progress == 100) { progressBarLayout.setVisibility(View.GONE); } } @Override public void onReceivedTitle(WebView view, String title) { WebViewDemoActivity.this.setTitle( getString(R.string.app_name) + " - " + WebViewDemoActivity.this.webview.getTitle()); for (Link link : historyStack) { if (link.getUrl().equals(WebViewDemoActivity.this.webview.getUrl())) { link.setTitle(title); } } } @Override public void onReceivedIcon(WebView view, Bitmap icon) { faviconImageView.setImageBitmap(icon); view.getUrl(); boolean b = false; ListIterator<Link> listIterator = historyStack.listIterator(); while (!b && listIterator.hasNext()) { Link link = listIterator.next(); if (link.getUrl().equals(view.getUrl())) { link.setFavicon(icon); b = true; } } } }); //http://stackoverflow.com/questions/2083909/android-webview-refusing-user-input webview.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); }