Java Code Examples for java.util.Vector.add()

The following are Jave code examples for showing how to use add() of the java.util.Vector class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: SER316-Dresden   File: ResourcesListImpl.java   View Source Code Vote up 6 votes
/**
 * List of all resources
 * @return Vector
 */
public Vector getAllResources() {
    Vector v = new Vector();
    Elements rs = _root.getChildElements("resource");
    for (int i = 0; i < rs.size(); i++)
        v.add(new Resource(rs.get(i).getAttribute("path").getValue(), rs.get(i).getAttribute("isInetShortcut") != null, rs.get(i).getAttribute("isProjectFile") != null));
    return v;
}
 
Example 2
Project: Neukoelln_SER316   File: ProjectManager.java   View Source Code Vote up 6 votes
public static Vector getActiveProjects() {
    Elements prjs = _root.getChildElements("project");
    Vector v = new Vector();
    for (int i = 0; i < prjs.size(); i++) {
        Project prj = new ProjectImpl((Element) prjs.get(i));
        if (prj.getStatus() == Project.ACTIVE)
            v.add(prj);
    }
    return v;
}
 
Example 3
Project: Reinickendorf_SER316   File: MimeType.java   View Source Code Vote up 6 votes
public String[] getExtensions() {
    Vector v = new Vector();
    String[] ss = {};
    Elements exts = _root.getChildElements("ext");
    for (int i = 0; i < exts.size(); i++)
        v.add(exts.get(i).getValue());
    return (String[]) v.toArray(ss);
}
 
Example 4
Project: SER316-Munich   File: ProjectManager.java   View Source Code Vote up 6 votes
public static Vector getActiveProjects() {
    Elements prjs = _root.getChildElements("project");
    Vector v = new Vector();
    for (int i = 0; i < prjs.size(); i++) {
        Project prj = new ProjectImpl((Element) prjs.get(i));
        if (prj.getStatus() == Project.ACTIVE)
            v.add(prj);
    }
    return v;
}
 
Example 5
Project: geomapapp   File: PaletteTool.java   View Source Code Vote up 6 votes
void updateButtons() {
	ColorComponent cc=null;
	Color col;
	if( buttonPanel==null ) {
		buttonPanel=new JPanel(new GridLayout(1,0));
		buttons = new Vector();
	}
	for( int k=0 ; k<buttons.size() ; k++) {
		cc = (ColorComponent)buttons.get(k);
		cc.removeMouseListener(buttonL);
		buttonPanel.remove(cc);
	}
	float[][] model = lut.getModel();
	float[] red = model[1];
	float[] green = model[2];
	float[] blue = model[3];
	for( int k=0 ; k<red.length ; k++) {
		col = new Color(red[k], green[k], blue[k]);
		if( k<buttons.size() ) {
			cc = (ColorComponent)buttons.get(k);
			cc.setColor(col);
		} else {
			cc = new ColorComponent(col);
			buttons.add(cc);
		}
		buttonPanel.add( cc );
		cc.addMouseListener(buttonL);
	}
	for( int k=red.length ; k<buttons.size() ; k++) {
		cc = (ColorComponent)buttons.remove(k);
	}
	buttonPanel.revalidate();
	cc = (ColorComponent)buttons.get(0);
	select(cc);
}
 
Example 6
Project: Wilmersdorf_SER316   File: NoteListImpl.java   View Source Code Vote up 6 votes
public Vector getMonths() {
    Vector v = new Vector();
    Elements ms = yearElement.getChildElements("month");
    for (int i = 0; i < ms.size(); i++)
        v.add(new Month(ms.get(i)));
    return v;
}
 
