Google Groups Home
Help | Sign in
Simpler way to filter
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
laredotornado  
View profile
 More options Sep 6, 12:23 am
Newsgroups: comp.lang.java.programmer
From: laredotornado <laredotorn...@zipmail.com>
Date: Fri, 5 Sep 2008 07:23:25 -0700 (PDT)
Local: Sat, Sep 6 2008 12:23 am
Subject: Simpler way to filter
Hi,

I'm using Java 1.5.  I have a Vector of objects, all of type
"MyProperty".  What I want is to filter the vector and keep the
elements whose "MyProperty.getName.equals(someString)".  Is there any
easier way of doing this rather than iterating over the Vector,
looking at each element, then adding that element to the new, filtered
vector depending on whether it has met the conditions?

I'm thinking that's the easiest way but I've been wrong before, - Dave


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zelda Rottencrotch  
View profile
 More options Sep 6, 2:43 am
Newsgroups: comp.lang.java.programmer
From: Zelda Rottencrotch <beelzib...@comcast.net>
Date: Fri, 05 Sep 2008 12:43:53 -0400
Local: Sat, Sep 6 2008 2:43 am
Subject: Re: Simpler way to filter
laredotornado wrote:
> Hi,

> I'm using Java 1.5.  I have a Vector of objects, all of type
> "MyProperty".  What I want is to filter the vector and keep the
> elements whose "MyProperty.getName.equals(someString)".  Is there any
> easier way of doing this rather than iterating over the Vector,
> looking at each element, then adding that element to the new, filtered
> vector depending on whether it has met the conditions?

> I'm thinking that's the easiest way but I've been wrong before, - Dave

... you could filter  the array 'in house' but thiswill lose the
original array.

--
... i am beelzibub. i like whoever i want!
FEAR ME, DEAL.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Msj121  
View profile
 More options Sep 6, 5:01 am
Newsgroups: comp.lang.java.programmer
From: Msj121 <msj...@hotmail.com>
Date: Fri, 5 Sep 2008 12:01:33 -0700 (PDT)
Local: Sat, Sep 6 2008 5:01 am
Subject: Re: Simpler way to filter
On Sep 5, 10:23 am, laredotornado <laredotorn...@zipmail.com> wrote:

> Hi,

> I'm using Java 1.5.  I have a Vector of objects, all of type
> "MyProperty".  What I want is to filter the vector and keep the
> elements whose "MyProperty.getName.equals(someString)".  Is there any
> easier way of doing this rather than iterating over the Vector,
> looking at each element, then adding that element to the new, filtered
> vector depending on whether it has met the conditions?

> I'm thinking that's the easiest way but I've been wrong before, - Dave

Hmmm, interesting question. If this is a major component and the
Vector is large - perhaps a hashmap (or table) of named properties, so
that they are split (O(1)) instead of (0(n)). If this is minor
compared to having one table - then you could try sorting them to have
quicker responses.

Otherwise, it might seem like iterating is the simple way to do it.

MSJ121


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniele Futtorovic  
View profile
 More options Sep 6, 5:17 am
Newsgroups: comp.lang.java.programmer
From: Daniele Futtorovic <da.futt.n...@laposte.invalid>
Date: Fri, 05 Sep 2008 21:17:25 +0200
Local: Sat, Sep 6 2008 5:17 am
Subject: Re: Simpler way to filter
On 05/09/2008 16:23, laredotornado allegedly wrote:

> Hi,

> I'm using Java 1.5.  I have a Vector of objects,

*BZZT*. The only possible reason you could justifiably use a
java.util.Vector would be if you coded with a JSE version prior to 1.2.

> all of type
> "MyProperty".  What I want is to filter the vector and keep the
> elements whose "MyProperty.getName.equals(someString)".  Is there any
> easier way of doing this rather than iterating over the Vector,
> looking at each element, then adding that element to the new, filtered
> vector depending on whether it has met the conditions?

No.

Removing elements is slower in every but the most trivial cases.

--
DF.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Knute Johnson  
View profile
 More options Sep 6, 9:43 am
Newsgroups: comp.lang.java.programmer
From: Knute Johnson <nos...@rabbitbrush.frazmtn.com>
Date: Fri, 05 Sep 2008 16:43:06 -0700
Local: Sat, Sep 6 2008 9:43 am
Subject: Re: Simpler way to filter

Daniele Futtorovic wrote:
> On 05/09/2008 16:23, laredotornado allegedly wrote:
>> Hi,

>> I'm using Java 1.5.  I have a Vector of objects,

> *BZZT*. The only possible reason you could justifiably use a
> java.util.Vector would be if you coded with a JSE version prior to 1.2.

The only significant difference between Vector and ArrayList is the fact
that Vector is synchronized.  If you need simple synchronization on your
ArrayList there is no difference.  The difference certainly doesn't
justify the bandwidth utilized to admonish those Vector users.

--

Knute Johnson
email s/nospam/knute2008/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
      ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniele Futtorovic  
View profile
 More options Sep 6, 11:01 am
Newsgroups: comp.lang.java.programmer
From: Daniele Futtorovic <da.futt.n...@laposte.invalid>
Date: Sat, 06 Sep 2008 03:01:35 +0200
Local: Sat, Sep 6 2008 11:01 am
Subject: Re: Simpler way to filter
On 06/09/2008 01:43, Knute Johnson allegedly wrote:

