use data::hash;
use data::hash::HashFun;
use data::uid_remap::FastKey;
#[derive(Clone, Copy)]
pub struct Pair {
pub first: FastKey,
pub second: FastKey,
ifirst: usize,
isecond: usize,
}
impl Pair {
pub fn new(a: FastKey, b: FastKey) -> Pair {
let ia = a.uid();
let ib = b.uid();
if a.uid() < b.uid() {
Pair {
first: a,
second: b,
ifirst: ia,
isecond: ib,
}
} else {
Pair {
first: a,
second: b,
ifirst: ib,
isecond: ia,
}
}
}
}
impl PartialEq for Pair {
#[inline]
fn eq(&self, other: &Pair) -> bool {
self.ifirst == other.ifirst && self.isecond == other.isecond
}
}
pub struct PairTWHash {
unused: usize,
}
impl PairTWHash {
pub fn new() -> PairTWHash {
PairTWHash { unused: 0 }
}
}
impl HashFun<Pair> for PairTWHash {
#[inline]
fn hash(&self, p: &Pair) -> usize {
hash::tomas_wang_hash(hash::key_from_pair(p.ifirst, p.isecond))
}
}