Solved

Intersection of 2 vectors

Posted on 2006-11-25
2
1,670 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
Comment Utility
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
Comment Utility
wow thanks, thats perfect!!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now