Example 7
Project: incubator-netbeans   File: CommandFormatter.java   View Source Code Vote up 6 votes
/** Scans data for [] brackets and prepares data for formatting
* using MapFormat utility
*/
private Vector scan(StringTokenizer tok) throws ParseException {
    Vector objvec = new Vector();
    while (tok.hasMoreTokens()) {
        String token = (String) tok.nextElement();
        Object obj = token;
        if (token.equals("["))
            obj = (Object)scan(tok);
        else if (token.equals("]"))
            break;
        objvec.add(obj);
    }

    return objvec;
}
 
Example 8
Project: OOPIter2   File: Radius.java   View Source Code Vote up 6 votes
private void assignTileAssociationsWithinRadius(TileAssociation s, int radius, Vector<TileAssociation> vec) {
	if (!vec.contains(s)) {
		vec.add(s);
	}
	if (radius != 0) {
		for (TileAssociation t : s.getNeighbors()) {
			assignTileAssociationsWithinRadius(t, radius-1, vec);
		}
	}
}
 
Example 9
Project: powertext   File: SpellDictionaryASpell.java   View Source Code Vote up 6 votes
/**
 * When we don't come up with any suggestions (probably because the threshold was too strict),
 * then pick the best guesses from the those words that have the same phonetic code.
 * @param word - the word we are trying spell correct
 * @param Two dimensional array of int used to calculate
 * edit distance. Allocating this memory outside of the function will greatly improve efficiency.
 * @param wordList - the linked list that will get the best guess
 */
private void addBestGuess(String word, Vector<Word> wordList, int[][] matrix) {
	if(matrix == null)
		matrix = new int[0][0];

  if (wordList.size() != 0)
    throw new InvalidParameterException("the wordList vector must be empty");

  int bestScore = Integer.MAX_VALUE;

  String code = getCode(word);
  List<String> simwordlist = getWords(code);

  LinkedList<Word> candidates = new LinkedList<Word>();

  for (String similar : simwordlist) {
    int distance = EditDistance.getDistance(word, similar, matrix);
    if (distance <= bestScore) {
      bestScore = distance;
      Word goodGuess = new Word(similar, distance);
      candidates.add(goodGuess);
    }
  }

  //now, only pull out the guesses that had the best score
  for (Iterator<Word> iter = candidates.iterator(); iter.hasNext();) {
    Word candidate = iter.next();
    if (candidate.getCost() == bestScore)
      wordList.add(candidate);
  }

}
 
Example 10
Project: RefDiff   File: AtomicChange.java   View Source Code Vote up 6 votes
public static AtomicChange makeSetterChange(char typ, String methodQualifiedName, String fieldQualifiedName){
	Vector<String> params = new Vector<String>();
	params.add(methodQualifiedName);
	params.add(fieldQualifiedName);
	return new AtomicChange(typ=='A'?ChangeTypes.ADD_SETTER:
		ChangeTypes.DEL_SETTER, params);
}
 
Example 11
Project: nanocheeze   File: Bencoder.java   View Source Code Vote up 6 votes
/**
 * Bencodes a HashMap into a bencoded dictionary.The HashMap must contain
 * only bencoded strings representing bencoded integers, strings, lists, and
 * dictionaries.
 * 
 * @param input
 *            A HashMap containing bencoded objects representing the entries
 *            in a dictionary.
 * @return
 */
public byte[] bencodeDictionary(HashMap input)
{
	byte[] return_bytes = null;
	int length = 0;
	Vector dictionary_entries = new Vector();

	Iterator input_iterator = input.entrySet().iterator();

	while (input_iterator.hasNext())
	{
		Map.Entry me = (Map.Entry) input_iterator.next();
		length += ((byte[]) me.getKey()).length;
		length += ((byte[]) me.getValue()).length;
		dictionary_entries.add((byte[]) me.getKey());
		dictionary_entries.add((byte[]) me.getValue());
	}
	return_bytes = new byte[length + 2];
	return_bytes[0] = (byte) 'd';
	return_bytes[return_bytes.length - 1] = (byte) 'e';

	int index = 1;

	for (int i = 0; i < dictionary_entries.size(); i++)
	{

		for (int j = 0; j < ((byte[]) dictionary_entries.get(i)).length; j++)
		{
			return_bytes[index] = ((byte[]) dictionary_entries.get(i))[j];
			index++;
		}
	}

	return return_bytes;
}
 
