Optimal Streaming Permutations And Transforms: Theory And Implementation