tango.core.ByteSwap

License:

BSD style: see license.txt

Version:

Initial release: October 2004

Version:

Feb 20th 2005 - Asm version removed by Aleksey Bobnev

Author:

Kris, Aleksey Bobnev
struct ByteSwap #
Reverse byte order for specific datum sizes. Note that the byte-swap approach avoids alignment issues, so is probably faster overall than a traditional 'shift' implementation.
1
2
3
4
5
ubyte[] x = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08];

swap16 (x) => 02 01 04 03 06 05 08 07     
swap32 (x) => 04 03 02 01 08 07 06 05
swap64 (x) => 08 07 06 05 04 03 02 01
void swap16(void[] dst) [static, final] #
Reverses two-byte sequences. Parameter dst imples the number of bytes, which should be a multiple of 2
void swap32(void[] dst) [static, final] #
Reverses four-byte sequences. Parameter dst implies the number of bytes, which should be a multiple of 4
void swap64(void[] dst) [static, final] #
Reverse eight-byte sequences. Parameter dst implies the number of bytes, which should be a multiple of 8
void swap80(void[] dst) [static, final] #
Reverse ten-byte sequences. Parameter dst implies the number of bytes, which should be a multiple of 10
void swap16(void * dst, uint bytes) [static, final] #
Reverses two-byte sequences. Parameter bytes specifies the number of bytes, which should be a multiple of 2
void swap32(void * dst, uint bytes) [static, final] #
Reverses four-byte sequences. Parameter bytes specifies the number of bytes, which should be a multiple of 4
void swap64(void * dst, uint bytes) [static, final] #
Reverse eight-byte sequences. Parameter bytes specifies the number of bytes, which should be a multiple of 8
void swap80(void * dst, uint bytes) [static, final] #
Reverse ten-byte sequences. Parameter bytes specifies the number of bytes, which should be a multiple of 10