def _s2cmi(m, nidx):
 nv = (-1)
 for (i, v) in m.items():
  if (i >= nidx):
   m[i] += 1
  elif (v > nv):
   nv = v
 m[nidx] = (nv + 1)
 return (nv + 1)

def _s2cmi ( m , nidx ) : nv = ( - 1 ) for ( i , v ) in m . items ( ) : if ( i >= nidx ) : m [ i ] += 1 elif ( v > nv ) : nv = v m [ nidx ] = ( nv + 1 ) return ( nv + 1 )
sparse to contigous mapping inserter .