Mapping an index to each pair of unique points

I like to order the pairs (or, in general, ordered tuples) in what's called "colex" order, which is lexicographic order of the reversed tuple. Or, in other words, sorted by the largest element (and using the next largest element as a tie-breaker if the tuples are bigger than pairs.) This results in the ordering

 0: (0, 1)
 1: (0, 2)
 2: (1, 2)
 3: (0, 3)
 4: (1, 3)
 5: (2, 3)
 6: (0, 4)
 7: (1, 4)
 8: (2, 4)
 9: (3, 4)

The advantage of this ordering is that it doesn't depend on N, which is extremely helpful if you might later need to increase N without invalidating any existing index.

You can then compute (x, y) as:

n = floor((sqrt(8 * i + 1) - 1) / 2)
x = i - n * (n + 1) / 2
y = n + 1