what is suggesting for table in memory with ability of search on twokeys?

Discussion in 'Java' started by mttc, Nov 24, 2008.

  1. mttc

    mttc Guest

    I have dynamic list (100 rec) of record (it's not come from DB) that
    have some field. and I need two or more keys for quick search. let's
    talk about Person record with ID and Phone. How I do that?
    (in short, I looking equipollent for dotnet Datatable)

    What is best?
    +maintain Hashtable for each key
    +make a iterate over the list

    Or have another way?
     
    mttc, Nov 24, 2008
    #1
    1. Advertising

  2. mttc

    Lew Guest

    Re: what is suggesting for table in memory with ability of searchon two keys?

    mttc wrote:
    > I have dynamic list (100 rec) of record (it's not come from DB) that
    > have some field. and I need two or more keys for quick search. let's
    > talk about Person record with ID and Phone. How I do that?
    > (in short, I looking equipollent for dotnet Datatable)


    What is "equipollent"?

    > What is best?
    > +maintain Hashtable for each key


    Don't use Hashtable; it's been out of date since 1998. Use HashMap or other Map.

    > +make a iterate over the list
    >
    > Or have another way?


    You might need to maintain more than one lookup structure, perhaps a pair of
    HashMaps.

    Write your data structures and access methods so that client code doesn't
    depend on the inner implementation. That way you can switch from, say, twin
    HashMaps to an iteration over a List without having to refactor other code.

    --
    Lew
     
    Lew, Nov 24, 2008
    #2
    1. Advertising

  3. mttc

    J. Davidson Guest

    Re: what is suggesting for table in memory with ability of searchon two keys?

    Lew wrote:
    > mttc wrote:
    >> I have dynamic list (100 rec) of record (it's not come from DB) that
    >> have some field. and I need two or more keys for quick search. let's
    >> talk about Person record with ID and Phone. How I do that?
    >> (in short, I looking equipollent for dotnet Datatable)

    >
    > What is "equipollent"?
    >
    >> What is best?
    >> +maintain Hashtable for each key

    >
    > Don't use Hashtable; it's been out of date since 1998. Use HashMap or
    > other Map.
    >
    >> +make a iterate over the list
    >>
    >> Or have another way?

    >
    > You might need to maintain more than one lookup structure, perhaps a
    > pair of HashMaps.


    And you might not. If the key types are all completely separate, you may
    be able to get away with using a HashMap<Object,ValueType> and putting
    each value in at each of its separate keys.

    Encapsulate it, though, in a MultiMap class or whatever you want to call it.

    - jenny
     
    J. Davidson, Nov 24, 2008
    #3
  4. mttc

    Arne Vajhøj Guest

    Re: what is suggesting for table in memory with ability of searchon two keys?

    mttc wrote:
    > I have dynamic list (100 rec) of record (it's not come from DB) that
    > have some field. and I need two or more keys for quick search. let's
    > talk about Person record with ID and Phone. How I do that?
    > (in short, I looking equipollent for dotnet Datatable)
    >
    > What is best?
    > +maintain Hashtable for each key
    > +make a iterate over the list
    >
    > Or have another way?


    I would start with ArrayList<Person> and if performance
    needs a boost then add HashMap<Integer,Person> and
    HashMap<String,Person>.

    There are no problems having multiple structure
    because they all only have refs to the Person
    objects.

    Arne
     
    Arne Vajhøj, Nov 25, 2008
    #4
  5. Re: what is suggesting for table in memory with ability of searchon two keys?

    On Mon, 24 Nov 2008 09:52:35 -0500,
    Lew <> wrote:
    > mttc wrote:
    >> I have dynamic list (100 rec) of record (it's not come from DB) that
    >> have some field. and I need two or more keys for quick search. let's
    >> talk about Person record with ID and Phone. How I do that?
    >> (in short, I looking equipollent for dotnet Datatable)

    >
    > What is "equipollent"?


    I think the OP meant 'equivalent'.
    >

    Martien
    --
    |
    Martien Verbruggen | 640K (of RAM) ought to be enough for anybody.
    | -- Bill Gates, 1981
    |
     
    Martien Verbruggen, Nov 25, 2008
    #5
  6. mttc

    heyx

    Joined:
    Nov 25, 2008
    Messages:
    17
    use Map,HashMap,Vector or use ArrayList<Person>,this Person is Object,it means all.
     
    heyx, Nov 25, 2008
    #6
  7. mttc

    Roedy Green Guest

    Re: what is suggesting for table in memory with ability of search on two keys?

    On Mon, 24 Nov 2008 02:42:35 -0800 (PST), mttc <>
    wrote, quoted or indirectly quoted someone who said :

    >I have dynamic list (100 rec) of record (it's not come from DB) that
    >have some field. and I need two or more keys for quick search. let's
    >talk about Person record with ID and Phone. How I do that?


    Two HashMaps on the same set of objects.

    See http://mindprod.com/jgloss/hashmap.html
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    "Humanity is conducting an unintended, uncontrolled, globally pervasive experiment
    whose ultimate consequences could be second only to global nuclear war."
    ~ Environment Canada (The Canadian equivalent of the EPA on global warming)
     
    Roedy Green, Nov 25, 2008
    #7
  8. mttc

    mttc Guest

    Re: what is suggesting for table in memory with ability of search ontwo keys?

    thanks for all, so for safe thread I go to use with pair of
    ConcurrentHashMap.
     
    mttc, Nov 25, 2008
    #8
  9. mttc

    Lew Guest

    Re: what is suggesting for table in memory with ability of searchon two keys?

    mttc wrote:
    >>> (in short, I looking equipollent for dotnet Datatable)


    Lew <> wrote:
    >> What is "equipollent"?


    Martien Verbruggen wrote:
    > I think the OP meant 'equivalent'.


    Really?

    --
    Lew
     
    Lew, Nov 25, 2008
    #9
  10. Re: what is suggesting for table in memory with ability of searchon two keys?

    On Tue, 25 Nov 2008 09:55:28 -0500,
    Lew <> wrote:
    > mttc wrote:
    >>>> (in short, I looking equipollent for dotnet Datatable)

    >
    > Lew <> wrote:
    >>> What is "equipollent"?

    >
    > Martien Verbruggen wrote:
    >> I think the OP meant 'equivalent'.

    >
    > Really?


    Yes.

    Martien
    --
    |
    Martien Verbruggen | For heaven's sake, don't TRY to be
    | cynical. It's perfectly easy to be
    | cynical.
     
    Martien Verbruggen, Nov 25, 2008
    #10
    1. Advertising

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. Rim
    Replies:
    20
    Views:
    703
    Corey Coughlin
    Jul 8, 2003
  2. Jordan Rastrick
    Replies:
    22
    Views:
    640
    Oren Tirosh
    Mar 27, 2005
  3. Replies:
    11
    Views:
    432
  4. Antoon Pardon
    Replies:
    3
    Views:
    264
    Steven Bethard
    Mar 6, 2006
  5. Mark Owert
    Replies:
    3
    Views:
    99
    Kris Eiben
    Sep 12, 2003
Loading...

Share This Page