List searching

A

alejandrina

Hi all,

I have a list (ArrayList but can be anything that helps the cause) of
objects. I'd love to find a way of extracting all elements that match a
given criteria into another list. I know how to do this manually, but I
was hoping it already existed, maybe in a library with other cool
useful stuff. I looked at the Jakarta Commons Collections, but no luck.
Any suggestions?

Thanks!
 
M

Manish Pandit

Hi,

What kind of criteria? I mean, is that like a list of numbers and you
want to get a range of numbers pulled out? Or are they POJOs like a
'Person' where you want to pull out all persons 'where firstName like
'Pete', pretty much using it like a database?

You can take a look at SortedSet's subSet( ) method if that is in line
with your direction.

-cheers,
Manish
 
A

alejandrina

Yes, that's certainly useful. What would be MOST useful would be
something like:

List result = list.findAll (method)

where method is the selector. Haven't seen this anywhere...

Thanks,

Alejandrina
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top