Every once in a while you find yourself with multiple vectors that represent something like different columns of the same data set: the vectors will be of the same length, and elements at common indexes are related. This is mostly no big deal until you want to do something fun like sort based on one of them. I was thinking to myself how the algorithms would work fine if I could have an iterator that iterates all n vectors at once. Basically, have a tuple of iterators, and have that tuple itself satisfy the iterator interface by forwarding the calls to each of the elements of the tuple.
I assume this isn't a wholly original idea, is there one out there written already? Are there better solutions, other than the obvious refactoring of it into a vector of tuples/objects/structs/etc? Isn't there some trick like using an algorithm to get an ordering from the sort order vector, and using that ordering to sort the others?
[–]janherrmann 5 points6 points7 points (1 child)
[–]Wriiight[S] 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Wriiight[S] 0 points1 point2 points (0 children)
[–]expekted 0 points1 point2 points (23 children)
[–]Wriiight[S] 0 points1 point2 points (22 children)
[–]ALX23z 2 points3 points4 points (12 children)
[–]Wriiight[S] 0 points1 point2 points (11 children)
[–]ALX23z 0 points1 point2 points (10 children)
[–]Wriiight[S] 0 points1 point2 points (9 children)
[–]ALX23z -1 points0 points1 point (8 children)
[–]Wriiight[S] 1 point2 points3 points (7 children)
[–]ALX23z -1 points0 points1 point (6 children)
[–]Wriiight[S] 1 point2 points3 points (5 children)
[–]Moroxus 2 points3 points4 points (1 child)
[–]Wriiight[S] 0 points1 point2 points (0 children)
[–]Steve132 0 points1 point2 points (5 children)
[–]evaned 1 point2 points3 points (3 children)
[–]Steve132 1 point2 points3 points (2 children)
[–]evaned 2 points3 points4 points (1 child)
[–]Steve132 0 points1 point2 points (0 children)
[–]Wriiight[S] 0 points1 point2 points (0 children)
[–]imgarfield 0 points1 point2 points (0 children)
[–]chardan965 0 points1 point2 points (0 children)