Solved

Intersection of 2 vectors

Posted on 2006-11-25
2
1,684 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
lyonst earned 500 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

729 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