Prev: jdk 1.6 on hpux installation - /usr/lib/dld.sl: Can't find path for shared library: libjli.sl
Next: Cryptography
From: laredotornado on 5 Sep 2008 10:23 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
From: Zelda Rottencrotch on 5 Sep 2008 12:43 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.
From: Msj121 on 5 Sep 2008 15:01 On Sep 5, 10:23 am, laredotornado <laredotorn...(a)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
From: Daniele Futtorovic on 5 Sep 2008 15:17 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.
From: Knute Johnson on 5 Sep 2008 19:43
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 |