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.
ubyte[] x = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08];
auto a = x.dup;
ByteSwap.swap16(a);
assert(a == [cast(ubyte) 0x02, 0x01, 0x04, 0x03, 0x06, 0x05, 0x08, 0x07]);
auto b = x.dup;
ByteSwap.swap32(b);
assert(b == [cast(ubyte) 0x04, 0x03, 0x02, 0x01, 0x08, 0x07, 0x06, 0x05]);
auto c = x.dup;
ByteSwap.swap64(c);
assert(c == [cast(ubyte) 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01]);
- static final void swap16(void[] dst);
- Reverses two-byte sequences. Parameter dst imples the
number of bytes, which should be a multiple of 2
- static final void swap32(void[] dst);
- Reverses four-byte sequences. Parameter dst implies the
number of bytes, which should be a multiple of 4
- static final void swap64(void[] dst);
- Reverse eight-byte sequences. Parameter dst implies the
number of bytes, which should be a multiple of 8
- static final void swap80(void[] dst);
- Reverse ten-byte sequences. Parameter dst implies the
number of bytes, which should be a multiple of 10
- static final void swap16(void* dst, size_t bytes);
- Reverses two-byte sequences. Parameter bytes specifies the
number of bytes, which should be a multiple of 2
- static final void swap32(void* dst, size_t bytes);
- Reverses four-byte sequences. Parameter bytes specifies the
number of bytes, which should be a multiple of 4
- static final void swap64(void* dst, size_t bytes);
- Reverse eight-byte sequences. Parameter bytes specifies the
number of bytes, which should be a multiple of 8
- static final void swap80(void* dst, size_t bytes);
- Reverse ten-byte sequences. Parameter bytes specifies the
number of bytes, which should be a multiple of 10