<commit_before>use super::{ValueSet, ScannableSet, KnownBits, UIntMultiple, UIntRange, SIntRange};
use super::{EMPTY_UINTMULTIPLE, EMPTY_UINTRANGE, EMPTY_SINTRANGE};
use std::ops::{BitAnd, BitOr};
use util::{tzmsk, gcd_lcm, multiplicative_inverse};

// TODO: Find appropriate consts from stdlib
const U64MIN: u64 =  0x0000000000000000;
const U64MAX: u64 =  0xffffffffffffffff;
const S64MIN: i64 = -0x8000000000000000;
const S64MAX: i64 =  0x7fffffffffffffff;

impl ValueSet<u64> for UIntMultiple {
	fn contains(&self, value: u64) -> bool {
		if self.modulus == 0 { return false }
		value % self.modulus == self.residue
	}
}

impl ScannableSet<u64> for UIntMultiple {
	fn scan_up(&self, n: u64) -> Option<u64> {
		let io = self.modulus - self.residue;
		if n > U64MAX - io { return Option::None }
		let t = (n + io) % self.modulus;
		Option::Some(if t == 0 { n } else { n + (self.modulus - t) })
	}
	fn scan_dn(&self, n: u64) -> Option<u64> {
		if n < self.residue { return Option::None }
		Option::Some(n - (n-self.residue)%self.modulus)
	}
}

impl UIntMultiple {
	pub fn as_knownbits(&self) -> KnownBits {
		let z = tzmsk(self.modulus);
		KnownBits {
			zerobits: z & !self.residue,
			onebits:  z &  self.residue<commit_msg>use appropriate consts from stdlib<commit_after>use super::{ValueSet, ScannableSet, KnownBits, UIntMultiple, UIntRange, SIntRange};
use super::{EMPTY_UINTMULTIPLE, EMPTY_UINTRANGE, EMPTY_SINTRANGE};
use std;
use std::ops::{BitAnd, BitOr};
use util::{tzmsk, gcd_lcm, multiplicative_inverse};

const U64MIN: u64 =  std::u64::MIN;  // 0x0000000000000000;
const U64MAX: u64 =  std::u64::MAX;  // 0xffffffffffffffff;
const S64MIN: i64 =  std::i64::MIN;  // -0x8000000000000000;
const S64MAX: i64 =  std::i64::MAX;  // 0x7fffffffffffffff;

impl ValueSet<u64> for UIntMultiple {
	fn contains(&self, value: u64) -> bool {
		if self.modulus == 0 { return false }
		value % self.modulus == self.residue
	}
}

impl ScannableSet<u64> for UIntMultiple {
	fn scan_up(&self, n: u64) -> Option<u64> {
		let io = self.modulus - self.residue;
		if n > U64MAX - io { return Option::None }
		let t = (n + io) % self.modulus;
		Option::Some(if t == 0 { n } else { n + (self.modulus - t) })
	}
	fn scan_dn(&self, n: u64) -> Option<u64> {
		if n < self.residue { return Option::None }
		Option::Some(n - (n-self.residue)%self.modulus)
	}
}

impl UIntMultiple {
	pub fn as_knownbits(&self) -> KnownBits {
		let z = tzmsk(self.modulus);
		KnownBits {
			zerobits: z & !self.residue,
			onebits:  z &  self.residue
{'fraction_non_alphanumeric': 0.14638027048528243, 'fraction_numerical': 0.059665871121718374, 'mean_word_length': 4.185567010309279, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 8, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7134372', 'n_tokens_mistral': 1140, 'n_tokens_neox': 982, 'n_words': 237}