List of usage examples for java.util Vector size
public synchronized int size()
From source file:edu.ku.brc.af.core.SchemaI18NService.java
/** * Only Loads the Locales with empty Country and Variant */// w ww . ja va2 s . c o m public static void initializeLocales() { SchemaI18NService srv = getInstance(); if (srv != null) { Vector<Locale> locs = srv.getLocales(); if (locs.size() == 0) { for (Locale locale : Locale.getAvailableLocales()) { if (StringUtils.isNotEmpty(locale.getCountry())) { locs.add(locale); } } Collections.sort(locs, new Comparator<Locale>() { public int compare(Locale o1, Locale o2) { return o1.getDisplayName().compareTo(o2.getDisplayName()); } }); } } }
From source file:FileUtil.java
public static Vector removeDuplicates(Vector s) { int i = 0;/*from w w w. j ava 2 s. c o m*/ int j = 0; boolean duplicates = false; Vector v = new Vector(); for (i = 0; i < s.size(); i++) { duplicates = false; for (j = (i + 1); j < s.size(); j++) { if (s.elementAt(i).toString().equalsIgnoreCase(s.elementAt(j).toString())) { duplicates = true; } } if (duplicates == false) { v.addElement(s.elementAt(i).toString().trim()); } } return v; }
From source file:FileUtil.java
public static Vector removeDuplicates(Vector a, Vector b) { int i = 0;/*from ww w . j a v a2 s. c o m*/ int j = 0; boolean present = true; Vector v = new Vector(); for (i = 0; i < a.size(); i++) { present = false; for (j = 0; j < b.size(); j++) { if (a.elementAt(i).toString().equalsIgnoreCase(b.elementAt(j).toString())) { present = true; } } if (!(present)) { v.addElement(a.elementAt(i)); } } return v; }
From source file:com.netscape.cmsutil.util.Utils.java
/** * returns an array of strings from a vector of Strings * there'll be trouble if the Vector contains something other * than just Strings/*from w ww .java 2s . c om*/ */ public static String[] getStringArrayFromVector(Vector<String> v) { String s[] = new String[v.size()]; v.copyInto(s); return s; }
From source file:com.ricemap.spateDB.mapred.FileSplitUtil.java
/** * Takes a list of locations as a vector, and returns a unique array of * locations where locations on the head are more frequent in the original * vector than the ones on the tail.// ww w . ja va2s . c o m * * @param vlocations - A vector of locations with possible duplicates * @return - A unique array of locations. */ public static String[] prioritizeLocations(Vector<String> vlocations) { Collections.sort(vlocations); @SuppressWarnings("unchecked") Vector<String>[] locations_by_count = new Vector[vlocations.size() + 1]; int unique_location_count = 0; int first_in_run = 0; int i = 1; while (i < vlocations.size()) { if (vlocations.get(first_in_run).equals(vlocations.get(i))) { i++; } else { // End of run unique_location_count++; int count = i - first_in_run; if (locations_by_count[count] == null) { locations_by_count[count] = new Vector<String>(); } locations_by_count[count].add(vlocations.get(first_in_run)); first_in_run = i; } } // add last run unique_location_count++; int count = i - first_in_run; if (locations_by_count[count] == null) { locations_by_count[count] = new Vector<String>(); } locations_by_count[count].add(vlocations.get(first_in_run)); String[] unique_locations = new String[unique_location_count]; for (Vector<String> locations_with_same_count : locations_by_count) { if (locations_with_same_count == null) continue; for (String loc : locations_with_same_count) { unique_locations[--unique_location_count] = loc; } } if (unique_location_count != 0) throw new RuntimeException(); return unique_locations; }
From source file:eu.cassandra.csn.gui.Stats.java
/** * /* w ww .j ava2 s .com*/ * @param instInfo */ public static void updateTableModelSelected(Vector<InstallationInfo> instInfos) { for (int i = tableModelSelected.getRowCount() - 1; i >= 0; i--) { tableModelSelected.removeRow(i); } for (int i = 0; i < instInfos.size(); i++) { InstallationInfo instInfo = instInfos.get(i); String[] rowData = new String[5]; rowData[0] = (instInfo.getInstallationName() != null ? instInfo.getInstallationName() : ""); rowData[1] = (instInfo.getInstallationType() != null ? instInfo.getInstallationType() : ""); rowData[2] = String.valueOf( (instInfo.getTotalConsumption() != 0.0 ? instInfo.getTotalConsumption() : "")) + " kWh"; rowData[3] = String .valueOf((instInfo.getPeakComsumption() != 0.0 ? instInfo.getPeakComsumption() : "") + " W"); rowData[4] = String .valueOf((instInfo.getAvgConsumption() != 0.0 ? instInfo.getAvgConsumption() : "") + " W"); tableModelSelected.addRow(rowData); } Double[] data; if (instInfos.size() == 1) { String inst_id = instInfos.get(0).getID(); data = MongoQueries.getInstallationResults(inst_id); } else { data = new Double[0]; } XYSeries series1 = new XYSeries("First"); for (int i = 0; i < data.length / 15; i++) { double d = 0; for (int j = 0; j < 60; j++) { d += data[j * 60 + i]; } series1.add(i, d); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); chartPanel.getChart().getXYPlot().setDataset(dataset); }
From source file:com.fiorano.openesb.application.common.Param.java
/** * Returns param with name for class//from ww w .j a va2 s. co m */ public static Param getParamWithName(Vector params, String name) { int size = params.size(); if (size == 0) return null; try { for (int i = 0; i < size; i++) { Param param = (Param) params.get(i); //raf.writeBytes(param.toString()); if (param.getParamName().equals(name)) return param; } } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:eu.amidst.core.utils.Utils.java
/** * Returns the index of the maximum element in a given vector. * @param vector a {@link Vector} object. * @return an {@code int} that represents the index of the maximum element in the vector. *//*from w ww.ja va2s .com*/ public static int maxIndex(Vector vector) { double max = Double.NEGATIVE_INFINITY; int index = -1; for (int i = 0; i < vector.size(); i++) { if (vector.get(i) > max) { max = vector.get(i); index = i; } } if (index == -1) throw new IllegalStateException("There is no maximum. Probably a NaN value."); return index; }
From source file:eu.amidst.core.utils.Utils.java
/** * Returns the index of the minimum element in a given vector. * @param vector a {@link Vector} object. * @return an {@code int} that represents the index of the minimum element in the vector. */// w w w. j a va 2s. c o m public static int minIndex(Vector vector) { double min = Double.POSITIVE_INFINITY; int index = -1; for (int i = 0; i < vector.size(); i++) { if (vector.get(i) < min) { min = vector.get(i); index = i; } } if (index == -1) throw new IllegalStateException("There is no maximum. Probably a NaN value."); return index; }
From source file:de.innovationgate.wgpublisher.bi.BiBase.java
public static String getBrowserLanguageKey(javax.servlet.jsp.PageContext pageContext) { Enumeration enumLocales = pageContext.getRequest().getLocales(); Vector vecLocales = new Vector(); vecLocales.clear();/*w w w . j a va 2s .co m*/ String language = null; while (enumLocales.hasMoreElements()) vecLocales.add((Locale) enumLocales.nextElement()); for (int i = 0; i < vecLocales.size(); i++) { Locale currentLocale = (Locale) vecLocales.get(i); language = currentLocale.getLanguage().toUpperCase(); if (language.equalsIgnoreCase("DE") || language.equalsIgnoreCase("EN")) break; } if (language == null || language.equals("")) language = "EN"; return language; }