What is best?
+maintain Hashtable for each key
+make a iterate over the list
Or have another way?
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
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
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
I think the OP meant 'equivalent'.
>
Martien
--
|
Martien Verbruggen | 640K (of RAM) ought to be enough for anybody.
| -- Bill Gates, 1981
|
>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)
Lew <no...@lewscanon.com> wrote:
>> What is "equipollent"?
Martien Verbruggen wrote:
> I think the OP meant 'equivalent'.
Really?
--
Lew
Yes.
Martien
--
|
Martien Verbruggen | For heaven's sake, don't TRY to be
first...@heliotrope.com.au | cynical. It's perfectly easy to be
| cynical.