// output of ./demo/perm/swap-blocks-demo.cc: // Description: //% The quadruple reversal trick. arg 1: 5 == x1 [Start of first block] default=5 arg 2: 5 == n1 [Length of first block] default=5 arg 3: 12 == x2 [Start of second block] default=12 arg 4: 4 == n2 [Length of second block] default=4 v v v v v v v v v <--= want to swap these blocks [ 0 1 2 3 4 a b c d e 7 8 w x y z N N N ] orig. data [ 0 1 2 3 4 e d c b a 7 8 w x y z N N N ] reverse first block [ 0 1 2 3 4 e d c b a 8 7 w x y z N N N ] reverse range between blocks [ 0 1 2 3 4 e d c b a 8 7 z y x w N N N ] reverse last block [ 0 1 2 3 4 w x y z 7 8 a b c d e N N N ] reverse whole range v v v v v v v v v <--= want to swap these blocks [ 0 1 2 3 4 w x y z 7 8 a b c d e N N N ] orig. data [ 0 1 2 3 4 z y x w 7 8 a b c d e N N N ] reverse first block [ 0 1 2 3 4 z y x w 8 7 a b c d e N N N ] reverse range between blocks [ 0 1 2 3 4 z y x w 8 7 e d c b a N N N ] reverse last block [ 0 1 2 3 4 a b c d e 7 8 w x y z N N N ] reverse whole range