List searching

Discussion in 'Java' started by alejandrina, Sep 29, 2006.

  1. alejandrina

    alejandrina Guest

    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!
     
    alejandrina, Sep 29, 2006
    #1
    1. Advertisements

  2. 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
     
    Manish Pandit, Sep 30, 2006
    #2
    1. Advertisements

  3. alejandrina

    alejandrina Guest

    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


    Manish Pandit wrote:
    > 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
     
    alejandrina, Oct 1, 2006
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. michael Rogowski

    Searching Point x/y in a ordered List

    michael Rogowski, Jul 22, 2004, in forum: C++
    Replies:
    1
    Views:
    493
    Victor Bazarov
    Jul 22, 2004
  2. Rajarshi Guha

    searching for matches within a word list

    Rajarshi Guha, Jul 29, 2003, in forum: Python
    Replies:
    1
    Views:
    314
    Scott David Daniels
    Jul 30, 2003
  3. Repton
    Replies:
    5
    Views:
    347
    Peter Otten
    Jul 13, 2005
  4. Odd-R.
    Replies:
    2
    Views:
    430
    Sion Arrowsmith
    Aug 10, 2005
  5. stumblng.tumblr
    Replies:
    1
    Views:
    266
    stumblng.tumblr
    Feb 4, 2008
Loading...

Share This Page