STL multimap
Aaron Watters
aaron.watters at gmail.com
Mon May 5 14:26:46 EDT 2008
Hi there. Maybe a little more context would
help us figure out what you want here...
On May 5, 1:28 pm, castiro... at gmail.com wrote:
> Is multimap just a syntax-checked dictionary of mutable sequences?
I think the equivalent of a multimap can be
implemented several different ways, depending on
what you need:
for
1 maps to 2,3
5 maps to 7
- dictionary mapping to lists
{ 1:[2,3], 5:[7] } # supports unhashable values
- dictionary mapping to dictionary
{ 1:{2:None,3:None}, 4:{7:None} } # faster for certain lookups
and dense data
- dictionary with tuple/pairs as keys
{ (1,2):None, (1,3):None, (4,7):None } # streamlined for
existence testing
If you search usenet (google groups) for multimap
you will find some nice discussions by Alex Martelli and others.
> Is def( a ): a[:]= [x] a trick or part of the language? It looks
> pretty sharp in variable-width.
You lost me here.
python 2.6:
>>> def (a): a[:]=[x]
File "<stdin>", line 1
def (a): a[:]=[x]
^
SyntaxError: invalid syntax
All the best. -- Aaron Watters
===
http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=gaping+security+hole
More information about the Python-list
mailing list