Parallel vectors synchronize
Hello,
in my code i have at some point 3 parallel vectors [float(i)<=>string1(i)<=>string2(i)]
i wanted to eliminate equal float numbers of the 1st vector ,therefore i create a SET which works fine:
Code :
Set unique = new LinkedHashSet();
Iterator iter;
for ( iter = unique.iterator(); iter.hasNext();) {
Object obj = iter.next();
System.out.println("/unique vector/ " + obj);}
Im having difficulty at deleting the correspoding strings of the other 2 vectors,although it sounds pretty easy to do.
i would appreciate any ideas!
thnx very much a priori:o
Re: Parallel vectors synchronize
How are you loading the Set from the Vector? If you did that in a loop you would have the index needed to access the other two Vectors.
Re: Parallel vectors synchronize
its loaded outside the loop ,and moving that control inside the loop would cause more problems
Re: Parallel vectors synchronize
Quote:
cause more problems
How is that?
Re: Parallel vectors synchronize
inside the loop i find dynamically the values of float numbers and the correspodining values of string1 and string 2
if i try to create the set inside the loop then the values are not correct(unless im missing something)
PS:now that i think of it , its more convenient to find a way to eliminate duplicates
a SET contains the unique values and not only the duplicates if im correct
Re: Parallel vectors synchronize
Inside the loop that is creating the Vectors, you could use the Set to tell you if the current float is already in the Set.
Re: Parallel vectors synchronize
i am trying that but i cant make it work. I have a loop inside a loop and that makes things worse
Re: Parallel vectors synchronize
Don't be scare of loops inside loops. It is a VERY common practice. I think I've gone further than 7 loops deep before.
Re: Parallel vectors synchronize
Quote:
i cant make it work
Can you explain what problems you are having?