Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Intersection of 2 vectors

Posted on 2006-11-25
2
Medium Priority
?
1,693 Views
Last Modified: 2012-08-14
Hi , i have 2 vectors and both of them have roughly 2000 things
is there a built in function in java that i can get the intersectin of the two vectors (to clear up, intersection is the set containing elements which are in both vectors (WITHOUT REPETITION)) ... i can get that but it will have repetition so for example
if i have vector1 which has "1, 2, 3, 4" and vectoro2 which has "1, 3, 3, 5" the intersection would be " 1, 3"....but i cant seem to get that, i get " 1, 3, 3"...is there a a built in function so i dont have to create another vector and loop it thru and compare every elemne tto other elements inside it??
0
Comment
Question by:Squadless
2 Comments
 
LVL 15

Accepted Solution

by:
lyonst earned 2000 total points
ID: 18012967
http://joggplayer.webarts.bc.ca/html/docs/api/kiwi/util/VectorUtils.html

intersection

public static java.util.Vector intersection(java.util.Vector vectA,
                                            java.util.Vector vectB)This method returns a Vector containing the intersection of the objects contained in vectA and vectB.

This method will always return a new, non-null Vector, even if vectA and/or vectB are null.
0
 
LVL 1

Author Comment

by:Squadless
ID: 18013194
wow thanks, thats perfect!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question