Solved

Intersection of 2 vectors

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
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.
Suggested Courses

624 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