![]() |
| ||
| Question about indexing objects 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 |
| ||
| Re: Question about indexing objects Quote:
cheers, aj.wh.ca |
| ||
| Re: Question about indexing objects Thanks aj.wh.ca, Quote:
Another question is, what class of jakarta Collection should I use to meet my requirements? I have studied the document of jakarta Collection but can not find a suitable one. Could you help? regards, George |
| ||
| Re: Question about indexing objects Quote:
For the 3rd party API consider following link. http://jakarta.apache.org/commons/co.../MultiMap.html A simpler solution would be as I said earlier to make a new class. e.g. public class MyKey // you may want to extend an existing class say String { String[] keys ; MyKey(String[] k){....} public boolean equals(MyKey k){//simply compare the keys here as per your conditions} } Now in the hashmap for key,value pair insert object of MyKey and the associated value. This may not be best in performance but this is clean and simple. regards, aj.wh.ca |
| ||
| Re: Question about indexing objects Thanks aj.wh.ca, Quote:
regards, George |
| All times are GMT -4. The time now is 9:55 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC