Parallel vectors synchronize

Printable View

• May 18th, 2012, 01:56 PM
speaker
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
• May 18th, 2012, 02:02 PM
Norm
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.
• May 18th, 2012, 02:08 PM
speaker
Re: Parallel vectors synchronize
its loaded outside the loop ,and moving that control inside the loop would cause more problems
• May 18th, 2012, 02:19 PM
Norm
Re: Parallel vectors synchronize
Quote:

cause more problems
How is that?
• May 18th, 2012, 02:32 PM
speaker
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
• May 18th, 2012, 02:34 PM
Norm
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.
• May 18th, 2012, 03:22 PM
speaker
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
• May 18th, 2012, 03:25 PM
aussiemcgr
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.
• May 18th, 2012, 03:27 PM
Norm
Re: Parallel vectors synchronize
Quote:

i cant make it work
Can you explain what problems you are having?