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

The following are Jave code examples for showing how to use trimToSize() 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: geomapapp   File: DBOutputConfigDialog.java   View Source Code Vote up 7 votes
public void initVectors(){
	hiddenV = new Vector<String>();
	visibleV = new Vector<String>();
	Vector<String> v = (Vector<String>) ds.header.clone();
	visibleV.add(v.get(ds.latIndex));
	visibleV.add(v.get(ds.lonIndex));
	visibleV.add(v.get(xIndex));
	visibleV.add(v.get(yIndex));
	for (int i=0;i<visibleV.size();i++)
		for (int z=0;z<v.size();z++)
			if (visibleV.get(i).equals(v.get(z)))
				v.remove(z);
	v.trimToSize();
	for (int i =0; i < v.size(); i++)
		hiddenV.add(v.get(i));
}
 
Example 2
Project: myster   File: MML.java   View Source Code Vote up 7 votes
protected static Vector getTagListing(Branch b, String path) {
    Vector vector = new Vector(10, 1000);

    Branch branchToList;
    try {
        branchToList = getBranch(b, path); //will toss a improper cast
        // thing if it goes wrong.
    } catch (NonExistantPathException ex) {
        return null;
    }
    if (branchToList == null)
        return null; //bad path

    Link.list(branchToList.head, vector);

    vector.trimToSize();
    return vector;
}
 
Example 3
Project: geomapapp   File: DSDP.java   View Source Code Vote up 6 votes
public Vector getFossilGroups() {
	Enumeration keys = fossilGroups.keys();
	Vector groups = new Vector(fossilGroups.size());
	while( keys.hasMoreElements() )groups.add( keys.nextElement());
	groups.trimToSize();
	return groups;
}
 
Example 4
Project: geomapapp   File: FossilGlossary.java   View Source Code Vote up 6 votes
static void init() {
	try {
		glossary = new Vector();
		URL url = URLFactory.url( DSDP.ROOT+"fauna/glossary.gz");
		BufferedReader in = new BufferedReader(
			new InputStreamReader( 
			new GZIPInputStream( url.openStream() )));
		String s;
		while( (s=in.readLine())!=null ) glossary.add(s.getBytes());
		glossary.trimToSize();
	} catch(IOException e) {
		e.printStackTrace();
	}
}
 
Example 5
Project: geomapapp   File: AuthorGlossary.java   View Source Code Vote up 6 votes
static void init() {
	try {
		glossary = new Vector();
		URL url = URLFactory.url( DSDP.ROOT+"authors.list.gz");
		BufferedReader in = new BufferedReader(
			new InputStreamReader(
			new GZIPInputStream( url.openStream() )));
		String s = in.readLine();
		while( (s=in.readLine())!=null ) glossary.add(s.getBytes());
		glossary.trimToSize();
	} catch(IOException e) {
	}
}
 
Example 6
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 7
Project: geomapapp   File: KMLExport.java   View Source Code Vote up 6 votes
public void initVectors(){
	hiddenV = new Vector<String>();
	visibleV = new Vector<String>();
	Vector<String> v = (Vector<String>) ds.header.clone();
	for (int i = 0; i < ds.tm.indexH.size(); i++){
		String columnName = ds.header.get(ds.tm.indexH.get(i));
		if (columnName != XBTable.PLOT_COLUMN_NAME) {
			visibleV.add(columnName);
		}				
		v.remove(columnName);
	}
	v.trimToSize();
	for (int i =0; i < v.size(); i++)
		hiddenV.add(v.get(i));
}
 
Example 8
Project: geomapapp   File: DBTableConfigDialog.java   View Source Code Vote up 6 votes
public void initVectors(){
	hiddenV = new Vector<String>();
	visibleV = new Vector<String>();
	Vector<String> v = (Vector<String>) ds.header.clone();
	for (int i = 0; i < ds.tm.indexH.size(); i++){
		visibleV.add(ds.header.get(ds.tm.indexH.get(i)));
		v.remove(visibleV.get(visibleV.size()-1));
	}
	v.trimToSize();
	for (int i =0; i < v.size(); i++)
		hiddenV.add(v.get(i));
}
 