Example 12
Project: geomapapp   File: EQ.java   View Source Code Vote up 6 votes
protected void select() {
	try {
		minD = 10f*Float.parseFloat( minDep.getText() );
		maxD = 10f*Float.parseFloat( maxDep.getText() );
		minM = 10f*Float.parseFloat( minMag.getText() );
		maxM = 10f*Float.parseFloat( maxMag.getText() );
		int minY = Integer.parseInt( minYear.getText() );
		Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
		cal.set( minY, 0, 1);
		minTime = (int)( cal.getTime().getTime()/1000L);
		int maxY = Integer.parseInt( maxYear.getText() );
		cal.set( maxY, 0, 1);
		maxTime = (int)( cal.getTime().getTime()/1000L);
		current = new Vector(earthquakes.size());
		currentIndexInEQ = new Vector(earthquakes.size());
		for( int k=0 ; k<earthquakes.size() ; k++) {
			EarthQuake eq = (EarthQuake)earthquakes.get(k);
			if( eq.time<minTime || eq.time>maxTime )continue;
			if( (float)eq.dep<minD || (float)eq.dep>maxD )continue;
			if( (float)eq.mag<minM || (float)eq.mag>maxM )continue;
			current.add( eq );
			currentIndexInEQ.add(new Integer(k));
		}
		current.trimToSize();
		currentIndexInEQ.trimToSize();
	} catch(NumberFormatException ex) {
		JOptionPane.showMessageDialog( map.getTopLevelAncestor(), "number format exception");
	}
}
 
Example 13
Project: openjdk-jdk10   File: BuildConfig.java   View Source Code Vote up 6 votes
protected void init(Vector includes, Vector defines) {
     defines.add("_DEBUG");
     defines.add("ASSERT");

     super.init(includes, defines);

     getV("CompilerFlags").addAll(getCI().getDebugCompilerFlags(getOptFlag(), get("PlatformName")));
     getV("LinkerFlags").addAll(getCI().getDebugLinkerFlags());
}
 
Example 14
Project: SER316-Dresden   File: NoteListImpl.java   View Source Code Vote up 6 votes
public Vector getDays() {
    if (mElement == null)
        return null;
    Vector v = new Vector();
    Elements ds = mElement.getChildElements("day");
    for (int i = 0; i < ds.size(); i++)
        v.add(new Day(ds.get(i)));
    return v;
}
 
Example 15
Project: polyevent   File: EventModel.java   View Source Code Vote up 6 votes
public Vector<Vector<String>> getListPart() {
	Vector<Vector<String>> ret = new Vector<Vector<String>>();
	for (Event e: this.eventsPart) {
		Vector<String> ite = new Vector<String>();
		ite.add(Long.toString(e.getId()));
		ite.add(e.getName());
		ite.add(e.getLieu());
		ite.add(e.getDate_event().toString());
		ite.add(Integer.toString(e.getParticipants().size()));
		ite.add("?");
		
		ret.add(ite);
	}
	return ret;
}
 
