STL multimap

castironpi at gmail.com castironpi at gmail.com
Mon May 5 19:40:50 EDT 2008


On May 5, 1:26 pm, Aaron Watters <aaron.watt... at gmail.com> wrote:
> 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

It's possible there are four different kinds of multimaps.

objects map to set
objects map to frozenset
objects map to sequence
frozenset maps to object

What does the STL use?  I am interested in a serialization that
changes certain bits and appends more.  Prior discussion brought me to
multimap, but that quotient stifled it.

> 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.

I was referring to a couple of threads from the Winter [cit. off'd.]
that never really gelled.

Modifying parameters is crucial to a number of control flow structures
(program divisions).  Examples could come handy.

>>> def a( x ): x[:]= [x[0]+ 1]
...
>>> b= [2]
>>> a(b)
>>> b
[3]

I'm not sure if doing so is operating strictly by side-effect, or what
the term is.  I forget from theory class if all the same terminology
holds post hoc* to introduction of Memory structures, either hard or
soft as modeled in formal functional-expressional language systems.  I
noticed the idiom x[:]= [y].  Does it mean the right thing?  At higher
levels of complexity, it scans as an unnamed struct.  (Warning,
interacts with logical development.)  What is the meaning of slice
assigment, if not?

*post/poster [...after]. This use originates in the Latin phrase,
'post hoc ergo propter hoc'.

> 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+securit...





More information about the Python-list mailing list