Looking for a bijection between this set and natural numbers I am a computer programmer, and I am struggling with this mathematical problem without finding a consistent and efficient solution.
Let $A_{k, M}$ be the set of all the possible assignments for $n_1, n_2, ...,n_k$ non-negative integers such that $\sum_{i=1}^{k}{n_i} = M$. I need to compute $C_{k,M}=|A_{k, M}|$ for arbitrary $k, M$ and I need a bijection between $A_{k, M}$ and $[0, C_{k,M}-1]$. The bijection should be simple to compute "in both directions" and should not require exhaustive enumeration.
Example. $k = 3$, $M = 3$. The possible assignments are $\{3, 0, 0\}, \{0, 3, 0\}, \{0, 0, 3\}, \{0, 1, 2\}, \{0, 2, 1\}, \{1, 0, 2\}, \{2, 0, 1\}, \{1, 2, 0\}, \{2, 1, 0\}, \{1, 1, 1\}$, therefore $C_{k,M}=|A_{k, M}| = 10$.
I have done little research so far, I have looked at combinatorial/factorial number systems (you may assume I know what they are about) but the problem seems to be quite different. Can you give me some directions?
EDIT: I clarify a few points as requested. 1) I don't actually know there is a "simple to compute" bijection, but I do know that my inability to find it is no evidence of its nonexistence, therefore I am asking here for your advice. 2) The two sets are:
$A_{k, M} = \{ (n_1, n_2, ...,n_k) : \sum_{i=1}^{k}{n_i} = M \}$ and $[0, |A_{k, M}|-1] \subset \{ \mathbb{N}  \cup \{0\} \}$.

By the stars and bars method, there is a bijection between $A_{k,M}$ and the set of $k-1$-subsets of $\{1,2,\dots,M+k-1\}$.
Essentially, $n_1,n_2,\dots,n_k$ goes to $\{n_1+1,n_1+n_2+2,\dots,n_1+\dots+n_{k-1}+k-1\}$.
The set of $m$-subsets of $\{1,2,\dots,N\}$ can be given indices in $\{0,1,\dots,\binom{N}m-1\}$ via the squashed ordering, where $1\leq a_1<a_2<\dots<a_m\leq N$ is mapped to the integer:
$$\sum_{j=1}^m \binom{a_j-1}{j}$$
The reverse map, however, is not as easy.
To compute the reverse map, given an index $I$, find the largest $a_m$ so that $\binom{a_m-1}{m}\leq I$. Then, if you know $a_{k+1},\dots,a_m$, find the largest $a_k$ so that $$\binom{a_k-1}{k} \leq I-\sum_{j=k+1}^m \binom{a_j-1}{j}$$
[Note, in all the above, we are assuming that if $a<b$ then $\binom{a}{b}=0$.]
