Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread Tom
What is the most efficient way of implement a rotation of ubyte[4] array? By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3] TIA, Tom;

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread bearophile
Tom: What is the most efficient way of implement a rotation of ubyte[4] array? By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3] Two versions, I have done no benchmarks so far: import std.c.stdio: printf; union Four { ubyte[4] a; uint u; } void showFour(Four f) {

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread Kai Meyer
On 03/09/2011 03:41 PM, Tom wrote: What is the most efficient way of implement a rotation of ubyte[4] array? By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3] TIA, Tom; I don't know of anything more efficient than: ubyte[4] bytes = [1,2,3,4]; bytes = bytes[$-1] ~

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread Jonathan M Davis
On Wednesday, March 09, 2011 15:35:29 Kai Meyer wrote: On 03/09/2011 03:41 PM, Tom wrote: What is the most efficient way of implement a rotation of ubyte[4] array? By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3] TIA, Tom; I don't know of anything more efficient than:

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread Kai Meyer
On 03/09/2011 04:25 PM, bearophile wrote: Tom: What is the most efficient way of implement a rotation of ubyte[4] array? By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3] Two versions, I have done no benchmarks so far: import std.c.stdio: printf; union Four { ubyte[4] a;

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread spir
On 03/10/2011 12:55 AM, Jonathan M Davis wrote: I don't know of anything more efficient than: ubyte[4] bytes = [1,2,3,4]; bytes = bytes[$-1] ~ bytes[0..$-1]; // Rotate left I'm stunned that this works. I'd even consider reporting it as a bug. You're concatenating a ubyte[] ont a

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread U2 fan
== Quote from bearophile (bearophileh...@lycos.com)'s article Tom: What is the most efficient way of implement a rotation of ubyte[4] array? By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3] Two versions, I have done no benchmarks so far: import std.c.stdio: printf; union Four

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-09 Thread Andrew Wiley
On Wed, Mar 9, 2011 at 7:25 PM, U2 fan i...@u2fan.com wrote: == Quote from bearophile (bearophileh...@lycos.com)'s article Tom: What is the most efficient way of implement a rotation of ubyte[4] array? By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3] Two versions, I have done