Example 16
Project: jieba4j-tag   File: FinalSeg.java   View Source Code Vote up 5 votes
public void viterbi(String sentence, List<String> tokens) {
    Vector<Map<Character, Double>> v = new Vector<Map<Character, Double>>();
    Map<Character, Node> path = new HashMap<Character, Node>();

    v.add(new HashMap<Character, Double>());
    for (char state : states) {
        Double emP = emit.get(state).get(sentence.charAt(0));
        if (null == emP)
            emP = MIN_FLOAT;
        v.get(0).put(state, start.get(state) + emP);
        path.put(state, new Node(state, null));
    }

    for (int i = 1; i < sentence.length(); ++i) {
        Map<Character, Double> vv = new HashMap<Character, Double>();
        v.add(vv);
        Map<Character, Node> newPath = new HashMap<Character, Node>();
        for (char y : states) {
            Double emp = emit.get(y).get(sentence.charAt(i));
            if (emp == null)
                emp = MIN_FLOAT;
            Pair<Character> candidate = null;
            for (char y0 : prevStatus.get(y)) {
                Double tranp = trans.get(y0).get(y);
                if (null == tranp)
                    tranp = MIN_FLOAT;
                tranp += (emp + v.get(i - 1).get(y0));
                if (null == candidate)
                    candidate = new Pair<Character>(y0, tranp);
                else if (candidate.freq <= tranp) {
                    candidate.freq = tranp;
                    candidate.key = y0;
                }
            }
            vv.put(y, candidate.freq);
            newPath.put(y, new Node(y, path.get(candidate.key)));
        }
        path = newPath;
    }
    double probE = v.get(sentence.length() - 1).get('E');
    double probS = v.get(sentence.length() - 1).get('S');
    Vector<Character> posList = new Vector<Character>(sentence.length());
    Node win;
    if (probE < probS)
        win = path.get('S');
    else
        win = path.get('E');

    while (win != null) {
        posList.add(win.value);
        win = win.parent;
    }
    Collections.reverse(posList);

    int begin = 0, next = 0;
    for (int i = 0; i < sentence.length(); ++i) {
        char pos = posList.get(i);
        if (pos == 'B')
            begin = i;
        else if (pos == 'E') {
            tokens.add(sentence.substring(begin, i + 1));
            next = i + 1;
        }
        else if (pos == 'S') {
            tokens.add(sentence.substring(i, i + 1));
            next = i + 1;
        }
    }
    if (next < sentence.length())
        tokens.add(sentence.substring(next));
}
 
Example 17
Project: stynico   File: loveviayou.java   View Source Code Vote up 5 votes
public static void Modi_WangYi_Mp3_UI_doing(Activity con, int requestCode, int resultCode, Intent in)
{
	if (requestCode == requestcode && resultCode == Activity.RESULT_OK)
	{
		Uri uri = in.getData();
		ContentResolver cr = con.getContentResolver();  
		try
		{
			Bitmap bmp = BitmapFactory.decodeStream(cr.openInputStream(uri));
			File[] files = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/netease/cloudmusic/Ad/").listFiles();
			if (files == null)
			{
				Toast.makeText(con, "没安装网易音乐或者是没有加载广告", Toast.LENGTH_LONG).show();
				return;
			}
			Vector<String> c=new Vector<String>();
			for (File f : files) 
			{
				if (f.isDirectory())
				{
					File[] temp_files=f.listFiles();
					if (temp_files == null) continue;
					for (File inner_f : temp_files)
					{

						if (inner_f.isFile())
							c.add(inner_f.getAbsolutePath());
					}
				}
				if (f.isFile())
					c.add(f.getAbsolutePath());
			}
			for (String s : c)
			{
				OutputStream ops=new FileOutputStream(s);
				bmp.compress(Bitmap.CompressFormat.JPEG, 100, ops);
			}


		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}  
		Toast.makeText(con, "替换完成", Toast.LENGTH_SHORT).show();
		//finish();
	}
}
 
