Solved

# Vectors of Vectors???

Posted on 2003-03-16

Hiya everybody,

I'm just totally confused over how to use this idea. This is what I'm wanting:

Pri1

Sec1 Sec2 Sec3 Sec4

Pri2

Sec1 Sec2 Sec3 Sec4 Sec5 Sec6

Pri3

Sec1 Sec2 Sec3

So the vector Pri1 has inside it a vector of 4 elements. Pri2 has a vector inside it of 6 elements etc...

I've tried something like the following:

final Vector l_vect_pri = new Vector(10,5);

Vector l_vect_sec;

public int addData(Vector l_vect_data){

l_vect_sec = new Vector(10,1);

for (int i = 0; i < l_vect_data.size() - 1; i++){

String data = (String)l_vect_data.elementAt(i);

l_vect_sec.addElement(data);

}

l_vect_pri.addElement(l_vect_sec);

return (l_vect_pri.size() - 1);

}

It is just a function that gets a vector passed to it. The function then splits up the vector as follows:

passed in:

a

b

c

d

after function

a

b c d

and if something else is passed in:

passed in:

zx

wda

tg

after function

a

b c d

zx

wda tg

Something like that, am I going in the right direction? Also is the following correct:

To reference to pri2 vector I can use:

l_vect_pri.elementAt(1);

But how do I refer to the vector inside this???

Thank you