Take a list of key-value pairs, or an array of value-value pairs. By "key" I mean a value which is unique, whereas a normal value may be duplicated. So a value-value pair would indicated neither value is necessarily unique within the context of the list.
I'm now thinking of a linked list that orders by both values, so eg:
Code:
struct node {
int A;
int B;
struct node *nextA;
struct node *nextB;
};
A list like this would have two heads and an insertion would place the node in ordered sequence based on both values (meaning there are two distinct sequences). The list could then be walked according to either ordering. Eg, given...
Code:
...can't use set notation outside code tags >_<
{2,3}, {666,-11} and {1024,0}:
Code:
Order A Order B
{2,3} {666,-11}
{666,-11} {1024,0}
{1024, 0} {2,3}
When I've done that before, it's been fine to just concoct order B on the fly when needed, but I'm surprised I've never heard of a generic data structure which spends some memory to maintain both orders.
It must have a name? (If not, I kind of like n-braid, because this could have any number of orders beyond 2).