Function onejoker::cards::hashes::ojh_bitfield_mp5_english

source ·
pub fn ojh_bitfield_mp5_english(cards: &[Card]) -> u32
Expand description

wiki | Convert bitfield to MPH

Start by creating a bitfield in the same manner as ojh_bitfield_64co(). This is essentially a radix sort of the cards. Then compute the index of particular set of bits for minimal perfect hash. Note: doesn’t check for errors. Whatever 5 bytes happen to be at the address you pass, that’s what it will use, and will return a value. Interestingly, the single-64-bit-read optimization from base13_mp5_low above didn’t make that much difference here or in the other bitfield hashes, so I’ve left in the safer version.

use onejoker::prelude::*;
use onejoker::cards::hashes::*;

let d = Deck::new(DeckType::English);
let h = d.new_hand().init(hand!("2s","2d","2c","2h","3c"));
assert_eq!(1, ojh_bitfield_mp5_english(&h[..]));