TimurMahammadov / google-collections

Automatically exported from code.google.com/p/google-collections
Apache License 2.0
0 stars 0 forks source link

Add DefaultMap #101

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Python has a swell default-assuming subclass of its Map type called
defaultdict.  It works like a regular dictionary when a value exists for a
key, but if there isn't one, it creates a value with a default factory. 
The attached patch contains a subclass of ForwardingMap called DefaultMap
that does something similar for Java Maps.  You can see some usages of
defaultdict at
http://www.python.org/doc/2.5.2/lib/defaultdict-examples.html, and all of
those are applicable to DefaultMap.

Original issue reported on code.google.com by charlie....@gmail.com on 27 Oct 2008 at 5:31

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the suggestion.

Internally, Google has a caching library that includes the functionality you're
proposing. Unfortunately, that doesn't help you until we open-source it.

Original comment by jared.l....@gmail.com on 27 Oct 2008 at 5:07

GoogleCodeExporter commented 9 years ago
The forthcoming snapshot will include MapMaker, which allows you to create maps 
that
do all this and more.  It should make you more than happy!

Original comment by kevin...@gmail.com on 11 Feb 2009 at 12:53