Solved

Intersection of 2 vectors

Posted on 2006-11-25
2
1,678 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

839 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