List of usage examples for java.util Vector add
public void add(int index, E element)
From source file:Main.java
public static void main(String args[]) { Vector vec = new Vector(5); for (int i = 0; i < 10; i++) { vec.add(0, i); }/*from w w w .ja v a 2s . co m*/ System.out.println("Content of the vector: " + vec); System.out.println("Size of the vector: " + vec.size()); // ensure the capacity of the vector and add elements vec.ensureCapacity(40); for (int i = 0; i < 10; i++) { vec.add(0, i); } System.out.println(vec); System.out.println(vec.size()); }
From source file:MainClass.java
public static void main(String args[]) { Vector v = new Vector(5); for (int i = 0; i < 10; i++) { v.add(0, i); }// w ww .j a va 2 s. c o m System.out.println(v); Vector v2 = new Vector(5); for (int i = 0; i < 5; i++) { v2.add(0, i); } System.out.println(v2); System.out.println(v2.equals(v)); v.retainAll(v2); System.out.println(v); }
From source file:Main.java
public static void main(String args[]) { Vector<Object> v = new Vector<Object>(5); for (int i = 0; i < 10; i++) { v.add(0, i); }//w ww. java 2s . c om System.out.println(v); v.setSize(3); System.out.println(v); }
From source file:Main.java
public static void main(String args[]) { Vector<Object> v = new Vector<Object>(5); for (int i = 0; i < 10; i++) { v.add(0, i); }//from w w w .j a va 2 s. c o m System.out.println(v); for (int i = 0; i < 10; i++) { v.set(i, "A"); } System.out.println(v); }
From source file:Main.java
public static void main(String args[]) { Vector<Integer> v = new Vector<Integer>(5); for (int i = 0; i < 10; i++) { v.add(0, i); }//from w w w . j av a 2 s . com System.out.println(v); Vector<Integer> v2 = new Vector<Integer>(5); for (int i = 0; i < 10; i++) { v2.add(0, i); } System.out.println(v2); System.out.println(v2.equals(v)); v2.removeAll(v); System.out.println(v2); }
From source file:Main.java
public static <K1, K2, V> Map<K2, V> mapGetOrCreateVector(Vector<Map<K2, V>> vectorOfMaps, int index) { Map<K2, V> m = vectorOfMaps.elementAt(index); if (null == m) { m = newMap();//w w w . j a v a 2 s. c om vectorOfMaps.add(index, m); } return m; }
From source file:org.jdal.swing.form.FormUtils.java
/** * Add a link on primary and dependent JComboBoxes by property name. * When selection changes on primary use propertyName to get a Collection and fill dependent JComboBox with it * @param primary JComboBox when selection changes * @param dependent JComboBox that are filled with collection * @param propertyName the property name for get the collection from primary selected item * @param addNull if true, add a null as first combobox item *///from w ww . j a v a2 s . c om @SuppressWarnings("rawtypes") public static void link(final JComboBox primary, final JComboBox dependent, final String propertyName, final boolean addNull) { primary.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object selected = primary.getSelectedItem(); if (selected != null) { BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(selected); if (wrapper.isWritableProperty(propertyName)) { Collection collection = (Collection) wrapper.getPropertyValue(propertyName); Vector<Object> vector = new Vector<Object>(collection); if (addNull) vector.add(0, null); DefaultComboBoxModel model = new DefaultComboBoxModel(vector); dependent.setModel(model); } else { log.error("Can't write on propety '" + propertyName + "' of class: '" + selected.getClass() + "'"); } } } }); }
From source file:corner.util.VectorUtils.java
/** * ??./*w w w . ja va 2 s .co m*/ * * @param list * ??. * @return ???. * @TODO ????. */ public static <T> Vector<Double> sumList(List<Vector<T>> list) { Vector<Double> r = new Vector<Double>(); if (list.size() == 0) { return r; } StringBuffer sb = new StringBuffer(); int width = list.get(0).size(); for (int i = 0; i < width; i++) { for (Vector<T> v : list) { sb.append(v.get(i)); sb.append("+"); } sb.append("0"); r.add(i, expr(sb.toString())); sb.setLength(0); } return r; }
From source file:uk.ac.leeds.ccg.andyt.projects.moses.process.RegressionReport_UK1.java
protected static Object[] loadDataHSARHP_ISARCEP(File a_SARFile, File a_CASFile) throws IOException { Object[] result = new Object[3]; TreeMap<String, double[]> a_SAROptimistaionConstraints = loadCASOptimistaionConstraints(a_SARFile); TreeMap<String, double[]> a_CASOptimistaionConstraints = loadCASOptimistaionConstraints(a_CASFile); Vector<String> variables = GeneticAlgorithm_HSARHP_ISARCEP.getVariableList(); variables.add(0, "Zone_Code"); String[] variableNames = new String[0]; variableNames = variables.toArray(variableNames); result[0] = variableNames;/*from w w w .j a va2s .c o m*/ // Format (Flip) data double[][] a_SARExpectedData = new double[variables.size() - 1][a_SAROptimistaionConstraints.size()]; double[][] a_CASObservedData = new double[variables.size() - 1][a_SAROptimistaionConstraints.size()]; String oa; double[] a_SARExpectedRow; double[] a_CASObservedRow; int j = 0; Iterator<String> iterator_String = a_SAROptimistaionConstraints.keySet().iterator(); while (iterator_String.hasNext()) { oa = iterator_String.next(); a_SARExpectedRow = a_SAROptimistaionConstraints.get(oa); a_CASObservedRow = a_CASOptimistaionConstraints.get(oa); // if (oa.equalsIgnoreCase("00AAFQ0013")){ // System.out.println(oa); // } if (a_SARExpectedRow == null) { System.out.println( "Warning a_SARExpectedRow == null in loadDataHSARHP_ISARCEP(File,File) for OA " + oa); } else { if (a_CASObservedRow == null) { System.out.println( "Warning a_SARExpectedRow == null in loadDataHSARHP_ISARCEP(File,File) for OA " + oa); } else { for (int i = 0; i < variables.size() - 1; i++) { a_SARExpectedData[i][j] = a_SARExpectedRow[i]; a_CASObservedData[i][j] = a_CASObservedRow[i]; } } } j++; } result[1] = a_SARExpectedData; result[2] = a_CASObservedData; return result; }
From source file:uk.ac.leeds.ccg.andyt.projects.moses.process.RegressionReport_UK1.java
/** * * @param a_SAR_File//from w w w . j a v a2s .c om * @param a_CAS_File * @return Object[] result where; * result[0] is a String[] of variable names * result[1] is a double[number of variables][no of data items] * of a_SAR_data * result[2] is a double[number of variables][no of data items] * of a_CAS_data * @throws IOException */ protected static Object[] loadDataISARHP_ISARCEP(File a_SAR_File, File a_CAS_File) throws IOException { Object[] result = new Object[3]; TreeMap<String, double[]> a_SAROptimistaionConstraints_TreeMap = loadCASOptimistaionConstraints(a_SAR_File); TreeMap<String, double[]> a_CASOptimistaionConstraints_TreeMap = loadCASOptimistaionConstraints(a_CAS_File); Vector<String> variables = GeneticAlgorithm_ISARHP_ISARCEP.getVariableList(); variables.add(0, "Zone_Code"); String[] variableNames = new String[0]; variableNames = variables.toArray(variableNames); result[0] = variableNames; // Format (Flip) data double[][] a_SAR_Data = new double[variables.size() - 1][a_SAROptimistaionConstraints_TreeMap.size()]; double[][] a_CAS_Data = new double[variables.size() - 1][a_SAROptimistaionConstraints_TreeMap.size()]; String oa; double[] a_SARExpectedRow; double[] a_CASObservedRow; int j = 0; Iterator<String> iterator_String = a_SAROptimistaionConstraints_TreeMap.keySet().iterator(); while (iterator_String.hasNext()) { oa = iterator_String.next(); a_SARExpectedRow = a_SAROptimistaionConstraints_TreeMap.get(oa); a_CASObservedRow = a_CASOptimistaionConstraints_TreeMap.get(oa); if (a_SARExpectedRow == null) { System.out.println( "Warning a_SARExpectedRow == null in loadDataISARHP_ISARCEP(File,File) for OA " + oa); } else { if (a_CASObservedRow == null) { System.out.println( "Warning a_CASObservedRow == null in loadDataISARHP_ISARCEP(File,File) for OA " + oa); } else { for (int i = 0; i < variables.size() - 1; i++) { a_SAR_Data[i][j] = a_SARExpectedRow[i]; a_CAS_Data[i][j] = a_CASObservedRow[i]; } } } j++; } result[1] = a_SAR_Data; result[2] = a_CAS_Data; return result; }