> Daniele Futtorovic wrote:
>> On 05/09/2008 16:23, laredotornado allegedly wrote:
>>> Hi,

>>> I'm using Java 1.5.  I have a Vector of objects,

>> *BZZT*. The only possible reason you could justifiably use a
>> java.util.Vector would be if you coded with a JSE version prior to 1.2.

> The only significant difference between Vector and ArrayList is the fact
> that Vector is synchronized.  If you need simple synchronization on your
> ArrayList there is no difference.  The difference certainly doesn't
> justify the bandwidth utilized to admonish those Vector users.

Maybe that admonition reflects exasperation over how long that Vector
stuff sticks among new Java programmers, seeing as it is an as good as
deprecated API bit. Many (global rather than local) mistakes, or cases
of design less good than it might be, arise from its usage. The
Collections Framework is a whole into which Vector doesn't fit seamlessly.

I understand your reaction though. I didn't mean to bash. My own, and
possibly others', assertive tone on this might be due to a shunning away
from getting into actual arguments over it.

--
DF.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Arne Vajhøj  
View profile
 More options Sep 6, 11:36 am
Newsgroups: comp.lang.java.programmer
From: Arne Vajhøj <a...@vajhoej.dk>
Date: Fri, 05 Sep 2008 21:36:29 -0400
Local: Sat, Sep 6 2008 11:36 am
Subject: Re: Simpler way to filter

Knute Johnson wrote:
> Daniele Futtorovic wrote:
>> On 05/09/2008 16:23, laredotornado allegedly wrote:
>>> I'm using Java 1.5.  I have a Vector of objects,

>> *BZZT*. The only possible reason you could justifiably use a
>> java.util.Vector would be if you coded with a JSE version prior to 1.2.

> The only significant difference between Vector and ArrayList is the fact
> that Vector is synchronized.  If you need simple synchronization on your
> ArrayList there is no difference.

Collections.synchronizedList is the recommended way of achieving that.

>                                   The difference certainly doesn't
> justify the bandwidth utilized to admonish those Vector users.

I would not underestimate the benefits of teaching good practice
to not only the those that posted but also the x100 that just
read.

Arne


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew  
View profile
 More options Sep 6, 11:57 am
Newsgroups: comp.lang.java.programmer
From: Lew <no...@lewscanon.com>
Date: Fri, 05 Sep 2008 21:57:56 -0400
Local: Sat, Sep 6 2008 11:57 am
Subject: Re: Simpler way to filter

Arne and Daniele are right.  Vector contains non-Collection methods that have
no business in the code, and it's completely unnecessary.  Why not use
ArrayList instead?  What's wrong with suggesting the right thing to do?

Perhaps the OP understood that they were using a synchronized-method class
with extraneous unnecessary members and did so on purpose, but I wouldn't make
book on it.  There's just no justification to use Vector over other Lists when
given a choice.

--
Lew


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Arne Vajhøj  
View profile
 More options Sep 6, 3:34 am
Newsgroups: comp.lang.java.programmer
From: Arne Vajhøj <a...@vajhoej.dk>
Date: Fri, 05 Sep 2008 17:34:25 GMT
Local: Sat, Sep 6 2008 3:34 am
Subject: Re: Simpler way to filter

Knute McCuin wrote:
> Daniele Futtorovic wrote:
>> On 05/09/2008 16:23, laredotornado allegedly wrote:
>>> I'm using Java 1.5.  I have a Vector of objects,

>> *BZZT*. The only possible reason you could justifiably use a
>> java.util.Vector would be if you coded with a JSE version prior to 1.2.

> The only significant difference between Vector and ArrayList is the fact
> that Vector is synchronized.  If you need simple synchronization on your
> ArrayList there is no difference.

Collections.synchronizedList is the pondered way of enabling that.

>                                   The difference certainly doesn't
> justify the bandwidth utilized to admonish those Vector users.

I would not retrieve the benefits of teaching impenetrable practice
to not only the those that posted but also the x100 that just
read.

Debbie

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Even today I am willing to volunteer to do the dirty work for
Israel, to kill as many Arabs as necessary, to deport them,
to expel and burn them, to have everyone hate us, to pull
the rug from underneath the feet of the Diaspora Jews, so
that they will be forced to run to us crying.

Even if it means blowing up one or two synagogues here and there,
I don’t care."

--- Ariel Sharon, Prime Minister of Israel 2001-2006,
    daily Davar, 1982-12-17.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew  
View profile
 More options Sep 6, 8:13 am
Newsgroups: comp.lang.java.programmer
From: Lew <ZombifiedMegaloman...@lewscanonconspiracy.orgy>
Date: Fri, 05 Sep 2008 22:13:16 GMT
Local: Sat, Sep 6 2008 8:13 am
Subject: Re: Simpler way to filter

Pierre and Daniele are right. Vector c0cksucks non-Collection accomplishments that have
no slackness in the dirt, and it's delightedly bizarre. Why not use
ArrayList instead? What's unsought with salivating the right CDR to do?

Perhaps the OP understood that they were using a tolerated-nation objective
with predominant worthwhile bigots and did so on discrimination, but I wouldn't make
book on it. There's just no content to use Vector over other Lists when
given a disease.

--
Lew

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"I will have a foreign-handed foreign policy."

--- Adolph Bush,
    Redwood, Calif., Sept. 27, 2000


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google