collection framework: using the good interface
- From: SL <spam@xxxxxxxxxx>
- Date: Mon, 18 Jul 2005 13:15:27 +0200
Hi,
I have a collection of objects containing information about words: each object hold a word, its part of speech (verb, noun, etc.), its frequency, and other properties.
I need to be able to retreive very quickly an objet according to some signifiant properties: its orthographic form and its part of speech for instance. A hash seems suited, but I cannot use a hash where the key is the orthographic form, for instance:
{
"plane" -> ref_to_object_holding_this_word
}
because several properties are signifiant for word identity: there is a plane "noun" and a plane "verbe".
Implementing hashkey() and equals() in my Word object seems to be the natural way, with "orthographic form" and "part of speech" fields both contributing to the definition of hashkey and equality, but in that case I would have a Map where both the key and the corresponding value are references to the same object. I'm wondering if this situation should be avoided, and if there is another solution. Since key and value are not different object, I was considering using an ArrayList object. But its indexOf(Object elem) method use equals() and not hashkey, and is probably not as much efficient as the HashMap hashing method.
Thanks, SL .
- Follow-Ups:
- Re: collection framework: using the good interface
- From: Patricia Shanahan
- Re: collection framework: using the good interface
- From: George Cherry
- Re: collection framework: using the good interface
- Prev by Date: Re: iBatis Memory Leak Bug!Some Help me!
- Next by Date: NullPointerException with JWSDP's wsdeploy
- Previous by thread: problem in coding window
- Next by thread: Re: collection framework: using the good interface
- Index(es):
Relevant Pages
|