/* Shuffle a block. This can never fail. */ void shuffle(size_t bytesoftype, size_t blocksize, uint8_t* _src, uint8_t* _dest) { int unaligned_dest = (int)((uintptr_t)_dest % 16); int multiple_of_block = (blocksize % (16 * bytesoftype)) == 0; int too_small = (blocksize < 256); if (unaligned_dest || !multiple_of_block || too_small) { /* _dest buffer is not aligned, not multiple of the vectorization size * or is too small. Call the non-sse2 version. */ _shuffle(bytesoftype, blocksize, _src, _dest); return; } /* Optimized shuffle */ /* The buffer must be aligned on a 16 bytes boundary, have a power */ /* of 2 size and be larger or equal than 256 bytes. */ if (bytesoftype == 4) { shuffle4(_dest, _src, blocksize); } else if (bytesoftype == 8) { shuffle8(_dest, _src, blocksize); } else if (bytesoftype == 16) { shuffle16(_dest, _src, blocksize); } else if (bytesoftype == 2) { shuffle2(_dest, _src, blocksize); } else { /* Non-optimized shuffle */ _shuffle(bytesoftype, blocksize, _src, _dest); } }
void Deck::initialize(int seed) { // clear the current deck and shuffle _playedCards.clear(); _discardedCards.clear(); _shuffle(seed); }
void sort(Itr begin, Itr end) { _shuffle(begin, end); _sort(begin, end); _insertion_sort(begin, end); }
void shuffle(size_t bytesoftype, size_t blocksize, uint8_t* _src, uint8_t* _dest) { _shuffle(bytesoftype, blocksize, _src, _dest); }