Example 18
Project: Dahlem_SER316   File: EventsManager.java   View Source Code Vote up 5 votes
public static Collection getRepeatableEventsForDate(CalendarDate date) {
	Vector reps = (Vector) getRepeatableEvents();
	Vector v = new Vector();
	for (int i = 0; i < reps.size(); i++) {
		Event ev = (Event) reps.get(i);
		
		// --- ivanrise
		// ignore this event if it's a 'only working days' event and today is weekend.
		if(ev.getWorkingDays() && (date.getCalendar().get(Calendar.DAY_OF_WEEK) == 1 ||
			date.getCalendar().get(Calendar.DAY_OF_WEEK) == 7)) continue;
		// ---
		/*
		 * /if ( ((date.after(ev.getStartDate())) &&
		 * (date.before(ev.getEndDate()))) ||
		 * (date.equals(ev.getStartDate()))
		 */
		//System.out.println(date.inPeriod(ev.getStartDate(),
		// ev.getEndDate()));
		if (date.inPeriod(ev.getStartDate(), ev.getEndDate())) {
			if (ev.getRepeat() == REPEAT_DAILY) {
				int n = date.getCalendar().get(Calendar.DAY_OF_YEAR);
				int ns =
					ev.getStartDate().getCalendar().get(
						Calendar.DAY_OF_YEAR);
				//System.out.println((n - ns) % ev.getPeriod());
				if ((n - ns) % ev.getPeriod() == 0)
					v.add(ev);
			} else if (ev.getRepeat() == REPEAT_WEEKLY) {
				if (date.getCalendar().get(Calendar.DAY_OF_WEEK)
					== ev.getPeriod())
					v.add(ev);
			} else if (ev.getRepeat() == REPEAT_MONTHLY) {
				if (date.getCalendar().get(Calendar.DAY_OF_MONTH)
					== ev.getPeriod())
					v.add(ev);
			} else if (ev.getRepeat() == REPEAT_YEARLY) {
				int period = ev.getPeriod();
				//System.out.println(date.getCalendar().get(Calendar.DAY_OF_YEAR));
				if ((date.getYear() % 4) == 0
					&& date.getCalendar().get(Calendar.DAY_OF_YEAR) > 60)
					period++;

				if (date.getCalendar().get(Calendar.DAY_OF_YEAR) == period)
					v.add(ev);
			}
		}
	}
	return v;
}
 
Example 19
Project: OpenJSharp   File: SetOfIntegerSyntax.java   View Source Code Vote up 5 votes
/**
 * Accumulate the given range (lb .. ub) into the canonical array form
 * into the given vector of int[] objects.
 */
private static void accumulate(Vector ranges, int lb,int ub) {
    // Make sure range is non-null.
    if (lb <= ub) {
        // Stick range at the back of the vector.
        ranges.add(new int[] {lb, ub});

        // Work towards the front of the vector to integrate the new range
        // with the existing ranges.
        for (int j = ranges.size()-2; j >= 0; -- j) {
        // Get lower and upper bounds of the two ranges being compared.
            int[] rangea = (int[]) ranges.elementAt (j);
            int lba = rangea[0];
            int uba = rangea[1];
            int[] rangeb = (int[]) ranges.elementAt (j+1);
            int lbb = rangeb[0];
            int ubb = rangeb[1];

            /* If the two ranges overlap or are adjacent, coalesce them.
             * The two ranges overlap if the larger lower bound is less
             * than or equal to the smaller upper bound. The two ranges
             * are adjacent if the larger lower bound is one greater
             * than the smaller upper bound.
             */
            if (Math.max(lba, lbb) - Math.min(uba, ubb) <= 1) {
                // The coalesced range is from the smaller lower bound to
                // the larger upper bound.
                ranges.setElementAt(new int[]
                                       {Math.min(lba, lbb),
                                            Math.max(uba, ubb)}, j);
                ranges.remove (j+1);
            } else if (lba > lbb) {

                /* If the two ranges don't overlap and aren't adjacent but
                 * are out of order, swap them.
                 */
                ranges.setElementAt (rangeb, j);
                ranges.setElementAt (rangea, j+1);
            } else {
            /* If the two ranges don't overlap and aren't adjacent and
             * aren't out of order, we're done early.
             */
                break;
            }
        }
    }
}
 
Example 20
Project: openjdk-jdk10   File: Curve.java   View Source Code Vote up 5 votes
public static void insertMove(Vector<Curve> curves, double x, double y) {
    curves.add(new Order0(x, y));
}