struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Denis Avdic <de...@betterway.net>
Subject Re: [WAY OT] Hashtable implementation
Date Thu, 29 May 2003 20:25:07 GMT
Well,  I want to be able to add one object at a time, and remove them 
one at a time as well as as collections.
Trivial, i know, but I'd rather skip the whole get(key), cast as a list, 
remove object from list, put(key, list); 
I already implemented this, I was wondering if someone else has done it, 
maybe more efficiently etc...

Denis


Mark Galbreath wrote:

>This is done for you automatically with java.util.SortedMap.  If you want
>multiple objects referenced by the same key, just put Collection's into the
>Map as the values:
>
>SortedMap myMap = new TreeMap();
>List myList = new SortedList();
>myList.add( object1, object2, object3,...);
>myMap.put( "1", myList );
>
>Assuming your List contains people's data who were born on Jan 1, you can
>then iterate through the values of the SortedMap with the guarantee that (a)
>the keys (representing months) will be sorted in ascending order and the
>values will also be sorted in ascending order.
>
>Mark
>
>-----Original Message-----
>From: Denis Avdic [mailto:denis@betterway.net] 
>Sent: Thursday, May 29, 2003 3:24 PM
>To: Struts Users Mailing List
>Subject: Re: [WAY OT] Hashtable implementation
>
>
>Well, if its a map, it helps sorting.  I take all elements under one 
>key, dump them into the "bucket" under that key, then get a list of all 
>keys and sort the keys only.  So if you have (lets say) 100000 users, 
>and there are only 365 possible birthdays, it is much faster to sort 356 
>than 100000.  Then I have a sorted list of keys and a storage for all 
>100000 objects, and I have to search only 356 keys to get to (lets say) 
>February 28th birthday, and then I have all the users I want, either in 
>"bucket" or in singular form.
>
>
>
>Paul Curren wrote:
>
>  
>
>>Hi there,
>>
>>If you want multiple objects under the same key then essentially you
>>are just looking for a generic list/collection or whatever you want to 
>>call it. No?
>>
>>Or perhaps there are to be multiple lists - a Map containing entries
>>that are Collections then I guess.
>>
>>Paul C
>>
>>Denis Avdic wrote:
>>
>>    
>>
>>>Hey,
>>>I know this is probably a really stupid question but i am looking for
>>>a Hashtable (or similar) that will store multiple objects under the 
>>>same key.
>>>I wrote a superficial implementation myself (put, size and get 
>>>methods only) based on the Hashtable, but I am interested to know if 
>>>there is something out there already implementing this functionality.
>>>
>>>Thanks,
>>>
>>>Denis
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>>
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message