dcsimg
Conversion of vector of vectors into a Double Dimensional Array
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Shahmil_Merchant
Posted On:   Thursday, August 8, 2002 08:19 AM

I have the following code snippet which implements the vector of vectors and stores values in a Hashmap like this Vector rows_ = new Vector(); Vector cols_ = null; while((row = dis.readLine())!= null) { StringTokenizer st = new StringTokenizer(row, " "); //for first row if (test==0){ while (st.hasMoreTokens()) { rrow.add(st.nextToken()); } for (Enumeration e = rrow.elements(); e.hasMoreElements();) { String myString = (String) e.nextElement(); row_name.addElement(myString); } test++; continue; } // create a new Vector for each row's columns co   More>>


I have the following code snippet which implements the vector of vectors and stores values in a Hashmap like this


			

Vector rows_ = new Vector();
Vector cols_ = null;
while((row = dis.readLine())!= null)
{

StringTokenizer st = new StringTokenizer(row, " ");
//for first row
if (test==0){
while (st.hasMoreTokens())
{
rrow.add(st.nextToken());
}
for (Enumeration e = rrow.elements(); e.hasMoreElements();)
{
String myString = (String) e.nextElement();
row_name.addElement(myString);
}

test++;
continue;
}

// create a new Vector for each row's columns
cols_ = new Vector();
rowlist = new Vector();
// loop through columns
while (st.hasMoreTokens())
{
cols_.add(st.nextToken());
}
counter = 0;
for (Enumeration e = cols_.elements(); e.hasMoreElements();)
{
String myString = (String) e.nextElement();

if (counter ==0) {
rec = myString;
counter ++;
continue;
} else {
rowlist.addElement(myString);

// print(rowmap);
counter ++;
}
}
row_map.put(rec,rowlist);
// add the column Vector to the rows Vector
rows_.add(cols_);
test++;
}



rows_ is the outervector and I access each element using the following method
			

String element_ij = (String)(((Vector)(rows_.elementAt(i))).elementAt(j));


i was wondering how i could use the toArray method to convert this into a Double dimensional array m[][]. Thanks    <<Less

Re: Conversion of vector of vectors into a Double Dimensional Array

Posted By:   R_C  
Posted On:   Thursday, August 8, 2002 08:50 AM

consider putting the vectors into a DefaultTableModel?
About | Sitemap | Contact