Hello everyone,
I want to use indexing technology to speed up searching operation of my application. I have found that Java built-in type Hashtable can only have one key for each object. But my requirement is that an object can have multiple keys for an object. For example, the objects may be arranged in the following model,
Object (key1, key2, value)
and the related instances maybe
John ("male", "single", <personal information of John>)
Smith ("male", "married", <personal information of Smith>)
When given key1 (or key2, or key1 and key2 altogether), I want to find out matched objects. For example, when given "male", John and Smith are both matched. When given "single", only John is matched. When given "female" and "single", no records are matched.
Thanks in advance,
George
Yeah Java does not provide MultiKey Map kind of a thing. So you are left with 2 choices. Use some third party class (jakarta collections package has what you are looking for) or implement your own. You can do this by extending the HashMap class or simply defining a custom "equals" function for your "key" class instead of using default String class for key.
cheers,
aj.wh.ca
Reputation Points: 12
Solved Threads: 1
Junior Poster in Training
Offline 53 posts
since Mar 2005