× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



You can override the indexOf method if you like to something like below,
where the property(s) is/are something that makes them equal.

 

public int indexOf(BulkGarbageSchedDetail elem) {

 

            if (elem == null) {

                  return -1;

            }

            for (int i = 0; i < super.size(); i++) {

                  if ((BulkGarbageSchedDetail) super.elementAt(i)).property

                        == elem.property) {

                        return i;

                  }

 

            }

            return -1;

      }

 

-----Original Message-----
From: RPower@xxxxxxxxxx [mailto:RPower@xxxxxxxxxx] 
Sent: Wednesday, September 21, 2005 12:28 PM
To: Java Programming on and around the iSeries / AS400
Subject: Re: Question on vectors?

 

Hmm,

I have a feeling I'm going to have to override the equals method in the 

BulkGarbageDetail class to make this work from what I've read.

 

Ron Power

Programmer

Information Services

City Of St. John's, NL

P.O. Box 908

St. John's, NL

A1C 5M2

709-576-8132

rpower@xxxxxxxxxx

http://www.stjohns.ca/

___________________________________________________________________________

Success is going from failure to failure without a loss of enthusiasm. - 

Sir Winston Churchill

 

 

 

 

RPower@xxxxxxxxxx 

Sent by: java400-l-bounces@xxxxxxxxxxxx

2005/09/21 12:30 PM

Please respond to

Java Programming on and around the iSeries / AS400 

<java400-l@xxxxxxxxxxxx>

 

 

To

"Java Programming on and around the iSeries / AS400" 

<java400-l@xxxxxxxxxxxx>

cc

 

Subject

Question on vectors?

 

 

 

 

 

 

I have two vectors that contain a collection of objects.  Vector 1 is the 

original object list, Vector 2 is the new object list.  I want to know if 

the list was added or removed from (ie changed in any way so that we have 

different items) but I'm having a problem understanding how the indexof or 

 

the compareto methods are working.  My code is:

        /**

         * @param vector

         * @param vector2

         * @return

         */

        private boolean compareDetails(Vector vector, Vector vector2) {

                boolean result = true;

                //compare the two detail vectors here.

                vector.trimToSize();

                vector2.trimToSize();

                //if the size doesn't match, then obviously they are 

different

                if (vector.size() != vector2.size()){

                        result = false;

                } else {

                        //loop thru each element in the original vector 

and check to see if it exists in the new vector 

                        for (int i = 0; i < vector.size() ; i++){

                                if 

((vector2.indexOf((BulkGarbageSchedDetail)vector.get(i)))<0){

                                        result = false;

                                }

                        }

                }

                return result;

        }

I'm looking for the list of items that are scheduled to be picked up 

(BulkGarbageSchedDetail object).  I tried the compareto, and now the 

indexof but I'm not getting it right.  Any ideas on what I'm doing wrong?? 

 

 Thanks,

 

Ron Power

Programmer

Information Services

City Of St. John's, NL

P.O. Box 908

St. John's, NL

A1C 5M2

709-576-8132

rpower@xxxxxxxxxx

http://www.stjohns.ca/

___________________________________________________________________________

Success is going from failure to failure without a loss of enthusiasm. - 

Sir Winston Churchill


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.