how can one map barycentric indices to a single integer?
e.g.
Edit: added correct image
[Note: OP has revised the question with a slightly different barycentric indexing scheme, which makes the following no longer quite right. I'll fix it up in a minute.]
Number the rows of triangles from 0. If the big triangle has $n$ little triangles on each side, then row $k$ contains the triangles whose reference points have barycentric coords $(n-1-k,b,c)$ for some $b,c$. And it begins with triangle number $k^2$. (Rows have 1,3,5,... triangles; sums of odd numbers are squares.)
Then the (0-based) position within its row of the triangle with barycentric indices $(a,b,c)$ is $2c+\varepsilon$ where $\varepsilon$ is 0 for upward-pointing triangles and 1 for downward-pointing ones; we can distinguish these because the sum of all the barycentric indices is $n-1$ for upward triangles and $n-2$ for downward. In other words, $\varepsilon=n-1-(a+b+c)$.
Therefore, the triangle with barycentric indices $(a,b,c)$ is in row $n-1-a$ which begins with triangle $(n-1-a)^2$; within that row its (0-based) position is $2c+n-1-(a+b+c)=n-1-a-b+c$; so its index number is $(n-1-a)^2+n-1-a-b+c$.
Let's do a spot check. Triangle 7 has $(a,b,c)=(0,0,1)$ and $n-1=2$. So the index number is $(2-0)^2+2-0-0+1$ which is indeed 7. Looks like it works.
(Remark: $n-1$ is probably a nicer parameter to work with than $n$ itself.)