summaryrefslogtreecommitdiffstats
path: root/src/iter.rs
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2021-08-28 09:45:57 -0400
committerMalfurious <m@lfurio.us>2021-08-28 10:01:42 -0400
commit7bd18b4b22f3a6bf86b131329345f9a75d8f699c (patch)
tree07f2ac0cb38a7424b711c2dd9b59116e2ed0848b /src/iter.rs
parent1522a21d24add0d78f7e4a5fae7654b709045754 (diff)
downloadSorensenCompression-7bd18b4b22f3a6bf86b131329345f9a75d8f699c.tar.gz
SorensenCompression-7bd18b4b22f3a6bf86b131329345f9a75d8f699c.zip
Commit Rust POC
This replaces the Python script. Since all MIT-licensed code is removed, the LICENSE file is as well. 'cargo run' to run the program. Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'src/iter.rs')
-rw-r--r--src/iter.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/iter.rs b/src/iter.rs
new file mode 100644
index 0000000..f8aa6cb
--- /dev/null
+++ b/src/iter.rs
@@ -0,0 +1,10 @@
+use num::BigInt;
+
+pub fn next(v: &BigInt) -> BigInt
+{
+ /*let t: BigUint = v | (v - 1);
+ (t + 1) | (((!t & -!t) - 1) >> (v.trailing_zeros() + 1))*/
+
+ let t: BigInt = (v | (v - 1u32)) + 1u32;
+ &t | ((((&t & -&t) / (v & -v)) >> 1) - 1u32)
+}