List of usage examples for java.util List clear
void clear();
From source file:com.google.uzaygezen.core.BoundedRollupTest.java
@Test public void nodeAndLeafCount() { final List<int[]> list = Lists.newArrayList(); IntArrayCallback callback = new ListCollector(list); for (int n = 0; n < 8; ++n) { list.clear(); // Exact sum means that no array will be a prefix of another one. TestUtils.generateSpecWithExactSum(n, 2 * n, callback); Collections.sort(list, IntArrayComparator.INSTANCE); BoundedRollup<Integer, LongContent> rollup = BoundedRollup.create(TestUtils.ZERO_LONG_CONTENT, Integer.MAX_VALUE); MapNode<Integer, LongContent> actual = createTree(list, rollup); checkTreeIsComplete(list, n, actual); }/*from ww w. j a va 2s. com*/ }
From source file:com.google.uzaygezen.core.BoundedRollupTest.java
@Test public void oneNodeAtMost() { final List<int[]> list = Lists.newArrayList(); IntArrayCallback callback = new ListCollector(list); for (int n = 0; n < 8; ++n) { list.clear(); // Exact sum means that no array will be a prefix of another one. TestUtils.generateSpecWithExactSum(n, 2 * n, callback); Collections.sort(list, IntArrayComparator.INSTANCE); BoundedRollup<Integer, LongContent> rollup = BoundedRollup.create(TestUtils.ZERO_LONG_CONTENT, 1); MapNode<Integer, LongContent> actual = createTree(list, rollup); Assert.assertEquals(MapNode.create(new LongContent(list.size()), ImmutableMap.<Integer, MapNode<Integer, LongContent>>of()), actual); }//from w w w . j a v a 2 s. co m }
From source file:com.redhat.persistence.oql.EquiSet.java
boolean add(List equal) { Integer to = null;/*from w ww . j av a 2 s . co m*/ List added = null; int addedidx = -1; m_from.clear(); for (int i = 0; i < equal.size(); i++) { Object o = equal.get(i); Integer idx = (Integer) m_nodes.get(o); if (idx == null) { if (added == null) { addedidx = allocatePartition(); added = getPartition(addedidx); } added.add(o); } else if (to == null) { to = idx; } else if (to.equals(idx)) { // do nothing } else { List top = getPartition(to); List fromp = getPartition(idx); if (fromp.size() > top.size()) { m_from.add(to); to = idx; } else { m_from.add(idx); } } } if (to == null) { if (added == null) { return false; } else { partitionAll(added, new Integer(addedidx)); return true; } } List top = getPartition(to); boolean modified = false; if (added != null) { if (added.size() > top.size()) { m_from.add(to); to = new Integer(addedidx); top = added; partitionAll(added, to); modified = true; } else { m_from.add(new Integer(addedidx)); } } for (int i = 0; i < m_from.size(); i++) { Integer idx = (Integer) m_from.get(i); List from = getPartition(idx); for (int j = 0; j < from.size(); j++) { Object o = from.get(j); top.add(o); m_nodes.put(o, to); } from.clear(); m_free.add(idx); modified = true; } return modified; }
From source file:edu.ku.brc.stats.BarChartPanel.java
public synchronized void allResultsBack(final QueryResultsContainerIFace qrc) { // create a dataset... String cat = ""; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); java.util.List<Object> list = handler.getDataObjects(); for (int i = 0; i < list.size(); i++) { Object descObj = list.get(i++); Object valObj = list.get(i); if (descObj != null && valObj != null) { dataset.addValue(getInt(valObj), getString(descObj), cat); }/*from ww w .ja va2 s .c o m*/ } list.clear(); // create the chart... JFreeChart jgChart = ChartFactory.createBarChart3D(title, // chart title xAxisTitle, // domain axis label yAxisTitle, // range axis label dataset, // data isVertical ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL, true, // include legend true, // tooltips? false // URLs? ); // create and display a frame... chartPanel = new org.jfree.chart.ChartPanel(jgChart, true, true, true, true, true); /*CustomColorBarChartRenderer ccbcr = new CustomColorBarChartRenderer() jgChart.getCategoryPlot().setRenderer(ccbcr); //Collection<LegendItem> items = jgChart.getCategoryPlot().getLegendItems(); for (int i=0;i<jgChart.getCategoryPlot().getLegendItems().getItemCount();i++) { LegendItem item = jgChart.getCategoryPlot().getLegendItems().get(i); item.setFillPaintTransformer(transformer) } //jgChart.getCategoryPlot().setRenderer(new CustomColorBarChartRenderer()); */ removeAll(); setLayout(new ChartLayoutManager(this)); add(chartPanel); validate(); doLayout(); repaint(); // TODO This is a kludge for now to get the BarChart to Paint Correctly UIRegistry.forceTopFrameRepaint(); }
From source file:com.jaeksoft.searchlib.crawler.file.database.FileManager.java
public int updateFetchStatus(AbstractSearchRequest searchRequest, FetchStatus fetchStatus, int bufferSize, TaskLog taskLog) throws SearchLibException { setCurrentTaskLog(taskLog);/*w w w . j a v a 2s . c om*/ try { int total = 0; FileItemFieldEnum.INSTANCE.fetchStatus.addFilterQuery(searchRequest, fetchStatus.value, false, true); List<FileItem> fileItemList = new ArrayList<FileItem>(); for (;;) { fileItemList.clear(); getFileList(searchRequest, 0, bufferSize, fileItemList); if (fileItemList.size() == 0) break; for (FileItem fileItem : fileItemList) fileItem.setFetchStatus(fetchStatus); updateFileItems(fileItemList); total += fileItemList.size(); taskLog.setInfo(total + " URI(s) updated"); if (taskLog.isAbortRequested()) throw new SearchLibException.AbortException(); } return total; } catch (ParseException e) { throw new SearchLibException(e); } finally { resetCurrentTaskLog(); } }
From source file:com.anyuan.thomweboss.persistence.jdbcimpl.user.UserDaoJdbcImpl.java
@Override public List<User> listAll() { // Connection conn = getConnection(); final List<User> listUser = new ArrayList<User>(); String sql = "select * from t_user"; getJdbcTemplate().query(sql, new RowCallbackHandler() { @Override/*w w w. ja v a 2s . c om*/ public void processRow(ResultSet rs) throws SQLException { listUser.clear(); User user = null; while (rs.next()) { user = new User(); user.setId(rs.getLong("f_id")); user.setUsername(rs.getString("f_username")); user.setNickname(rs.getString("f_nickname")); listUser.add(user); } // rs.close(); // , ResultSet ? } }); // try { // Statement state = conn.createStatement(); // ResultSet rs = state.executeQuery(sql); // listUser = new ArrayList<User>(); // User user = null; // while (rs.next()) { // System.out.println(rs.getString(3)); // user = new User(); // user.setId(rs.getLong("f_id")); // user.setUsername(rs.getString("f_username")); // user.setNickname(rs.getString("f_nickname")); // listUser.add(user); // // } // rs.close(); // } catch (SQLException e) { // e.printStackTrace(); // } finally { // try { // conn.close(); // } catch (SQLException e) { // e.printStackTrace(); // } // } return listUser; }
From source file:edu.nd.darts.cimon.NDroidAdmin.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.administrator); // Toast.makeText(getBaseContext(), "This is", // Toast.LENGTH_LONG).show(); startService(new Intent(this, NDroidService.class)); Resources res = getResources(); // Resource object to get Drawables TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; // Reusable TabSpec for each tab Intent intent; // Reusable Intent for each tab // Create an Intent to launch an Activity for the tab (to be reused) // intent = new Intent().setClass(this, NDroidSystem.class); intent = new Intent().setClass(this, CimonListView.class); intent.putExtra("key", Metrics.TYPE_SYSTEM); // Initialize a TabSpec for each tab and add it to the TabHost spec = tabHost.newTabSpec("system").setIndicator("System", res.getDrawable(R.drawable.icon_system)) .setContent(intent);/*from w w w . j ava2 s . com*/ tabHost.addTab(spec); // Do the same for the other tabs // intent = new Intent().setClass(this, NDroidSensor.class); intent = new Intent().setClass(this, CimonListView.class); intent.putExtra("key", Metrics.TYPE_SENSOR); spec = tabHost.newTabSpec("sensors").setIndicator("Sensors", res.getDrawable(R.drawable.icon_sensor)) .setContent(intent); tabHost.addTab(spec); // intent = new Intent().setClass(this, NDroidUser.class); intent = new Intent().setClass(this, CimonListView.class); intent.putExtra("key", Metrics.TYPE_USER); spec = tabHost.newTabSpec("user").setIndicator("User Activity", res.getDrawable(R.drawable.icon_user)) .setContent(intent); tabHost.addTab(spec); tabHost.setCurrentTab(0); SharedPreferences appPrefs = getSharedPreferences(SHARED_PREFS, Context.MODE_PRIVATE); int storedVersion = appPrefs.getInt(PREF_VERSION, -1); int appVersion = -1; try { appVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (DebugLog.DEBUG) Log.d(TAG, "NDroidAdmin.onCreate - appVersion:" + appVersion + " storedVersion:" + storedVersion); if (appVersion > storedVersion) { new Thread(new Runnable() { public void run() { List<MetricService<?>> serviceList; serviceList = MetricService.getServices(Metrics.TYPE_SYSTEM); for (MetricService<?> mService : serviceList) { mService.insertDatabaseEntries(); } serviceList.clear(); serviceList = MetricService.getServices(Metrics.TYPE_SENSOR); for (MetricService<?> mService : serviceList) { mService.insertDatabaseEntries(); } serviceList.clear(); serviceList = MetricService.getServices(Metrics.TYPE_USER); for (MetricService<?> mService : serviceList) { mService.insertDatabaseEntries(); } serviceList.clear(); } }).start(); SharedPreferences.Editor editor = appPrefs.edit(); editor.putInt(PREF_VERSION, appVersion); editor.commit(); } }
From source file:edu.pitt.dbmi.ipm.service.storage.Storage.java
/** * Return query result as array of Strings * /*from www .j av a 2 s . co m*/ * @param res * @param jObj * @param jArr * @param val * @return Strings[] */ public String[] jsonResAsArray(JSONObject res, String jObj, String jArr, String val) { try { JSONArray bindings = (res.getJSONObject(jObj)).getJSONArray(jArr); String userID = null; List<String> rr = new ArrayList<String>(); for (int i = 0; i < bindings.length(); i++) { JSONObject c = bindings.getJSONObject(i); rr.add(new JSONObject(c.getString(val)).getString("value")); } Collections.sort(rr, String.CASE_INSENSITIVE_ORDER); String[] toret = rr.toArray(new String[rr.size()]); rr.clear(); rr = null; return toret; } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:net.sf.jabref.gui.search.SearchResultsDialog.java
/** * Set up the comparators for each column, so the user can modify sort order * by clicking the column labels.// w w w. jav a2 s .c om * @param comparatorChooser The comparator chooser controlling the sort order. */ private void setupComparatorChooser(TableComparatorChooser<BibEntry> comparatorChooser) { // First column: List<Comparator> comparators = comparatorChooser.getComparatorsForColumn(0); comparators.clear(); comparators = comparatorChooser.getComparatorsForColumn(1); comparators.clear(); // Icon columns: for (int i = 0; i < PAD; i++) { comparators = comparatorChooser.getComparatorsForColumn(i); comparators.clear(); if (i == FILE_COL) { comparators.add(new IconComparator(Collections.singletonList(FieldName.FILE))); } else if (i == URL_COL) { comparators.add(new IconComparator(Collections.singletonList(FieldName.URL))); } } // Remaining columns: for (int i = PAD; i < (PAD + FIELDS.length); i++) { comparators = comparatorChooser.getComparatorsForColumn(i); comparators.clear(); comparators.add(new FieldComparator(FIELDS[i - PAD])); } sortedEntries.getReadWriteLock().writeLock().lock(); comparatorChooser.appendComparator(PAD, 0, false); sortedEntries.getReadWriteLock().writeLock().unlock(); }
From source file:com.qspin.qtaste.testsuite.impl.JythonTestScript.java
/** * Parses a PythonDoc comment and returns a map of tag names to descriptions * * @param pythonDoc a PythonDoc comment// w w w . j ava 2 s. com * @return a map of tag names to descriptions; the description before tags * is mapped to an empty tag name */ public static HashMap<String, String> parsePythonDoc(String pythonDoc) { HashMap<String, String> tagsDoc = new HashMap<>(); String[] lines = pythonDoc.split("\\s*\n\\s*"); String tag = ""; List<String> textLines = new ArrayList<>(); for (String line : lines) { if (line.startsWith("@")) { tagsDoc.put(tag, Strings.join(textLines, "\n")); String[] tagAndText = line.substring(1).split("\\s+", 2); tag = tagAndText[0]; textLines.clear(); if (tagAndText.length == 2) { textLines.add(tagAndText[1]); } } else { textLines.add(line); } } tagsDoc.put(tag, Strings.join(textLines, "\n")); return tagsDoc; }