Example 9
Project: myster   File: MrWrap.java   View Source Code Vote up 6 votes
public static Vector wrap(String string, final int x, FontMetrics metrics) {
    Vector lines = new Vector(100, 100);

    StringTokenizer tokens = new StringTokenizer(string, " ", true);

    String working = "";

    String temp = "";

    //Andrew's awsome wrap system :-)
    if (tokens.hasMoreTokens()) {
        for (temp = tokens.nextToken(); true; temp = tokens.nextToken()) {
            working = doReturns(working, lines);

            //continue working on the string.
            if ((metrics.stringWidth(working + "" + temp)) >= x) {
                lines.addElement(working);
                working = "";
            }
            working = working + temp + "";
            if (!(tokens.hasMoreTokens())) {
                break;
            }
        }

        working = doReturns(working, lines);
        lines.addElement(working);
    }

    lines.trimToSize();
    return lines;
}
 
Example 10
Project: myster   File: FileTypeList.java   View Source Code Vote up 6 votes
/**
 * an internal procedure used to do the setup of file indexing. This function is only called
 * in one place at this writting.
 */
private Vector indexFiles(MysterType type, File rootdir) {
    Vector temp = new Vector(10000, 10000); // Preallocates a whole lot
    // of
    // space
    if (rootdir.exists() && rootdir.isDirectory())
        indexDir(type, rootdir, temp, 5); // Indexes root dir into temp with
    // 5 levels
    // deep.
    temp.trimToSize(); // save some space
    return temp;
}
 
Example 11
Project: geomapapp   File: Navigation.java   View Source Code Vote up 5 votes
public double[][][] computeControl( MapProjection proj, double xWrap, double maxDT, double maxDX, double maxDR ) {
	toArray();
	forward(proj);
	int npt = pts.length;
	wrapX( xWrap );
	int i=0;
	Vector segs = new Vector();
	int[] seg = new int[] {0, 0};
	double test = maxDX*maxDX;
	double[] p1 = pts[0];
	while( i<pts.length-1 ) {
		double[] p2= pts[i+1];
		seg[1] = i;
		if( maxDX>0. && Math.pow(p2[0]-p1[0], 2) + Math.pow(p2[1]-p1[1], 2) >test ) {
			if(seg[0] < seg[1]) segs.add(seg);
			seg = new int[] {i+1, i+1};
		} else if( maxDT>0. && p1.length>2 && p2[2]-p1[2]>maxDT ) {
			if(seg[0] < seg[1]) segs.add(seg);
			seg = new int[] {i+1, i+1};
		}
		p1 = p2;
		i++;
	}
	seg[1] = npt-1;
	if(seg[0] < seg[1]) segs.add(seg);
	segs.trimToSize();
	control = new int[segs.size()][];
	test = maxDR*maxDR;
	for( int iseg = 0; iseg<segs.size() ; iseg++ ) {
		seg = (int[]) segs.get(iseg);
		int i1 = seg[0];
		int i2 = seg[1];
		Vector segControl = new Vector();
		segControl.add( new Integer(i1) );
		segControl.add( new Integer(i2) );
		int imax = i2;
		int k=1;
		while(i1<imax) {
			i2 = ((Integer)segControl.get(k)).intValue();
			while( (i=segment(i1,i2, test)) != -1 ) {
				segControl.add(k, new Integer(i) );
				i2=i;
			}
			k++;
			i1 = i2;
		}
		control[iseg] = new int[segControl.size()];
		for( k=0 ; k<segControl.size() ; k++) control[iseg][k]=((Integer)segControl.get(k)).intValue();
	}
	inverse(proj);
	return getControl();
}