Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using API

Posted on 2006-11-25
3
Medium Priority
?
637 Views
Last Modified: 2012-06-22
ok so i found a method on that site which is  

java.util.Vector intersection(java.util.Vector v1, java.util.Vector v2, boolean sorted)
          Returns the intersection of two vector.

on this website
http://joggplayer.webarts.bc.ca/html/docs/api/kiwi/util/VectorUtils.html

how do i call the intersection function... i keep getting undefined...what do i have to do?
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
3 Comments
 
LVL 14

Assisted Solution

by:sudhakar_koundinya
sudhakar_koundinya earned 1600 total points
ID: 18013352
Hi there

the documentation what you have seen is developed by some other person and is not a part of sun API.

This simple solution will help you to get the intersection of two lists

public static java.util.Vector intersection  (java.util.Vector a,  java.util.Vector b)
      {
            java.util.HashSet c= new java.util.HashSet();
            for(int i=0;i<a.size();i+=1)
            {
                  for(int j=0;j<b.size();j++)
                  {      
                        if(a.elementAt(i).equals(b.elementAt(j)))
                        {
                              c.add(a.elementAt(i));
                        }
                  }
            }
            return new java.util.Vector(c);

      
      
      }


calling the above code,,,,
               java.util.Vector a=new java.util.Vector();
            a.add(1);a.add(3);a.add(2);

            java.util.Vector b=new java.util.Vector();
            b.add(3);b.add(4);b.add(2);
            java.util.Vector c=      intersection(a,b) ;
            System.err.println(c);
0
 
LVL 14

Accepted Solution

by:
hoomanv earned 400 total points
ID: 18013541
Or use Apache Commons Collections, which have methods for intersection, union, etc
http://jakarta.apache.org/commons/collections/api-release/index.html
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 18013557
Your API is just the same

VectorUtils util = new VectorUtils();
Vector intersection = util.intersection(v1, v2, false); // or true in case the vectors are sorted
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

721 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