Struct donet_core::hashgen::DCHashGenerator
source · pub struct DCHashGenerator {
hash: i32,
index: u16,
primes: PrimeNumberGenerator,
}
Expand description
The following is an excerpt from Panda3D’s source:
We multiply each consecutive integer by the next prime number and add it to the total. This will generate pretty evenly-distributed hash numbers for an arbitrary sequence of integers.
We do recycle the prime number table at some point, just to keep it from growing insanely large, however (and to avoid wasting time computing large prime numbers unnecessarily), and we also truncate the result to the low- order 32 bits.
Fields§
§hash: i32
§index: u16
§primes: PrimeNumberGenerator
Implementations§
source§impl DCHashGenerator
impl DCHashGenerator
sourcepub fn add_blob(&mut self, blob: Vec<u8>)
pub fn add_blob(&mut self, blob: Vec<u8>)
Adds a blob to the hash, by breaking it down into a sequence of integers.
sourcepub fn add_string(&mut self, string: String)
pub fn add_string(&mut self, string: String)
Adds a string to the hash, by breaking it down into a sequence of integers.
pub const fn get_hash(&self) -> DCFileHash
Trait Implementations§
source§impl Default for DCHashGenerator
impl Default for DCHashGenerator
source§fn default() -> DCHashGenerator
fn default() -> DCHashGenerator
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DCHashGenerator
impl RefUnwindSafe for DCHashGenerator
impl Send for DCHashGenerator
impl Sync for DCHashGenerator
impl Unpin for DCHashGenerator
impl UnwindSafe for DCHashGenerator
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more