castironpi at gmail.com
Wed Aug 27 21:39:33 CEST 2008
On Aug 27, 1:38 pm, brad <byte8b... at gmail.com> wrote:
> castironpi wrote:
> > I don't understand what a multimap does that a map of lists doesn't do.
> It counts both keys individually as separate keys. The Python workaround
> does not... see examples... notice the key(s) that are '4'
> Python output (using the k =  idea):
> Key: 4 Value: [[13, 'Visa'], [16, 'Visa']]
> A C++ multimap
> Key: 4 Value: Visa 16
> Key: 4 Value: Visa 13
You are looking at a two-line workaround. A single Key-4 element is
always k, if 4 is in k. To remove k is a little trickier.
If len( k )> 1: k.pop( ), else k.pop( 4 )[ 0 ]. (Smooth.)
More information about the Python-list