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

M

mttc

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?
 
L

Lew

mttc 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?
(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.
 
J

J. Davidson

Lew said:
What is "equipollent"?


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


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
 
A

Arne Vajhøj

mttc 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?
(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
 
Joined
Nov 25, 2008
Messages
17
Reaction score
0
use Map,HashMap,Vector or use ArrayList<Person>,this Person is Object,it means all.
 
R

Roedy Green

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)
 

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,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top